@@ -75,12 +75,8 @@ STATIC mp_obj_t mp_lcd_spi_bus_make_new(const mp_obj_type_t *type, size_t n_args
75
75
mp_lcd_spi_bus_obj_t * self = m_new_obj (mp_lcd_spi_bus_obj_t );
76
76
self -> base .type = & mp_lcd_spi_bus_type ;
77
77
78
- if ((args [ARG_spi_mode ].u_int > 3 ) || (args [ARG_spi_mode ].u_int < 0 )) {
79
- mp_raise_msg_varg (& mp_type_ValueError , MP_ERROR_TEXT ("invalid spi mode (%d)" ), args [ARG_spi_mode ].u_int );
80
- }
81
-
82
78
self -> callback = mp_const_none ;
83
- self -> spi_bus = (esp32_hw_spi_bus_obj_t * )MP_OBJ_TO_PTR (args [ARG_spi_bus ].u_obj )
79
+ self -> spi_bus = (esp32_hw_spi_bus_obj_t * )MP_OBJ_TO_PTR (args [ARG_spi_bus ].u_obj );
84
80
self -> panel_io_handle .panel_io = NULL ;
85
81
self -> bus_handle = (esp_lcd_spi_bus_handle_t )self -> spi_bus -> host ;
86
82
@@ -112,13 +108,15 @@ STATIC mp_obj_t mp_lcd_spi_bus_make_new(const mp_obj_type_t *type, size_t n_args
112
108
printf ("cs_gpio_num=%d\n" , self -> panel_io_config .cs_gpio_num );
113
109
printf ("dc_gpio_num=%d\n" , self -> panel_io_config .dc_gpio_num );
114
110
printf ("spi_mode=%d\n" , self -> panel_io_config .spi_mode );
115
- printf ("pclk_hz=%d \n" , self -> panel_io_config .pclk_hz );
111
+ printf ("pclk_hz=%lu \n" , self -> panel_io_config .pclk_hz );
116
112
printf ("lcd_cmd_bits=%d\n" , self -> panel_io_config .lcd_cmd_bits );
117
113
printf ("lcd_param_bits=%d\n" , self -> panel_io_config .lcd_param_bits );
118
- printf ("dc_low_on_data=%d\n" , self -> panel_io_config .flags .dc_low_on_data );
119
- printf ("sio_mode=%d\n" , self -> panel_io_config .flags .sio_mode );
120
- printf ("lsb_first=%d\n" , self -> panel_io_config .flags .lsb_first );
121
- printf ("cs_high_active=%d\n" , self -> panel_io_config .flags .cs_high_active );
114
+ printf ("dc_low_on_data=%lu\n" , self -> panel_io_config .flags .dc_low_on_data );
115
+ printf ("sio_mode=%lu\n" , self -> panel_io_config .flags .sio_mode );
116
+ printf ("lsb_first=%lu\n" , self -> panel_io_config .flags .lsb_first );
117
+ printf ("cs_high_active=%lu\n" , self -> panel_io_config .flags .cs_high_active );
118
+ printf ("octal_mode=%lu\n" , self -> panel_io_config .flags .octal_mode );
119
+
122
120
#endif
123
121
124
122
return MP_OBJ_FROM_PTR (self );
@@ -134,7 +132,7 @@ mp_lcd_err_t spi_del(mp_obj_t obj)
134
132
mp_raise_msg_varg (& mp_type_ValueError , MP_ERROR_TEXT ("%d(esp_lcd_panel_io_del)" ), ret );
135
133
}
136
134
137
- ret = spi_bus_free (self -> host );
135
+ ret = spi_bus_free (self -> spi_bus -> host );
138
136
if (ret != ESP_OK ) {
139
137
mp_raise_msg_varg (& mp_type_ValueError , MP_ERROR_TEXT ("%d(spi_bus_free)" ), ret );
140
138
}
@@ -145,7 +143,7 @@ mp_lcd_err_t spi_del(mp_obj_t obj)
145
143
mp_lcd_err_t spi_init (mp_obj_t obj , uint16_t width , uint16_t height , uint8_t bpp , uint32_t buffer_size , bool rgb565_byte_swap )
146
144
{
147
145
#if CONFIG_LCD_ENABLE_DEBUG_LOG
148
- printf ("spi_init(self, width=%d , height=%d , bpp=%d , buffer_size=%d , rgb565_byte_swap=%d )\n" , width , height , bpp , buffer_size , rgb565_byte_swap );
146
+ printf ("spi_init(self, width=%i , height=%i , bpp=%i , buffer_size=%lu , rgb565_byte_swap=%i )\n" , width , height , bpp , buffer_size , ( uint8_t ) rgb565_byte_swap );
149
147
#endif
150
148
mp_lcd_spi_bus_obj_t * self = (mp_lcd_spi_bus_obj_t * )obj ;
151
149
@@ -158,11 +156,11 @@ mp_lcd_err_t spi_init(mp_obj_t obj, uint16_t width, uint16_t height, uint8_t bpp
158
156
self -> panel_io_config .trans_queue_depth = 10 ;
159
157
160
158
#if CONFIG_LCD_ENABLE_DEBUG_LOG
161
- printf ("rgb565_byte_swap=%d \n" , self -> rgb565_byte_swap );
162
- printf ("trans_queue_depth=%d \n" , self -> panel_io_config .trans_queue_depth );
159
+ printf ("rgb565_byte_swap=%i \n" , ( uint8_t ) self -> rgb565_byte_swap );
160
+ printf ("trans_queue_depth=%i \n" , ( uint8_t ) self -> panel_io_config .trans_queue_depth );
163
161
#endif
164
162
165
- ret = esp_lcd_new_panel_io_spi (self -> bus_handle , & self -> panel_io_config , & self -> panel_io_handle .panel_io );
163
+ mp_lcd_err_t ret = esp_lcd_new_panel_io_spi (self -> bus_handle , & self -> panel_io_config , & self -> panel_io_handle .panel_io );
166
164
if (ret != ESP_OK ) {
167
165
mp_raise_msg_varg (& mp_type_ValueError , MP_ERROR_TEXT ("%d(esp_lcd_new_panel_io_spi)" ), ret );
168
166
}
@@ -179,13 +177,14 @@ mp_lcd_err_t spi_get_lane_count(mp_obj_t obj, uint8_t *lane_count)
179
177
180
178
if (self -> panel_io_config .flags .sio_mode ) {
181
179
* lane_count = 2 ;
182
- }
183
- if (self -> bus_config .quadwp_io_num != -1 ) {
184
- * lane_count = 4 ;
180
+ } else if (self -> spi_bus -> octal_mode ) {
181
+ * lane_count = 8 ;
182
+ } else {
183
+ * lane_count = 0 ;
185
184
}
186
185
187
186
#if CONFIG_LCD_ENABLE_DEBUG_LOG
188
- printf ("spi_get_lane_count(self) -> %d \n" , * lane_count );
187
+ printf ("spi_get_lane_count(self) -> %i \n" , ( uint8_t )( * lane_count ) );
189
188
#endif
190
189
191
190
return LCD_OK ;
@@ -197,7 +196,7 @@ mp_obj_t mp_spi_bus_get_host(mp_obj_t obj)
197
196
mp_lcd_spi_bus_obj_t * self = (mp_lcd_spi_bus_obj_t * )obj ;
198
197
199
198
#if CONFIG_LCD_ENABLE_DEBUG_LOG
200
- printf ("mp_spi_bus_get_host(self) -> %d \n" , (uint8_t )self -> spi_bus -> host );
199
+ printf ("mp_spi_bus_get_host(self) -> %i \n" , (uint8_t )self -> spi_bus -> host );
201
200
#endif
202
201
203
202
return mp_obj_new_int ((uint8_t )self -> spi_bus -> host );
0 commit comments