|
24 | 24 | mp_lcd_sdl_bus_obj_t*instances[10]= {NULL }; |
25 | 25 |
|
26 | 26 | uint8_tinstance_count=0; |
27 | | -boolexit_thread= false; |
28 | 27 | boolsdl_inited= false; |
29 | 28 |
|
30 | 29 | mp_lcd_err_tsdl_tx_param(mp_obj_tobj,intlcd_cmd,void*param,size_tparam_size); |
|
112 | 111 | LCD_UNUSED(color_size); |
113 | 112 |
|
114 | 113 | mp_lcd_sdl_bus_obj_t*self=MP_OBJ_TO_PTR(obj); |
115 | | -while (!self->trans_done) {} |
116 | | -self->trans_done= false; |
117 | | -self->panel_io_config.buf_to_flush=color; |
118 | | -SDL_UnlockMutex(self->panel_io_config.mutex); |
| 114 | + |
| 115 | +intpitch=self->panel_io_config.width*self->panel_io_config.bytes_per_pixel; |
| 116 | + |
| 117 | +SDL_UpdateTexture(self->texture,NULL,color,pitch); |
| 118 | +SDL_RenderClear(self->renderer); |
| 119 | +SDL_RenderCopy(self->renderer,self->texture,NULL,NULL); |
| 120 | +SDL_RenderPresent(self->renderer); |
119 | 121 |
|
120 | 122 | if (self->callback!=mp_const_none&&mp_obj_is_callable(self->callback)) { |
121 | 123 | mp_call_function_n_kw(self->callback,0,0,NULL); |
|
128 | 130 | { |
129 | 131 | mp_lcd_sdl_bus_obj_t*self=MP_OBJ_TO_PTR(obj); |
130 | 132 |
|
131 | | -self->panel_io_config.buf_to_flush=NULL; |
132 | | -self->panel_io_config.exit_thread= true; |
133 | | -SDL_UnlockMutex(self->panel_io_config.mutex); |
134 | | -SDL_WaitThread(self->panel_io_config.thread,NULL); |
135 | | - |
136 | 133 | SDL_DestroyTexture(self->texture); |
137 | 134 | SDL_DestroyRenderer(self->renderer); |
138 | 135 | SDL_DestroyWindow(self->window); |
139 | | -SDL_DestroyMutex(self->panel_io_config.mutex); |
140 | 136 |
|
141 | 137 | uint8_ti=0; |
142 | 138 |
|
|
156 | 152 | } |
157 | 153 |
|
158 | 154 | if (instance_count==0) { |
159 | | -exit_thread= true; |
160 | 155 | SDL_Quit(); |
161 | 156 | } |
162 | 157 |
|
|
176 | 171 |
|
177 | 172 | SDL_StartTextInput(); |
178 | 173 |
|
179 | | -self->panel_io_config.mutex=SDL_CreateMutex(); |
180 | | -SDL_LockMutex(self->panel_io_config.mutex); |
181 | 174 | self->window=SDL_CreateWindow( |
182 | 175 | "LVGL MP\0", |
183 | 176 | SDL_WINDOWPOS_UNDEFINED, |
|
195 | 188 | SDL_SetWindowSize(self->window,width,height); |
196 | 189 |
|
197 | 190 | self->rgb565_byte_swap= false; |
198 | | -self->panel_io_config.thread=SDL_CreateThread(flush_thread,"LVGL_MP_RENDERER\0", (void*)self); |
199 | 191 | self->trans_done= true; |
200 | 192 |
|
201 | 193 | instance_count+=1; |
|
216 | 208 | returnLCD_OK; |
217 | 209 | } |
218 | 210 |
|
219 | | -intflush_thread(void*self_in) { |
220 | | -mp_lcd_sdl_bus_obj_t*self= (mp_lcd_sdl_bus_obj_t*)self_in; |
221 | | -void*buf; |
222 | | -intpitch; |
223 | | - |
224 | | -while (!self->panel_io_config.exit_thread) { |
225 | | -SDL_LockMutex(self->panel_io_config.mutex); |
226 | | - |
227 | | -if (self->panel_io_config.buf_to_flush!=NULL) { |
228 | | -pitch=self->panel_io_config.width*self->panel_io_config.bytes_per_pixel; |
229 | | -buf=self->panel_io_config.buf_to_flush; |
230 | | -SDL_UpdateTexture(self->texture,NULL,buf,pitch); |
231 | | -SDL_RenderClear(self->renderer); |
232 | | -SDL_RenderCopy(self->renderer,self->texture,NULL,NULL); |
233 | | -SDL_RenderPresent(self->renderer); |
234 | | - } |
235 | | - |
236 | | -self->trans_done= true; |
237 | | - } |
238 | | -return0; |
239 | | - } |
240 | | - |
241 | 211 | staticmp_obj_tmp_lcd_sdl_poll_events(mp_obj_tself_in) |
242 | 212 | { |
243 | 213 | LCD_UNUSED(self_in); |
|