@@ -144,6 +144,44 @@ static inline void fill_disp_buf_color(size_t opt_loop, color_t original, uint32
144144
145145#define  min (A , B ) ((A) < (B) ? (A) : (B))
146146
147+ #if  defined(CONFIG_DISPLAY_TOUCHSCREEN )
148+ #define  TOUCH_BUTTON_WIDTH  40
149+ #define  TOUCH_BUTTON_HEIGHT  40
150+ #define  TOUCH_BUTTON_MARGIN  5
151+ 
152+ static  void  display_draw_touch_buttons (void )
153+ {
154+     /* The TwatchS3 and core s3 don't have buttons that can be used (just power and 
155+        reset) 
156+        but it has a touch panel, we use the bottom 40 pixels worth of height 
157+        to display 3 buttons (prev, OK, next), we handle this here rather than 
158+        in display_hw because we want to draw text inside the virtual buttons */ 
159+ 
160+     /* blank the bottom of the display with black */ 
161+     uint16_t  line [CONFIG_DISPLAY_WIDTH ] =  { TFT_BLACK  };
162+     for  (int16_t  i  =  0 ; i  <  TOUCH_BUTTON_HEIGHT ; ++ i ) {
163+         draw_bitmap (CONFIG_DISPLAY_OFFSET_X , CONFIG_DISPLAY_HEIGHT  +  i  +  CONFIG_DISPLAY_OFFSET_Y ,
164+             CONFIG_DISPLAY_WIDTH  +  CONFIG_DISPLAY_OFFSET_X , 1 , line );
165+     }
166+ 
167+     dispWin_t  disp_win_virtual_buttons  =  { .x1  =  TOUCH_BUTTON_MARGIN  +  CONFIG_DISPLAY_OFFSET_X ,
168+         .y1  =  CONFIG_DISPLAY_HEIGHT  +  TOUCH_BUTTON_MARGIN  +  CONFIG_DISPLAY_OFFSET_Y ,
169+         .x2  =  TOUCH_BUTTON_WIDTH  +  CONFIG_DISPLAY_OFFSET_X ,
170+         .y2  =  (CONFIG_DISPLAY_HEIGHT  +  (TOUCH_BUTTON_HEIGHT  -  TOUCH_BUTTON_MARGIN )) +  CONFIG_DISPLAY_OFFSET_Y  };
171+ 
172+     display_set_font (JADE_SYMBOLS_16x16_FONT , NULL );
173+     display_print_in_area ("H" , CENTER , CENTER , disp_win_virtual_buttons , 0 );
174+     disp_win_virtual_buttons .x1  =  ((CONFIG_DISPLAY_WIDTH  / 2 ) +  CONFIG_DISPLAY_OFFSET_X ) -  (TOUCH_BUTTON_WIDTH  / 2 );
175+     disp_win_virtual_buttons .x2  =  ((CONFIG_DISPLAY_WIDTH  / 2 ) +  CONFIG_DISPLAY_OFFSET_X ) +  (TOUCH_BUTTON_WIDTH  / 2 );
176+     display_print_in_area ("J" , CENTER , CENTER , disp_win_virtual_buttons , 0 );
177+     disp_win_virtual_buttons .x1 
178+         =  ((CONFIG_DISPLAY_WIDTH  -  TOUCH_BUTTON_MARGIN ) +  CONFIG_DISPLAY_OFFSET_X ) -  TOUCH_BUTTON_WIDTH ;
179+     disp_win_virtual_buttons .x2  =  (CONFIG_DISPLAY_WIDTH  -  TOUCH_BUTTON_MARGIN ) +  CONFIG_DISPLAY_OFFSET_X ;
180+     display_print_in_area ("I" , CENTER , CENTER , disp_win_virtual_buttons , 0 );
181+     display_set_font (DEFAULT_FONT , NULL );
182+ }
183+ #endif 
184+ 
147185void  display_fill_rect (int  x , int  y , int  w , int  h , color_t  color )
148186{
149187    if  ((x  >= GUI_DISPLAY_WINDOW .x2 ) ||  (y  >  GUI_DISPLAY_WINDOW .y2 )) {
@@ -183,8 +221,7 @@ void display_fill_rect(int x, int y, int w, int h, color_t color)
183221        ||  ((y  -  CONFIG_DISPLAY_OFFSET_Y ) +  h  >  CONFIG_DISPLAY_HEIGHT )) {
184222        JADE_LOGE (
185223            "display_fill_rect called with bad params (ignored) x %d y %d w %d h %d color %u\n" , x , y , w , h , color );
186- #if  !defined(CONFIG_BOARD_TYPE_M5_CORES3 ) &&  !defined(CONFIG_BOARD_TYPE_TTGO_TWATCHS3 )                                 \
187-     &&  !defined(CONFIG_BOARD_TYPE_WS_TOUCH_LCD2 )
224+ #if  !defined(CONFIG_DISPLAY_TOUCHSCREEN )
188225        return ;
189226#endif 
190227    }
@@ -245,43 +282,8 @@ void display_init(TaskHandle_t* gui_h)
245282    JADE_ASSERT (gui_h );
246283    display_hw_init (gui_h );
247284
248- #if  defined(CONFIG_BOARD_TYPE_TTGO_TWATCHS3 ) ||  defined(CONFIG_BOARD_TYPE_M5_CORES3 )                                   \
249-     ||  defined(CONFIG_BOARD_TYPE_WS_TOUCH_LCD2 )
250- #define  TOUCH_BUTTON_AREA  40
251- #define  TOUCH_BUTTON_MARGIN  5
252- #define  TOUCH_BUTTON_WIDTH  40
253-     /* The TwatchS3 and core s3 don't have buttons that can be used (just power and 
254-        reset) 
255-        but it has a touch panel, we use the bottom 40 pixels worth of height 
256-        to display 3 buttons (prev, OK, next), we handle this here rather than 
257-        in display_hw because we want to draw text inside the virtual buttons */ 
258- 
259-     vTaskDelay (50  / portTICK_PERIOD_MS );
260- 
261-     /* blank the bottom of the display with black */ 
262-     uint16_t  line [CONFIG_DISPLAY_WIDTH ] =  { TFT_BLACK  };
263-     for  (int16_t  i  =  0 ; i  <  TOUCH_BUTTON_AREA ; ++ i ) {
264-         draw_bitmap (CONFIG_DISPLAY_OFFSET_X , CONFIG_DISPLAY_HEIGHT  +  i  +  CONFIG_DISPLAY_OFFSET_Y ,
265-             CONFIG_DISPLAY_WIDTH  +  CONFIG_DISPLAY_OFFSET_X , 1 , line );
266-     }
267- 
268-     dispWin_t  disp_win_virtual_buttons  =  { .x1  =  TOUCH_BUTTON_MARGIN  +  CONFIG_DISPLAY_OFFSET_X ,
269-         .y1  =  CONFIG_DISPLAY_HEIGHT  +  TOUCH_BUTTON_MARGIN  +  CONFIG_DISPLAY_OFFSET_Y ,
270-         .x2  =  TOUCH_BUTTON_WIDTH  +  CONFIG_DISPLAY_OFFSET_X ,
271-         .y2  =  (CONFIG_DISPLAY_HEIGHT  +  (TOUCH_BUTTON_AREA  -  TOUCH_BUTTON_MARGIN )) +  CONFIG_DISPLAY_OFFSET_Y  };
272- 
273-     display_set_font (JADE_SYMBOLS_16x16_FONT , NULL );
274-     display_print_in_area ("H" , CENTER , CENTER , disp_win_virtual_buttons , 0 );
275-     disp_win_virtual_buttons .x1  =  ((CONFIG_DISPLAY_WIDTH  / 2 ) +  CONFIG_DISPLAY_OFFSET_X ) -  (TOUCH_BUTTON_WIDTH  / 2 );
276-     disp_win_virtual_buttons .x2  =  ((CONFIG_DISPLAY_WIDTH  / 2 ) +  CONFIG_DISPLAY_OFFSET_X ) +  (TOUCH_BUTTON_WIDTH  / 2 );
277-     display_print_in_area ("J" , CENTER , CENTER , disp_win_virtual_buttons , 0 );
278-     disp_win_virtual_buttons .x1 
279-         =  ((CONFIG_DISPLAY_WIDTH  -  TOUCH_BUTTON_MARGIN ) +  CONFIG_DISPLAY_OFFSET_X ) -  TOUCH_BUTTON_WIDTH ;
280-     disp_win_virtual_buttons .x2  =  (CONFIG_DISPLAY_WIDTH  -  TOUCH_BUTTON_MARGIN ) +  CONFIG_DISPLAY_OFFSET_X ;
281-     display_print_in_area ("I" , CENTER , CENTER , disp_win_virtual_buttons , 0 );
282-     display_set_font (DEFAULT_FONT , NULL );
283- 
284-     vTaskDelay (50  / portTICK_PERIOD_MS );
285+ #if  defined(CONFIG_DISPLAY_TOUCHSCREEN )
286+     display_draw_touch_buttons ();
285287#endif 
286288#endif 
287289
@@ -296,7 +298,13 @@ void display_init(TaskHandle_t* gui_h)
296298bool  display_flip_orientation (const  bool  flipped_orientation )
297299{
298300#ifndef  CONFIG_ETH_USE_OPENETH 
299-     return  display_hw_flip_orientation (flipped_orientation );
301+     display_hw_flip_orientation (flipped_orientation );
302+ 
303+ #if  defined(CONFIG_DISPLAY_TOUCHSCREEN )
304+     display_draw_touch_buttons ();
305+ #endif 
306+ 
307+     return  flipped_orientation ;
300308#else 
301309    // Not supported for qemu 
302310    return  false;
0 commit comments