Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite893d2d

Browse files
committed
Updates bus drivers
1 parenta9f26c1 commite893d2d

File tree

3 files changed

+51
-25
lines changed

3 files changed

+51
-25
lines changed

‎ext_mod/lcd_bus/common_src/spi_bus.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@
136136
#endif
137137
}
138138

139-
spi_args[0]=MP_OBJ_NEW_SMALL_INT(args[ARG_host].u_int);
140-
spi_args[1]=MP_OBJ_NEW_SMALL_INT(args[ARG_freq].u_int);
139+
spi_args[0]=mp_obj_new_int_from_uint(args[ARG_host].u_int);
140+
spi_args[1]=mp_obj_new_int_from_uint(args[ARG_freq].u_int);
141141
spi_args[2]=MP_ROM_QSTR(MP_QSTR_firstbit);
142-
spi_args[3]=MP_OBJ_NEW_SMALL_INT(firstbit);
142+
spi_args[3]=mp_obj_new_int_from_uint(firstbit);
143143
spi_args[4]=MP_ROM_QSTR(MP_QSTR_sck);
144144
spi_args[5]=MP_OBJ_FROM_PTR(mp_hal_get_pin_obj(args[ARG_sclk].u_obj));
145145
spi_args[6]=MP_ROM_QSTR(MP_QSTR_mosi);
@@ -199,7 +199,8 @@
199199
mp_lcd_err_ts_spi_init(mp_obj_tobj,uint16_twidth,uint16_theight,uint8_tbpp,uint32_tbuffer_size,boolrgb565_byte_swap)
200200
{
201201
LCD_UNUSED(rgb565_byte_swap);
202-
mp_lcd_spi_bus_obj_t*self= (mp_lcd_spi_bus_obj_t*)obj;
202+
203+
mp_lcd_spi_bus_obj_t*self=MP_OBJ_TO_PTR(obj);
203204

204205
if (self->panel_io_config.lcd_cmd_bits==16) {
205206
self->send_cmd=send_cmd_16;
@@ -227,12 +228,11 @@
227228

228229
mp_lcd_err_ts_spi_rx_param(mp_obj_tobj,intlcd_cmd,void*param,size_tparam_size)
229230
{
230-
mp_lcd_spi_bus_obj_t*self=(mp_lcd_spi_bus_obj_t*)obj;
231+
mp_lcd_spi_bus_obj_t*self=MP_OBJ_TO_PTR(obj);
231232

232233
CS_ON();
233234

234235
self->send_cmd(self,lcd_cmd);
235-
236236
self->panel_io_config.spi_transfer(
237237
self->bus_handle,param_size,NULL, (uint8_t*)param);
238238

@@ -244,7 +244,7 @@
244244

245245
mp_lcd_err_ts_spi_tx_param(mp_obj_tobj,intlcd_cmd,void*param,size_tparam_size)
246246
{
247-
mp_lcd_spi_bus_obj_t*self=(mp_lcd_spi_bus_obj_t*)obj;
247+
mp_lcd_spi_bus_obj_t*self=MP_OBJ_TO_PTR(obj);
248248

249249
CS_ON();
250250
self->send_cmd(self,lcd_cmd);
@@ -264,7 +264,8 @@
264264
LCD_UNUSED(y_start);
265265
LCD_UNUSED(x_end);
266266
LCD_UNUSED(y_end);
267-
mp_lcd_spi_bus_obj_t*self= (mp_lcd_spi_bus_obj_t*)obj;
267+
268+
mp_lcd_spi_bus_obj_t*self=MP_OBJ_TO_PTR(obj);
268269

269270
CS_ON();
270271
if (lcd_cmd >=0x00) {

‎ext_mod/lcd_bus/esp32_include/rgb_bus.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#include"esp_lcd_panel_io.h"
1313
#include"esp_lcd_panel_rgb.h"
1414

15+
#include"freertos/FreeRTOS.h"
16+
#include"freertos/task.h"
17+
#include"freertos/semphr.h"
18+
1519
// micropython includes
1620
#include"mphalport.h"
1721
#include"py/obj.h"
@@ -39,6 +43,8 @@
3943
uint32_tbuffer_size;
4044
mp_obj_array_t*view1;
4145
mp_obj_array_t*view2;
46+
SemaphoreHandle_tsem_vsync_end;
47+
SemaphoreHandle_tsem_gui_ready;
4248
}mp_lcd_rgb_bus_obj_t;
4349

4450

‎ext_mod/lcd_bus/esp32_src/rgb_bus.c‎

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
#include"esp_lcd_panel_interface.h"
1919
#include"esp_lcd_panel_rgb.h"
2020

21+
#include"freertos/FreeRTOS.h"
22+
#include"freertos/task.h"
23+
#include"freertos/semphr.h"
24+
2125
// micropython includes
2226
#include"mphalport.h"
2327
#include"py/obj.h"
@@ -46,17 +50,8 @@
4650
uint8_t*fbs[3];// Frame buffers
4751
}rgb_panel_t;
4852

49-
boolrgb_bus_trans_done_cb(esp_lcd_panel_handle_tpanel_io,constesp_lcd_rgb_panel_event_data_t*edata,void*user_ctx)
50-
{
51-
mp_lcd_rgb_bus_obj_t*self= (mp_lcd_rgb_bus_obj_t*)user_ctx;
52-
53-
if (self->callback!=mp_const_none&&mp_obj_is_callable(self->callback)) {
54-
cb_isr(self->callback);
55-
}
56-
self->trans_done= true;
57-
return false;
58-
}
5953

54+
staticboolrgb_bus_trans_done_cb(esp_lcd_panel_handle_tpanel,constesp_lcd_rgb_panel_event_data_t*event_data,void*user_data)
6055
esp_lcd_rgb_panel_event_callbacks_tcallbacks= { .on_vsync=rgb_bus_trans_done_cb };
6156

6257
mp_lcd_err_trgb_del(mp_obj_tobj);
@@ -219,6 +214,11 @@
219214
self->panel_io_handle.free_framebuffer=&rgb_free_framebuffer;
220215
self->panel_io_handle.init=&rgb_init;
221216

217+
self->sem_vsync_end=xSemaphoreCreateBinary();
218+
assert(self->sem_vsync_end);
219+
self->sem_gui_ready=xSemaphoreCreateBinary();
220+
assert(self->sem_gui_ready);
221+
222222
returnMP_OBJ_FROM_PTR(self);
223223
}
224224

@@ -447,6 +447,11 @@
447447
{
448448
mp_lcd_rgb_bus_obj_t*self= (mp_lcd_rgb_bus_obj_t*)obj;
449449

450+
if (self->panel_io_config.flags.double_fb) {
451+
xSemaphoreGive(self->sem_gui_ready);
452+
xSemaphoreTake(self->sem_vsync_end,portMAX_DELAY);
453+
}
454+
450455
esp_err_tret=esp_lcd_panel_draw_bitmap(
451456
self->panel_handle,
452457
x_start,
@@ -467,18 +472,32 @@
467472
}
468473
*/
469474

470-
if (!self->panel_io_config.flags.double_fb) {
471-
if (self->callback!=mp_const_none&&mp_obj_is_callable(self->callback)) {
472-
mp_call_function_n_kw(self->callback,0,0,NULL);
473-
}
474-
}elseif (self->callback==mp_const_none) {
475-
while (!self->trans_done) {}
476-
self->trans_done= false;
475+
if (self->callback!=mp_const_none&&mp_obj_is_callable(self->callback)) {
476+
mp_call_function_n_kw(self->callback,0,0,NULL);
477477
}
478478

479479
returnLCD_OK;
480480
}
481481

482+
483+
boolrgb_bus_trans_done_cb(esp_lcd_panel_handle_tpanel,constesp_lcd_rgb_panel_event_data_t*event_data,void*user_data)
484+
{
485+
mp_lcd_rgb_bus_obj_t*self= (mp_lcd_rgb_bus_obj_t*)user_data;
486+
487+
LCD_UNUSED(event_data);
488+
LCD_UNUSED(panel);
489+
490+
if (self->panel_io_config.flags.double_fb) {
491+
BaseType_thigh_task_awoken=pdFALSE;
492+
if (xSemaphoreTakeFromISR(self->sem_gui_ready,&high_task_awoken)==pdTRUE) {
493+
xSemaphoreGiveFromISR(self->sem_vsync_end,&high_task_awoken);
494+
}
495+
returnhigh_task_awoken==pdTRUE;
496+
}
497+
return false;
498+
}
499+
500+
482501
MP_DEFINE_CONST_OBJ_TYPE(
483502
mp_lcd_rgb_bus_type,
484503
MP_QSTR_RGBBus,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp