Wakeup Light with touch user interface, anti-aliased Font, SD card access and RTC usage on STM32F746NG-DISCO board

Dependencies:   BSP_DISCO_F746NG_patch_fixed LCD_DISCO_F746NG TS_DISCO_F746NG FATFileSystem TinyJpgDec_interwork mbed-src

Committer:
the_sz
Date:
Tue Nov 10 22:39:50 2015 +0000
Revision:
6:aa51cc3b9f90
Parent:
5:13c70bcde7f6
Child:
7:dc29f6647486
alpha picture support

Who changed what in which revision?

UserRevisionLine numberNew contents of line
the_sz 2:80026d18fcf3 1 #include "WakeupLight.h"
the_sz 2:80026d18fcf3 2
the_sz 6:aa51cc3b9f90 3 #include "Images/ic_alarm_white_48dp_1x.h"
the_sz 6:aa51cc3b9f90 4 #include "Images/ic_navigate_before_white_24dp_1x.h"
the_sz 6:aa51cc3b9f90 5 #include "Images/ic_notifications_none_white_48dp_1x.h"
the_sz 6:aa51cc3b9f90 6 #include "Images/ic_query_builder_white_48dp_1x.h"
the_sz 6:aa51cc3b9f90 7
the_sz 3:ecf7f1f8d749 8 #define CLIENT_COLOR_BG ((uint32_t)0xFF000000)
the_sz 2:80026d18fcf3 9 #define CLIENT_COLOR_FG ((uint32_t)0xFFD0D0D0)
the_sz 2:80026d18fcf3 10
the_sz 2:80026d18fcf3 11 #define HEADER_HEIGHT 25
the_sz 2:80026d18fcf3 12 #define HEADER_COLOR_BG ((uint32_t)0xFF404040)
the_sz 2:80026d18fcf3 13 #define HEADER_COLOR_FG ((uint32_t)0xFFD3D3D3)
the_sz 2:80026d18fcf3 14
the_sz 2:80026d18fcf3 15 #define CLOCK_COLOR_BG ((uint32_t)0xFF000000)
the_sz 2:80026d18fcf3 16 #define CLOCK_COLOR_FG ((uint32_t)0xFF707070)
the_sz 2:80026d18fcf3 17
the_sz 5:13c70bcde7f6 18 #define BUTTON_WIDTH 100
the_sz 5:13c70bcde7f6 19 #define BUTTON_HEIGHT 60
the_sz 5:13c70bcde7f6 20 #define BUTTON_COLOR_BG ((uint32_t)0x00000000)
the_sz 5:13c70bcde7f6 21 #define BUTTON_COLOR_FG CLIENT_COLOR_FG
the_sz 5:13c70bcde7f6 22 #define BUTTON_COLOR_BG_START 0x0C2696
the_sz 5:13c70bcde7f6 23 #define BUTTON_COLOR_BG_END 0x07185E
the_sz 5:13c70bcde7f6 24
the_sz 2:80026d18fcf3 25 #define COLOR_BG ((uint32_t)0xFF000000)
the_sz 2:80026d18fcf3 26
the_sz 3:ecf7f1f8d749 27 #define MAX_BOXES_PER_LINE 3
the_sz 3:ecf7f1f8d749 28 #define BOX_SPACING 10
the_sz 3:ecf7f1f8d749 29 #define BOX_TEXT_SPACING 10
the_sz 5:13c70bcde7f6 30 #define BOX_COLOR_BG BUTTON_COLOR_BG
the_sz 3:ecf7f1f8d749 31 #define BOX_COLOR_FG CLIENT_COLOR_FG
the_sz 5:13c70bcde7f6 32 #define BOX_COLOR_BG_START BUTTON_COLOR_BG_START
the_sz 5:13c70bcde7f6 33 #define BOX_COLOR_BG_END BUTTON_COLOR_BG_END
the_sz 3:ecf7f1f8d749 34
the_sz 2:80026d18fcf3 35 LCD_DISCO_F746NG uiLcd;
the_sz 2:80026d18fcf3 36 TS_DISCO_F746NG uiTs;
the_sz 3:ecf7f1f8d749 37 uint16_t uiLastTouchX;
the_sz 3:ecf7f1f8d749 38 uint16_t uiLastTouchY;
the_sz 2:80026d18fcf3 39 UI_STRUCT *uiCurrent=NULL;
the_sz 3:ecf7f1f8d749 40 UI_STRUCT uiClock;
the_sz 3:ecf7f1f8d749 41 UI_STRUCT uiClockInWords;
the_sz 5:13c70bcde7f6 42 UI_STRUCT uiColorTest;
the_sz 3:ecf7f1f8d749 43 UI_STRUCT uiWakeup;
the_sz 3:ecf7f1f8d749 44 UI_STRUCT uiMain;
the_sz 3:ecf7f1f8d749 45 UI_BOX_LIST_ITEM_STRUCT uiMainItems[]=
the_sz 3:ecf7f1f8d749 46 {
the_sz 6:aa51cc3b9f90 47 { "Clock", ic_query_builder_white_48dp_1x }, { "Clock\nWith Words", ic_query_builder_white_48dp_1x }, { "Adjust\nTimers", ic_notifications_none_white_48dp_1x }, { "Lights On", NULL }, { "Lights Off", NULL }, { "Color Test", NULL }
the_sz 3:ecf7f1f8d749 48 };
the_sz 2:80026d18fcf3 49
the_sz 2:80026d18fcf3 50 //
the_sz 2:80026d18fcf3 51 // helper function
the_sz 2:80026d18fcf3 52 //
the_sz 2:80026d18fcf3 53 void UI_ShowClearClientRect(void)
the_sz 2:80026d18fcf3 54 {
the_sz 2:80026d18fcf3 55 uiLcd.SetTextColor(CLIENT_COLOR_BG);
the_sz 5:13c70bcde7f6 56 uiLcd.FillRect(0,HEADER_HEIGHT,uiLcd.GetXSize(),uiLcd.GetYSize()-HEADER_HEIGHT);
the_sz 2:80026d18fcf3 57 }
the_sz 2:80026d18fcf3 58
the_sz 3:ecf7f1f8d749 59 void UI_ShowDisplayText(int16_t x,int16_t y,char *text)
the_sz 3:ecf7f1f8d749 60 {
the_sz 3:ecf7f1f8d749 61 int16_t xStart;
the_sz 3:ecf7f1f8d749 62 int16_t charWidth;
the_sz 3:ecf7f1f8d749 63 int16_t charHeight;
the_sz 3:ecf7f1f8d749 64
the_sz 3:ecf7f1f8d749 65 xStart=x;
the_sz 3:ecf7f1f8d749 66 charHeight=uiLcd.GetFont()->Height+3;
the_sz 3:ecf7f1f8d749 67 charWidth=uiLcd.GetFont()->Width;
the_sz 3:ecf7f1f8d749 68
the_sz 3:ecf7f1f8d749 69 while ((*text)!='\0')
the_sz 3:ecf7f1f8d749 70 {
the_sz 3:ecf7f1f8d749 71 if ((*text)=='\n')
the_sz 3:ecf7f1f8d749 72 {
the_sz 3:ecf7f1f8d749 73 y+=charHeight;
the_sz 3:ecf7f1f8d749 74 x=xStart;
the_sz 3:ecf7f1f8d749 75 }
the_sz 3:ecf7f1f8d749 76 else
the_sz 3:ecf7f1f8d749 77 {
the_sz 3:ecf7f1f8d749 78 uiLcd.DisplayChar(x,y,*text);
the_sz 3:ecf7f1f8d749 79 x+=charWidth;
the_sz 3:ecf7f1f8d749 80 }
the_sz 3:ecf7f1f8d749 81
the_sz 3:ecf7f1f8d749 82 text++;
the_sz 3:ecf7f1f8d749 83 }
the_sz 3:ecf7f1f8d749 84 }
the_sz 5:13c70bcde7f6 85
the_sz 5:13c70bcde7f6 86 void UI_ShowDisplayTextCenter(int16_t x,int16_t y,int16_t width,int16_t height,char *text)
the_sz 5:13c70bcde7f6 87 {
the_sz 5:13c70bcde7f6 88 int16_t charWidth;
the_sz 5:13c70bcde7f6 89 int16_t charHeight;
the_sz 5:13c70bcde7f6 90
the_sz 5:13c70bcde7f6 91 charHeight=uiLcd.GetFont()->Height+3;
the_sz 5:13c70bcde7f6 92 charWidth=uiLcd.GetFont()->Width;
the_sz 5:13c70bcde7f6 93
the_sz 5:13c70bcde7f6 94 x+=((width-(strlen(text)*charWidth))/2);
the_sz 5:13c70bcde7f6 95 y+=((height-charHeight)/2);
the_sz 5:13c70bcde7f6 96
the_sz 5:13c70bcde7f6 97 while ((*text)!='\0')
the_sz 5:13c70bcde7f6 98 {
the_sz 5:13c70bcde7f6 99 uiLcd.DisplayChar(x,y,*text);
the_sz 5:13c70bcde7f6 100 x+=charWidth;
the_sz 5:13c70bcde7f6 101
the_sz 5:13c70bcde7f6 102 text++;
the_sz 5:13c70bcde7f6 103 }
the_sz 5:13c70bcde7f6 104 }
the_sz 5:13c70bcde7f6 105
the_sz 5:13c70bcde7f6 106 void UI_ShowDrawGradientButton(uint16_t x,uint16_t y,uint16_t width,uint16_t height,uint32_t colorStart,uint32_t colorEnd)
the_sz 5:13c70bcde7f6 107 {
the_sz 5:13c70bcde7f6 108 float deltaRed;
the_sz 5:13c70bcde7f6 109 float deltaGreen;
the_sz 5:13c70bcde7f6 110 float deltaBlue;
the_sz 5:13c70bcde7f6 111 float red;
the_sz 5:13c70bcde7f6 112 float green;
the_sz 5:13c70bcde7f6 113 float blue;
the_sz 5:13c70bcde7f6 114 uint16_t offset;
the_sz 5:13c70bcde7f6 115 uint32_t color;
the_sz 5:13c70bcde7f6 116
the_sz 5:13c70bcde7f6 117 deltaRed=(float)((int32_t)(colorEnd & 0xFF) - (int32_t)(colorStart & 0xFF))/height;
the_sz 5:13c70bcde7f6 118 deltaGreen=(float)((int32_t)((colorEnd >> 8) & 0xFF) - (int32_t)((colorStart >> 8)& 0xFF))/height;
the_sz 5:13c70bcde7f6 119 deltaBlue=(float)((int32_t)((colorEnd >> 16) & 0xFF) - (int32_t)((colorStart >> 16)& 0xFF))/height;
the_sz 5:13c70bcde7f6 120
the_sz 5:13c70bcde7f6 121 red=colorStart & 0xFF;
the_sz 5:13c70bcde7f6 122 green=((colorStart >> 8)& 0xFF);
the_sz 5:13c70bcde7f6 123 blue=((colorStart >> 16)& 0xFF);
the_sz 5:13c70bcde7f6 124
the_sz 5:13c70bcde7f6 125 for (offset=0;offset<height;offset++)
the_sz 5:13c70bcde7f6 126 {
the_sz 5:13c70bcde7f6 127 color=(uint8_t)red | (((uint8_t)green)<<8) | (((uint8_t)blue)<<16) | (((uint32_t)0xFF)<<24);
the_sz 5:13c70bcde7f6 128 uiLcd.SetTextColor(color);
the_sz 5:13c70bcde7f6 129
the_sz 5:13c70bcde7f6 130 if ((offset==0) || (offset==(height-1)))
the_sz 5:13c70bcde7f6 131 uiLcd.DrawHLine(x+1,y+offset,width-2);
the_sz 5:13c70bcde7f6 132 else
the_sz 5:13c70bcde7f6 133 uiLcd.DrawHLine(x,y+offset,width);
the_sz 5:13c70bcde7f6 134
the_sz 5:13c70bcde7f6 135 red+=deltaRed;
the_sz 5:13c70bcde7f6 136 green+=deltaGreen;
the_sz 5:13c70bcde7f6 137 blue+=deltaBlue;
the_sz 5:13c70bcde7f6 138 }
the_sz 5:13c70bcde7f6 139 }
the_sz 5:13c70bcde7f6 140
the_sz 5:13c70bcde7f6 141 void UI_ShowDrawButton(uint16_t x,uint16_t y,char *text)
the_sz 5:13c70bcde7f6 142 {
the_sz 5:13c70bcde7f6 143 // paint button background
the_sz 5:13c70bcde7f6 144 UI_ShowDrawGradientButton(x,y,BUTTON_WIDTH,BUTTON_HEIGHT,BUTTON_COLOR_BG_START,BUTTON_COLOR_BG_END);
the_sz 5:13c70bcde7f6 145
the_sz 5:13c70bcde7f6 146 // paint button text
the_sz 5:13c70bcde7f6 147 uiLcd.SetFont(&display_font_12x22);
the_sz 5:13c70bcde7f6 148 uiLcd.SetBackColor(BUTTON_COLOR_BG);
the_sz 5:13c70bcde7f6 149 uiLcd.SetTextColor(BUTTON_COLOR_FG);
the_sz 5:13c70bcde7f6 150
the_sz 5:13c70bcde7f6 151 UI_ShowDisplayTextCenter(x,y,BUTTON_WIDTH,BUTTON_HEIGHT,text);
the_sz 5:13c70bcde7f6 152 }
the_sz 5:13c70bcde7f6 153
the_sz 6:aa51cc3b9f90 154 void UI_DrawBitmapWithAlpha(uint32_t Xpos,uint32_t Ypos,uint8_t *pbmp)
the_sz 6:aa51cc3b9f90 155 {
the_sz 6:aa51cc3b9f90 156 uint32_t index = 0, width = 0, height = 0, bit_pixel = 0;
the_sz 6:aa51cc3b9f90 157 uint32_t x;
the_sz 6:aa51cc3b9f90 158 uint32_t part;
the_sz 6:aa51cc3b9f90 159 uint32_t color[3];
the_sz 6:aa51cc3b9f90 160 uint32_t value;
the_sz 6:aa51cc3b9f90 161
the_sz 6:aa51cc3b9f90 162 /* Get bitmap data address offset */
the_sz 6:aa51cc3b9f90 163 index = *(__IO uint16_t *) (pbmp + 10);
the_sz 6:aa51cc3b9f90 164 index |= (*(__IO uint16_t *) (pbmp + 12)) << 16;
the_sz 6:aa51cc3b9f90 165
the_sz 6:aa51cc3b9f90 166 /* Read bitmap width */
the_sz 6:aa51cc3b9f90 167 width = *(uint16_t *) (pbmp + 18);
the_sz 6:aa51cc3b9f90 168 width |= (*(uint16_t *) (pbmp + 20)) << 16;
the_sz 6:aa51cc3b9f90 169
the_sz 6:aa51cc3b9f90 170 /* Read bitmap height */
the_sz 6:aa51cc3b9f90 171 height = *(uint16_t *) (pbmp + 22);
the_sz 6:aa51cc3b9f90 172 height |= (*(uint16_t *) (pbmp + 24)) << 16;
the_sz 6:aa51cc3b9f90 173
the_sz 6:aa51cc3b9f90 174 /* Read bit/pixel */
the_sz 6:aa51cc3b9f90 175 bit_pixel = *(uint16_t *) (pbmp + 28);
the_sz 6:aa51cc3b9f90 176
the_sz 6:aa51cc3b9f90 177 /* Get the layer pixel format */
the_sz 6:aa51cc3b9f90 178 if ((bit_pixel/8) != 4)
the_sz 6:aa51cc3b9f90 179 {
the_sz 6:aa51cc3b9f90 180 DPrintf("UI_DrawBitmapWithAlpha: This is no alpha picture.\r\n");
the_sz 6:aa51cc3b9f90 181 return;
the_sz 6:aa51cc3b9f90 182 }
the_sz 6:aa51cc3b9f90 183
the_sz 6:aa51cc3b9f90 184 /* Bypass the bitmap header */
the_sz 6:aa51cc3b9f90 185 pbmp += (index + (width * (height - 1) * (bit_pixel/8)));
the_sz 6:aa51cc3b9f90 186
the_sz 6:aa51cc3b9f90 187 for(index=0; index < height; index++)
the_sz 6:aa51cc3b9f90 188 {
the_sz 6:aa51cc3b9f90 189 for (x=0;x<width;x++)
the_sz 6:aa51cc3b9f90 190 {
the_sz 6:aa51cc3b9f90 191 value=uiLcd.ReadPixel(Xpos+x,Ypos+index);
the_sz 6:aa51cc3b9f90 192
the_sz 6:aa51cc3b9f90 193 color[0]=value & 0xFF;
the_sz 6:aa51cc3b9f90 194 color[1]=(value >> 8) & 0xFF;
the_sz 6:aa51cc3b9f90 195 color[2]=(value >> 16) & 0xFF;
the_sz 6:aa51cc3b9f90 196
the_sz 6:aa51cc3b9f90 197 if (pbmp[3]>0)
the_sz 6:aa51cc3b9f90 198 {
the_sz 6:aa51cc3b9f90 199 // add red
the_sz 6:aa51cc3b9f90 200 part=(color[0]+(pbmp[0]*pbmp[3]/255));
the_sz 6:aa51cc3b9f90 201 if (part>255)
the_sz 6:aa51cc3b9f90 202 part=255;
the_sz 6:aa51cc3b9f90 203 color[0]=part;
the_sz 6:aa51cc3b9f90 204
the_sz 6:aa51cc3b9f90 205 // add green
the_sz 6:aa51cc3b9f90 206 part=(color[1]+(pbmp[1]*pbmp[3]/255));
the_sz 6:aa51cc3b9f90 207 if (part>255)
the_sz 6:aa51cc3b9f90 208 part=255;
the_sz 6:aa51cc3b9f90 209 color[1]=part;
the_sz 6:aa51cc3b9f90 210
the_sz 6:aa51cc3b9f90 211 // add blue
the_sz 6:aa51cc3b9f90 212 part=(color[2]+(pbmp[2]*pbmp[3]/255));
the_sz 6:aa51cc3b9f90 213 if (part>255)
the_sz 6:aa51cc3b9f90 214 part=255;
the_sz 6:aa51cc3b9f90 215 color[2]=part;
the_sz 6:aa51cc3b9f90 216
the_sz 6:aa51cc3b9f90 217 // draw pixel
the_sz 6:aa51cc3b9f90 218 uiLcd.DrawPixel(Xpos+x,Ypos+index,color[0] | (color[1] << 8) | (color[2] << 16) | ((uint32_t)0xFF << 24));
the_sz 6:aa51cc3b9f90 219 }
the_sz 6:aa51cc3b9f90 220
the_sz 6:aa51cc3b9f90 221 pbmp+=4;
the_sz 6:aa51cc3b9f90 222 }
the_sz 6:aa51cc3b9f90 223
the_sz 6:aa51cc3b9f90 224 /* Increment the source and destination buffers */
the_sz 6:aa51cc3b9f90 225 pbmp -= 2*(width*(bit_pixel/8));
the_sz 6:aa51cc3b9f90 226 }
the_sz 6:aa51cc3b9f90 227 }
the_sz 6:aa51cc3b9f90 228
the_sz 2:80026d18fcf3 229 //
the_sz 2:80026d18fcf3 230 // box list
the_sz 2:80026d18fcf3 231 //
the_sz 2:80026d18fcf3 232 void UI_ShowBoxList(bool initial)
the_sz 2:80026d18fcf3 233 {
the_sz 2:80026d18fcf3 234 if (initial==true)
the_sz 2:80026d18fcf3 235 {
the_sz 3:ecf7f1f8d749 236 int8_t lines;
the_sz 3:ecf7f1f8d749 237 int8_t columns;
the_sz 3:ecf7f1f8d749 238 int8_t box;
the_sz 3:ecf7f1f8d749 239 int16_t width;
the_sz 3:ecf7f1f8d749 240 int16_t height;
the_sz 3:ecf7f1f8d749 241 int16_t startX;
the_sz 3:ecf7f1f8d749 242 int16_t startY;
the_sz 3:ecf7f1f8d749 243
the_sz 2:80026d18fcf3 244 // fill background
the_sz 2:80026d18fcf3 245 UI_ShowClearClientRect();
the_sz 3:ecf7f1f8d749 246
the_sz 3:ecf7f1f8d749 247 // paint boxes
the_sz 3:ecf7f1f8d749 248 if (uiCurrent->data.boxList.count<=MAX_BOXES_PER_LINE)
the_sz 3:ecf7f1f8d749 249 lines=1;
the_sz 3:ecf7f1f8d749 250 else
the_sz 3:ecf7f1f8d749 251 lines=2;
the_sz 3:ecf7f1f8d749 252
the_sz 3:ecf7f1f8d749 253 columns=((uiCurrent->data.boxList.count + (lines-1)) / lines);
the_sz 3:ecf7f1f8d749 254
the_sz 3:ecf7f1f8d749 255 width=(uiLcd.GetXSize() - BOX_SPACING) / columns;
the_sz 3:ecf7f1f8d749 256 height=(uiLcd.GetYSize() - HEADER_HEIGHT - BOX_SPACING) / lines;
the_sz 3:ecf7f1f8d749 257
the_sz 3:ecf7f1f8d749 258 for (box=0;box<uiCurrent->data.boxList.count;box++)
the_sz 3:ecf7f1f8d749 259 {
the_sz 3:ecf7f1f8d749 260 startX=BOX_SPACING+(width*(box % columns));
the_sz 3:ecf7f1f8d749 261 startY=HEADER_HEIGHT+BOX_SPACING+(height*(box/columns));
the_sz 3:ecf7f1f8d749 262
the_sz 3:ecf7f1f8d749 263 // paint box background
the_sz 5:13c70bcde7f6 264 UI_ShowDrawGradientButton(startX,startY,width-BOX_SPACING,height-BOX_SPACING,BOX_COLOR_BG_START,BOX_COLOR_BG_END);
the_sz 5:13c70bcde7f6 265
the_sz 3:ecf7f1f8d749 266 // paint box text
the_sz 3:ecf7f1f8d749 267 uiLcd.SetFont(&display_font_12x22);
the_sz 3:ecf7f1f8d749 268 uiLcd.SetBackColor(BOX_COLOR_BG);
the_sz 3:ecf7f1f8d749 269 uiLcd.SetTextColor(BOX_COLOR_FG);
the_sz 3:ecf7f1f8d749 270 UI_ShowDisplayText(startX+BOX_TEXT_SPACING,startY+BOX_TEXT_SPACING,uiCurrent->data.boxList.items[box].name);
the_sz 6:aa51cc3b9f90 271
the_sz 6:aa51cc3b9f90 272 // draw icon
the_sz 6:aa51cc3b9f90 273 if (uiCurrent->data.boxList.items[box].image!=NULL)
the_sz 6:aa51cc3b9f90 274 UI_DrawBitmapWithAlpha(startX+width-BOX_SPACING-48,startY+height-BOX_SPACING-48,uiCurrent->data.boxList.items[box].image);
the_sz 6:aa51cc3b9f90 275 // uiLcd.DrawBitmap(0,0,uiCurrent->data.boxList.items[box].image);
the_sz 6:aa51cc3b9f90 276 // uiLcd.DrawBitmap(startX+width-BOX_SPACING-48,startY+height-BOX_SPACING-48,uiCurrent->data.boxList.items[box].image);
the_sz 3:ecf7f1f8d749 277 }
the_sz 5:13c70bcde7f6 278 }
the_sz 2:80026d18fcf3 279 }
the_sz 2:80026d18fcf3 280
the_sz 2:80026d18fcf3 281 void UI_ClickBoxList(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 282 {
the_sz 3:ecf7f1f8d749 283 int8_t lines;
the_sz 3:ecf7f1f8d749 284 int8_t columns;
the_sz 3:ecf7f1f8d749 285 int8_t box;
the_sz 3:ecf7f1f8d749 286 int16_t width;
the_sz 3:ecf7f1f8d749 287 int16_t height;
the_sz 3:ecf7f1f8d749 288 int16_t startX;
the_sz 3:ecf7f1f8d749 289 int16_t startY;
the_sz 3:ecf7f1f8d749 290
the_sz 3:ecf7f1f8d749 291 // detect at which box was clicked
the_sz 3:ecf7f1f8d749 292 if (uiCurrent->data.boxList.count<=MAX_BOXES_PER_LINE)
the_sz 3:ecf7f1f8d749 293 lines=1;
the_sz 3:ecf7f1f8d749 294 else
the_sz 3:ecf7f1f8d749 295 lines=2;
the_sz 3:ecf7f1f8d749 296
the_sz 3:ecf7f1f8d749 297 columns=((uiCurrent->data.boxList.count + (lines-1)) / lines);
the_sz 3:ecf7f1f8d749 298
the_sz 3:ecf7f1f8d749 299 width=(uiLcd.GetXSize() - BOX_SPACING) / columns;
the_sz 3:ecf7f1f8d749 300 height=(uiLcd.GetYSize() - HEADER_HEIGHT - BOX_SPACING) / lines;
the_sz 3:ecf7f1f8d749 301
the_sz 3:ecf7f1f8d749 302 for (box=0;box<uiCurrent->data.boxList.count;box++)
the_sz 3:ecf7f1f8d749 303 {
the_sz 3:ecf7f1f8d749 304 startX=BOX_SPACING+(width*(box % columns));
the_sz 3:ecf7f1f8d749 305 startY=HEADER_HEIGHT+BOX_SPACING+(height*(box/columns));
the_sz 3:ecf7f1f8d749 306
the_sz 3:ecf7f1f8d749 307 if ( (x>=startX) && (x<(startX+width-BOX_SPACING))
the_sz 3:ecf7f1f8d749 308 &&
the_sz 3:ecf7f1f8d749 309 (y>=startY) && (y<(startY+height-BOX_SPACING))
the_sz 3:ecf7f1f8d749 310 )
the_sz 3:ecf7f1f8d749 311 {
the_sz 3:ecf7f1f8d749 312 uiCurrent->handler(UR_CLICK,box,uiCurrent);
the_sz 3:ecf7f1f8d749 313 break;
the_sz 3:ecf7f1f8d749 314 }
the_sz 3:ecf7f1f8d749 315 }
the_sz 2:80026d18fcf3 316 }
the_sz 2:80026d18fcf3 317
the_sz 2:80026d18fcf3 318 //
the_sz 2:80026d18fcf3 319 // message box
the_sz 2:80026d18fcf3 320 //
the_sz 2:80026d18fcf3 321 void UI_ShowMessageBox(bool initial)
the_sz 2:80026d18fcf3 322 {
the_sz 2:80026d18fcf3 323 if (initial==true)
the_sz 2:80026d18fcf3 324 {
the_sz 2:80026d18fcf3 325 // fill background
the_sz 2:80026d18fcf3 326 UI_ShowClearClientRect();
the_sz 2:80026d18fcf3 327 }
the_sz 2:80026d18fcf3 328 }
the_sz 2:80026d18fcf3 329
the_sz 2:80026d18fcf3 330 void UI_ClickMessageBox(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 331 {
the_sz 3:ecf7f1f8d749 332 uint32_t index;
the_sz 3:ecf7f1f8d749 333
the_sz 2:80026d18fcf3 334 // detect at which button was clicked
the_sz 3:ecf7f1f8d749 335 index=0;
the_sz 3:ecf7f1f8d749 336
the_sz 3:ecf7f1f8d749 337 uiCurrent->handler(UR_CLICK,index,uiCurrent);
the_sz 2:80026d18fcf3 338 }
the_sz 2:80026d18fcf3 339
the_sz 2:80026d18fcf3 340 //
the_sz 2:80026d18fcf3 341 // clock
the_sz 2:80026d18fcf3 342 //
the_sz 2:80026d18fcf3 343 void UI_ShowClock(bool initial)
the_sz 2:80026d18fcf3 344 {
the_sz 2:80026d18fcf3 345 char buffer[100];
the_sz 3:ecf7f1f8d749 346 struct tm *tmStruct;
the_sz 3:ecf7f1f8d749 347 time_t timeValue;
the_sz 2:80026d18fcf3 348
the_sz 2:80026d18fcf3 349 if (initial==true)
the_sz 2:80026d18fcf3 350 {
the_sz 2:80026d18fcf3 351 // fill background
the_sz 2:80026d18fcf3 352 uiLcd.SetTextColor(CLOCK_COLOR_BG);
the_sz 5:13c70bcde7f6 353 uiLcd.FillRect(0,0,uiLcd.GetXSize(),uiLcd.GetYSize());
the_sz 2:80026d18fcf3 354 }
the_sz 2:80026d18fcf3 355
the_sz 2:80026d18fcf3 356 // show clock
the_sz 2:80026d18fcf3 357 uiLcd.SetFont(&display_font_12x22);
the_sz 2:80026d18fcf3 358 uiLcd.SetBackColor(CLOCK_COLOR_BG);
the_sz 2:80026d18fcf3 359 uiLcd.SetTextColor(CLOCK_COLOR_FG);
the_sz 3:ecf7f1f8d749 360 timeValue=time(NULL);
the_sz 3:ecf7f1f8d749 361 tmStruct=localtime(&timeValue);
the_sz 3:ecf7f1f8d749 362 snprintf(buffer,sizeof(buffer),"%u:%02u:%02u",tmStruct->tm_hour,tmStruct->tm_min,tmStruct->tm_sec);
the_sz 2:80026d18fcf3 363 uiLcd.DisplayStringAt(0,100,(uint8_t *)buffer,CENTER_MODE);
the_sz 2:80026d18fcf3 364 }
the_sz 2:80026d18fcf3 365
the_sz 2:80026d18fcf3 366 void UI_ClickClock(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 367 {
the_sz 2:80026d18fcf3 368 // exit view
the_sz 3:ecf7f1f8d749 369 UI_Show(&uiMain);
the_sz 2:80026d18fcf3 370 }
the_sz 2:80026d18fcf3 371
the_sz 2:80026d18fcf3 372 //
the_sz 2:80026d18fcf3 373 // clock in words
the_sz 2:80026d18fcf3 374 //
the_sz 2:80026d18fcf3 375 void UI_ShowClockInWords(bool initial)
the_sz 2:80026d18fcf3 376 {
the_sz 2:80026d18fcf3 377 if (initial==true)
the_sz 2:80026d18fcf3 378 {
the_sz 2:80026d18fcf3 379 // fill background
the_sz 2:80026d18fcf3 380 UI_ShowClearClientRect();
the_sz 2:80026d18fcf3 381 }
the_sz 2:80026d18fcf3 382
the_sz 2:80026d18fcf3 383 // show clock in words
the_sz 2:80026d18fcf3 384 uiLcd.SetFont(&display_font_12x22);
the_sz 2:80026d18fcf3 385 uiLcd.SetBackColor(CLIENT_COLOR_BG);
the_sz 2:80026d18fcf3 386 uiLcd.SetTextColor(CLIENT_COLOR_FG);
the_sz 2:80026d18fcf3 387 uiLcd.DisplayStringAt(5,30,(uint8_t *)"UM F\x9ANF ZEHN VIERTEL HALB",LEFT_MODE);
the_sz 2:80026d18fcf3 388 uiLcd.DisplayStringAt(5,60,(uint8_t *)"NACH VOR",LEFT_MODE);
the_sz 2:80026d18fcf3 389 uiLcd.DisplayStringAt(5,90,(uint8_t *)"EINS ZWEI DREI VIER",LEFT_MODE);
the_sz 2:80026d18fcf3 390 uiLcd.DisplayStringAt(5,120,(uint8_t *)"F\x9ANF SECHS SIEBEN ACHT",LEFT_MODE);
the_sz 2:80026d18fcf3 391 uiLcd.DisplayStringAt(5,150,(uint8_t *)"NEUN ZEHN ELF ZW\x99LF",LEFT_MODE);
the_sz 2:80026d18fcf3 392
the_sz 2:80026d18fcf3 393 // draw charset
the_sz 2:80026d18fcf3 394 /*
the_sz 2:80026d18fcf3 395 int x;
the_sz 2:80026d18fcf3 396 for (x=0x80;x<=0xFF;x++)
the_sz 2:80026d18fcf3 397 {
the_sz 2:80026d18fcf3 398 uiLcd.DisplayChar(1+(((x-0x80) % 16)*14),30+(((x-0x80)/16)*20),x);
the_sz 2:80026d18fcf3 399 }
the_sz 2:80026d18fcf3 400 */
the_sz 2:80026d18fcf3 401 }
the_sz 2:80026d18fcf3 402
the_sz 2:80026d18fcf3 403 void UI_ClickClockInWords(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 404 {
the_sz 2:80026d18fcf3 405 // exit view
the_sz 3:ecf7f1f8d749 406 UI_Show(&uiMain);
the_sz 2:80026d18fcf3 407 }
the_sz 2:80026d18fcf3 408
the_sz 2:80026d18fcf3 409 //
the_sz 5:13c70bcde7f6 410 // value adjust
the_sz 2:80026d18fcf3 411 //
the_sz 5:13c70bcde7f6 412 void UI_ShowValueAdjust(bool initial)
the_sz 2:80026d18fcf3 413 {
the_sz 5:13c70bcde7f6 414 char buffer[20];
the_sz 5:13c70bcde7f6 415
the_sz 2:80026d18fcf3 416 if (initial==true)
the_sz 2:80026d18fcf3 417 {
the_sz 2:80026d18fcf3 418 // fill background
the_sz 2:80026d18fcf3 419 UI_ShowClearClientRect();
the_sz 5:13c70bcde7f6 420
the_sz 5:13c70bcde7f6 421 if (uiCurrent->data.valueAdjust.count==4)
the_sz 5:13c70bcde7f6 422 {
the_sz 5:13c70bcde7f6 423 UI_ShowDrawButton(17+(0*(BUTTON_WIDTH+15)),40,"+");
the_sz 5:13c70bcde7f6 424 UI_ShowDrawButton(17+(1*(BUTTON_WIDTH+15)),40,"+");
the_sz 5:13c70bcde7f6 425 UI_ShowDrawButton(17+(2*(BUTTON_WIDTH+15)),40,"+");
the_sz 5:13c70bcde7f6 426 UI_ShowDrawButton(17+(3*(BUTTON_WIDTH+15)),40,"+");
the_sz 5:13c70bcde7f6 427
the_sz 5:13c70bcde7f6 428 UI_ShowDrawButton(17+(0*(BUTTON_WIDTH+15)),205,"-");
the_sz 5:13c70bcde7f6 429 UI_ShowDrawButton(17+(1*(BUTTON_WIDTH+15)),205,"-");
the_sz 5:13c70bcde7f6 430 UI_ShowDrawButton(17+(2*(BUTTON_WIDTH+15)),205,"-");
the_sz 5:13c70bcde7f6 431 UI_ShowDrawButton(17+(3*(BUTTON_WIDTH+15)),205,"-");
the_sz 5:13c70bcde7f6 432 }
the_sz 5:13c70bcde7f6 433 }
the_sz 5:13c70bcde7f6 434
the_sz 5:13c70bcde7f6 435 uiLcd.SetBackColor(CLIENT_COLOR_BG);
the_sz 5:13c70bcde7f6 436 uiLcd.SetTextColor(CLIENT_COLOR_FG);
the_sz 5:13c70bcde7f6 437
the_sz 5:13c70bcde7f6 438 if (uiCurrent->data.valueAdjust.count==4)
the_sz 5:13c70bcde7f6 439 {
the_sz 5:13c70bcde7f6 440 snprintf(buffer,sizeof(buffer),"0x%02X",uiCurrent->data.valueAdjust.values[0]);
the_sz 5:13c70bcde7f6 441 UI_ShowDisplayTextCenter(17+(0*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 5:13c70bcde7f6 442
the_sz 5:13c70bcde7f6 443 snprintf(buffer,sizeof(buffer),"0x%02X",uiCurrent->data.valueAdjust.values[1]);
the_sz 5:13c70bcde7f6 444 UI_ShowDisplayTextCenter(17+(1*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 5:13c70bcde7f6 445
the_sz 5:13c70bcde7f6 446 snprintf(buffer,sizeof(buffer),"0x%02X",uiCurrent->data.valueAdjust.values[2]);
the_sz 5:13c70bcde7f6 447 UI_ShowDisplayTextCenter(17+(2*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 5:13c70bcde7f6 448
the_sz 5:13c70bcde7f6 449 snprintf(buffer,sizeof(buffer),"0x%02X",uiCurrent->data.valueAdjust.values[3]);
the_sz 5:13c70bcde7f6 450 UI_ShowDisplayTextCenter(17+(3*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 2:80026d18fcf3 451 }
the_sz 2:80026d18fcf3 452 }
the_sz 2:80026d18fcf3 453
the_sz 5:13c70bcde7f6 454 void UI_ClickValueAdjust(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 455 {
the_sz 5:13c70bcde7f6 456 int32_t index;
the_sz 3:ecf7f1f8d749 457
the_sz 2:80026d18fcf3 458 // detect at which button was clicked
the_sz 5:13c70bcde7f6 459 index=-1;
the_sz 3:ecf7f1f8d749 460
the_sz 5:13c70bcde7f6 461 if (uiCurrent->data.valueAdjust.count==4)
the_sz 5:13c70bcde7f6 462 {
the_sz 5:13c70bcde7f6 463 if ((y>=40) && (y<(40+BUTTON_HEIGHT)))
the_sz 5:13c70bcde7f6 464 {
the_sz 5:13c70bcde7f6 465 if ((x>=(17+(0*(BUTTON_WIDTH+15)))) && (x<(17+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 466 index=0;
the_sz 5:13c70bcde7f6 467 else if ((x>=(17+(1*(BUTTON_WIDTH+15)))) && (x<(17+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 468 index=1;
the_sz 5:13c70bcde7f6 469 else if ((x>=(17+(2*(BUTTON_WIDTH+15)))) && (x<(17+(2*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 470 index=2;
the_sz 5:13c70bcde7f6 471 else if ((x>=(17+(3*(BUTTON_WIDTH+15)))) && (x<(17+(3*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 472 index=3;
the_sz 5:13c70bcde7f6 473 }
the_sz 5:13c70bcde7f6 474 else if ((y>=205) && (y<(205+BUTTON_HEIGHT)))
the_sz 5:13c70bcde7f6 475 {
the_sz 5:13c70bcde7f6 476 if ((x>=(17+(0*(BUTTON_WIDTH+15)))) && (x<(17+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 477 index=4;
the_sz 5:13c70bcde7f6 478 else if ((x>=(17+(1*(BUTTON_WIDTH+15)))) && (x<(17+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 479 index=5;
the_sz 5:13c70bcde7f6 480 else if ((x>=(17+(2*(BUTTON_WIDTH+15)))) && (x<(17+(2*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 481 index=6;
the_sz 5:13c70bcde7f6 482 else if ((x>=(17+(3*(BUTTON_WIDTH+15)))) && (x<(17+(3*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 483 index=7;
the_sz 5:13c70bcde7f6 484 }
the_sz 5:13c70bcde7f6 485 }
the_sz 5:13c70bcde7f6 486
the_sz 5:13c70bcde7f6 487 if (index!=-1)
the_sz 5:13c70bcde7f6 488 uiCurrent->handler(UR_CLICK,index,uiCurrent);
the_sz 2:80026d18fcf3 489 }
the_sz 2:80026d18fcf3 490
the_sz 2:80026d18fcf3 491 //
the_sz 2:80026d18fcf3 492 // common
the_sz 2:80026d18fcf3 493 //
the_sz 2:80026d18fcf3 494 void UI_Init(void)
the_sz 2:80026d18fcf3 495 {
the_sz 2:80026d18fcf3 496 uiCurrent=NULL;
the_sz 2:80026d18fcf3 497
the_sz 3:ecf7f1f8d749 498 uiLastTouchX=0;
the_sz 3:ecf7f1f8d749 499 uiLastTouchY=0;
the_sz 3:ecf7f1f8d749 500
the_sz 2:80026d18fcf3 501 uiLcd.Init();
the_sz 2:80026d18fcf3 502 uiLcd.Clear(COLOR_BG);
the_sz 2:80026d18fcf3 503
the_sz 2:80026d18fcf3 504 if (uiTs.Init(uiLcd.GetXSize(),uiLcd.GetYSize())==TS_OK)
the_sz 2:80026d18fcf3 505 DPrintf("UI_Init: Size: %ux%u.\r\n",uiLcd.GetXSize(),uiLcd.GetYSize());
the_sz 2:80026d18fcf3 506 else
the_sz 2:80026d18fcf3 507 DPrintf("UI_Init: Can't init touch screen.\r\n");
the_sz 3:ecf7f1f8d749 508
the_sz 3:ecf7f1f8d749 509 // setup ui structs
the_sz 3:ecf7f1f8d749 510 uiClock.flags=UI_FLAG_TYPE_CLOCK;
the_sz 3:ecf7f1f8d749 511 uiClock.handler=NULL;
the_sz 5:13c70bcde7f6 512
the_sz 3:ecf7f1f8d749 513 uiClockInWords.flags=UI_FLAG_TYPE_CLOCK_IN_WORDS;
the_sz 3:ecf7f1f8d749 514 uiClockInWords.handler=NULL;
the_sz 5:13c70bcde7f6 515
the_sz 3:ecf7f1f8d749 516 uiWakeup.flags=UI_FLAG_TYPE_BOX_LIST;
the_sz 3:ecf7f1f8d749 517 uiWakeup.handler=UI_WakeupHandler;
the_sz 5:13c70bcde7f6 518
the_sz 5:13c70bcde7f6 519 uiColorTest.flags=UI_FLAG_TYPE_VALUE_ADJUST;
the_sz 5:13c70bcde7f6 520 uiColorTest.handler=UI_ColorTestHandler;
the_sz 5:13c70bcde7f6 521 uiColorTest.data.valueAdjust.count=4;
the_sz 5:13c70bcde7f6 522 uiColorTest.data.valueAdjust.values[0]=0x80;
the_sz 5:13c70bcde7f6 523 uiColorTest.data.valueAdjust.values[1]=0x80;
the_sz 5:13c70bcde7f6 524 uiColorTest.data.valueAdjust.values[2]=0x80;
the_sz 5:13c70bcde7f6 525 uiColorTest.data.valueAdjust.values[3]=0x80;
the_sz 5:13c70bcde7f6 526
the_sz 3:ecf7f1f8d749 527 uiMain.flags=UI_FLAG_TYPE_BOX_LIST;
the_sz 3:ecf7f1f8d749 528 uiMain.handler=UI_MainHandler;
the_sz 3:ecf7f1f8d749 529 uiMain.data.boxList.items=uiMainItems;
the_sz 3:ecf7f1f8d749 530 uiMain.data.boxList.count=COUNT_OF(uiMainItems);
the_sz 3:ecf7f1f8d749 531
the_sz 3:ecf7f1f8d749 532 UI_Show(&uiMain);
the_sz 2:80026d18fcf3 533 }
the_sz 2:80026d18fcf3 534
the_sz 2:80026d18fcf3 535 void UI_ShowChrome(bool initial)
the_sz 2:80026d18fcf3 536 {
the_sz 2:80026d18fcf3 537 char buffer[100];
the_sz 3:ecf7f1f8d749 538 struct tm *tmStruct;
the_sz 3:ecf7f1f8d749 539 time_t timeValue;
the_sz 2:80026d18fcf3 540
the_sz 2:80026d18fcf3 541 if (initial==true)
the_sz 2:80026d18fcf3 542 {
the_sz 2:80026d18fcf3 543 // fill background
the_sz 2:80026d18fcf3 544 uiLcd.SetTextColor(HEADER_COLOR_BG);
the_sz 5:13c70bcde7f6 545 uiLcd.FillRect(0,0,uiLcd.GetXSize(),HEADER_HEIGHT);
the_sz 5:13c70bcde7f6 546
the_sz 5:13c70bcde7f6 547 uiLcd.SetFont(&display_font_12x22);
the_sz 5:13c70bcde7f6 548 uiLcd.SetBackColor(HEADER_COLOR_BG);
the_sz 5:13c70bcde7f6 549 uiLcd.SetTextColor(HEADER_COLOR_FG);
the_sz 5:13c70bcde7f6 550 if ((uiCurrent->flags & UI_FLAG_HAS_BACK_BUTTON)!=0)
the_sz 6:aa51cc3b9f90 551 UI_DrawBitmapWithAlpha(0,1,ic_navigate_before_white_24dp_1x);
the_sz 2:80026d18fcf3 552 }
the_sz 2:80026d18fcf3 553
the_sz 2:80026d18fcf3 554 // show clock
the_sz 2:80026d18fcf3 555 uiLcd.SetFont(&display_font_12x22);
the_sz 2:80026d18fcf3 556 uiLcd.SetBackColor(HEADER_COLOR_BG);
the_sz 2:80026d18fcf3 557 uiLcd.SetTextColor(HEADER_COLOR_FG);
the_sz 3:ecf7f1f8d749 558 timeValue=time(NULL);
the_sz 3:ecf7f1f8d749 559 tmStruct=localtime(&timeValue);
the_sz 3:ecf7f1f8d749 560 snprintf(buffer,sizeof(buffer),"%u:%02u",tmStruct->tm_hour,tmStruct->tm_min);
the_sz 2:80026d18fcf3 561 uiLcd.DisplayStringAt(0,3,(uint8_t *)buffer,CENTER_MODE);
the_sz 2:80026d18fcf3 562
the_sz 2:80026d18fcf3 563 // show next alarm
the_sz 3:ecf7f1f8d749 564 //XXX
the_sz 2:80026d18fcf3 565 }
the_sz 2:80026d18fcf3 566
the_sz 2:80026d18fcf3 567 void UI_Update(bool initial)
the_sz 2:80026d18fcf3 568 {
the_sz 3:ecf7f1f8d749 569 uint8_t typeFlag;
the_sz 3:ecf7f1f8d749 570
the_sz 2:80026d18fcf3 571 if ((uiCurrent->flags & UI_FLAG_NEEDS_CHROME)!=0)
the_sz 2:80026d18fcf3 572 UI_ShowChrome(initial);
the_sz 2:80026d18fcf3 573
the_sz 5:13c70bcde7f6 574 typeFlag=uiCurrent->flags & ~(UI_FLAG_NEEDS_CHROME | UI_FLAG_HAS_BACK_BUTTON);
the_sz 3:ecf7f1f8d749 575 if ((typeFlag & UI_FLAG_TYPE_BOX_LIST)!=0)
the_sz 2:80026d18fcf3 576 UI_ShowBoxList(initial);
the_sz 3:ecf7f1f8d749 577 else if ((typeFlag & UI_FLAG_TYPE_MESSAGE_BOX)!=0)
the_sz 2:80026d18fcf3 578 UI_ShowMessageBox(initial);
the_sz 3:ecf7f1f8d749 579 else if ((typeFlag & UI_FLAG_TYPE_CLOCK)!=0)
the_sz 2:80026d18fcf3 580 UI_ShowClock(initial);
the_sz 3:ecf7f1f8d749 581 else if ((typeFlag & UI_FLAG_TYPE_CLOCK_IN_WORDS)!=0)
the_sz 2:80026d18fcf3 582 UI_ShowClockInWords(initial);
the_sz 5:13c70bcde7f6 583 else if ((typeFlag & UI_FLAG_TYPE_VALUE_ADJUST)!=0)
the_sz 5:13c70bcde7f6 584 UI_ShowValueAdjust(initial);
the_sz 2:80026d18fcf3 585 }
the_sz 2:80026d18fcf3 586
the_sz 2:80026d18fcf3 587 void UI_Show(UI_STRUCT *ui)
the_sz 2:80026d18fcf3 588 {
the_sz 5:13c70bcde7f6 589 DPrintf_("UI_Show: 0x%X.\r\n",ui->flags);
the_sz 3:ecf7f1f8d749 590
the_sz 2:80026d18fcf3 591 uiCurrent=ui;
the_sz 2:80026d18fcf3 592
the_sz 3:ecf7f1f8d749 593 if (uiCurrent->handler!=NULL)
the_sz 3:ecf7f1f8d749 594 uiCurrent->handler(UR_SHOW,0,uiCurrent);
the_sz 3:ecf7f1f8d749 595
the_sz 2:80026d18fcf3 596 UI_Update(true);
the_sz 2:80026d18fcf3 597 }
the_sz 2:80026d18fcf3 598
the_sz 2:80026d18fcf3 599 void UI_Click(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 600 {
the_sz 3:ecf7f1f8d749 601 uint8_t typeFlag;
the_sz 3:ecf7f1f8d749 602
the_sz 5:13c70bcde7f6 603 DPrintf_("UI_Click: %u x %u.\r\n",x,y);
the_sz 5:13c70bcde7f6 604
the_sz 5:13c70bcde7f6 605 if ((uiCurrent->flags & UI_FLAG_HAS_BACK_BUTTON)!=0)
the_sz 5:13c70bcde7f6 606 {
the_sz 5:13c70bcde7f6 607 if ((y<40) && (x<40))
the_sz 5:13c70bcde7f6 608 {
the_sz 5:13c70bcde7f6 609 if (uiCurrent->handler!=NULL)
the_sz 5:13c70bcde7f6 610 {
the_sz 5:13c70bcde7f6 611 uiCurrent->handler(UR_CLICK,-1,uiCurrent);
the_sz 5:13c70bcde7f6 612 return;
the_sz 5:13c70bcde7f6 613 }
the_sz 5:13c70bcde7f6 614 }
the_sz 5:13c70bcde7f6 615 }
the_sz 5:13c70bcde7f6 616
the_sz 5:13c70bcde7f6 617 typeFlag=uiCurrent->flags & ~(UI_FLAG_NEEDS_CHROME | UI_FLAG_HAS_BACK_BUTTON);
the_sz 3:ecf7f1f8d749 618 if ((typeFlag & UI_FLAG_TYPE_BOX_LIST)!=0)
the_sz 2:80026d18fcf3 619 UI_ClickBoxList(x,y);
the_sz 3:ecf7f1f8d749 620 else if ((typeFlag & UI_FLAG_TYPE_MESSAGE_BOX)!=0)
the_sz 2:80026d18fcf3 621 UI_ClickMessageBox(x,y);
the_sz 3:ecf7f1f8d749 622 else if ((typeFlag & UI_FLAG_TYPE_CLOCK)!=0)
the_sz 2:80026d18fcf3 623 UI_ClickClock(x,y);
the_sz 3:ecf7f1f8d749 624 else if ((typeFlag & UI_FLAG_TYPE_CLOCK_IN_WORDS)!=0)
the_sz 2:80026d18fcf3 625 UI_ClickClockInWords(x,y);
the_sz 5:13c70bcde7f6 626 else if ((typeFlag & UI_FLAG_TYPE_VALUE_ADJUST)!=0)
the_sz 5:13c70bcde7f6 627 UI_ClickValueAdjust(x,y);
the_sz 2:80026d18fcf3 628 }
the_sz 2:80026d18fcf3 629
the_sz 2:80026d18fcf3 630 void UI_Poll(void)
the_sz 2:80026d18fcf3 631 {
the_sz 2:80026d18fcf3 632 TS_StateTypeDef tsState;
the_sz 2:80026d18fcf3 633
the_sz 2:80026d18fcf3 634 uiTs.GetState(&tsState);
the_sz 2:80026d18fcf3 635 if (tsState.touchDetected>0)
the_sz 2:80026d18fcf3 636 {
the_sz 3:ecf7f1f8d749 637 if ( (ABS(uiLastTouchX-tsState.touchX[0])>4)
the_sz 3:ecf7f1f8d749 638 ||
the_sz 3:ecf7f1f8d749 639 (ABS(uiLastTouchY-tsState.touchY[0])>4)
the_sz 3:ecf7f1f8d749 640 )
the_sz 3:ecf7f1f8d749 641 {
the_sz 5:13c70bcde7f6 642 DPrintf_("UI_Poll: #%u - %ux%u.\r\n",tsState.touchDetected,tsState.touchX[0],tsState.touchY[0]);
the_sz 3:ecf7f1f8d749 643
the_sz 3:ecf7f1f8d749 644 uiLastTouchX=tsState.touchX[0];
the_sz 3:ecf7f1f8d749 645 uiLastTouchY=tsState.touchY[0];
the_sz 3:ecf7f1f8d749 646
the_sz 3:ecf7f1f8d749 647 if (uiCurrent!=NULL)
the_sz 3:ecf7f1f8d749 648 UI_Click(tsState.touchX[0],tsState.touchY[0]);
the_sz 3:ecf7f1f8d749 649 }
the_sz 2:80026d18fcf3 650 }
the_sz 5:13c70bcde7f6 651 else
the_sz 5:13c70bcde7f6 652 {
the_sz 5:13c70bcde7f6 653 uiLastTouchX=0;
the_sz 5:13c70bcde7f6 654 uiLastTouchY=0;
the_sz 5:13c70bcde7f6 655 }
the_sz 2:80026d18fcf3 656
the_sz 2:80026d18fcf3 657 if (uiCurrent!=NULL)
the_sz 3:ecf7f1f8d749 658 {
the_sz 3:ecf7f1f8d749 659 if (uiCurrent->handler!=NULL)
the_sz 3:ecf7f1f8d749 660 uiCurrent->handler(UR_TIMER,0,uiCurrent);
the_sz 3:ecf7f1f8d749 661
the_sz 2:80026d18fcf3 662 UI_Update(false);
the_sz 3:ecf7f1f8d749 663 }
the_sz 2:80026d18fcf3 664 }