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:
Thu Oct 29 18:09:31 2015 +0000
Revision:
3:ecf7f1f8d749
Parent:
2:80026d18fcf3
Child:
5:13c70bcde7f6
ui menu working, time() added

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 3:ecf7f1f8d749 3 #define CLIENT_COLOR_BG ((uint32_t)0xFF000000)
the_sz 2:80026d18fcf3 4 #define CLIENT_COLOR_FG ((uint32_t)0xFFD0D0D0)
the_sz 2:80026d18fcf3 5
the_sz 2:80026d18fcf3 6 #define HEADER_HEIGHT 25
the_sz 2:80026d18fcf3 7 #define HEADER_COLOR_BG ((uint32_t)0xFF404040)
the_sz 2:80026d18fcf3 8 #define HEADER_COLOR_FG ((uint32_t)0xFFD3D3D3)
the_sz 2:80026d18fcf3 9
the_sz 2:80026d18fcf3 10 #define CLOCK_COLOR_BG ((uint32_t)0xFF000000)
the_sz 2:80026d18fcf3 11 #define CLOCK_COLOR_FG ((uint32_t)0xFF707070)
the_sz 2:80026d18fcf3 12
the_sz 2:80026d18fcf3 13 #define COLOR_BG ((uint32_t)0xFF000000)
the_sz 2:80026d18fcf3 14
the_sz 3:ecf7f1f8d749 15 #define MAX_BOXES_PER_LINE 3
the_sz 3:ecf7f1f8d749 16 #define BOX_SPACING 10
the_sz 3:ecf7f1f8d749 17 #define BOX_TEXT_SPACING 10
the_sz 3:ecf7f1f8d749 18 #define BOX_COLOR_BG ((uint32_t)0xFF808080)
the_sz 3:ecf7f1f8d749 19 #define BOX_COLOR_FG CLIENT_COLOR_FG
the_sz 3:ecf7f1f8d749 20
the_sz 2:80026d18fcf3 21 LCD_DISCO_F746NG uiLcd;
the_sz 2:80026d18fcf3 22 TS_DISCO_F746NG uiTs;
the_sz 3:ecf7f1f8d749 23 uint16_t uiLastTouchX;
the_sz 3:ecf7f1f8d749 24 uint16_t uiLastTouchY;
the_sz 2:80026d18fcf3 25 UI_STRUCT *uiCurrent=NULL;
the_sz 3:ecf7f1f8d749 26 UI_STRUCT uiClock;
the_sz 3:ecf7f1f8d749 27 UI_STRUCT uiClockInWords;
the_sz 3:ecf7f1f8d749 28 UI_STRUCT uiWakeup;
the_sz 3:ecf7f1f8d749 29 UI_STRUCT uiMain;
the_sz 3:ecf7f1f8d749 30 UI_BOX_LIST_ITEM_STRUCT uiMainItems[]=
the_sz 3:ecf7f1f8d749 31 {
the_sz 3:ecf7f1f8d749 32 { "Clock" }, { "Clock\nWith Words" }, { "Adjust\nTimers" }, { "Lights On" }, { "Lights Off" }
the_sz 3:ecf7f1f8d749 33 };
the_sz 2:80026d18fcf3 34
the_sz 2:80026d18fcf3 35 //
the_sz 2:80026d18fcf3 36 // helper function
the_sz 2:80026d18fcf3 37 //
the_sz 2:80026d18fcf3 38 void UI_ShowClearClientRect(void)
the_sz 2:80026d18fcf3 39 {
the_sz 2:80026d18fcf3 40 uiLcd.SetTextColor(CLIENT_COLOR_BG);
the_sz 2:80026d18fcf3 41 uiLcd.FillRect(0,HEADER_HEIGHT,uiLcd.GetXSize()-1,uiLcd.GetYSize()-1);
the_sz 2:80026d18fcf3 42 }
the_sz 2:80026d18fcf3 43
the_sz 3:ecf7f1f8d749 44 void UI_ShowDisplayText(int16_t x,int16_t y,char *text)
the_sz 3:ecf7f1f8d749 45 {
the_sz 3:ecf7f1f8d749 46 int16_t xStart;
the_sz 3:ecf7f1f8d749 47 int16_t charWidth;
the_sz 3:ecf7f1f8d749 48 int16_t charHeight;
the_sz 3:ecf7f1f8d749 49
the_sz 3:ecf7f1f8d749 50 xStart=x;
the_sz 3:ecf7f1f8d749 51 charHeight=uiLcd.GetFont()->Height+3;
the_sz 3:ecf7f1f8d749 52 charWidth=uiLcd.GetFont()->Width;
the_sz 3:ecf7f1f8d749 53
the_sz 3:ecf7f1f8d749 54 while ((*text)!='\0')
the_sz 3:ecf7f1f8d749 55 {
the_sz 3:ecf7f1f8d749 56 if ((*text)=='\n')
the_sz 3:ecf7f1f8d749 57 {
the_sz 3:ecf7f1f8d749 58 y+=charHeight;
the_sz 3:ecf7f1f8d749 59 x=xStart;
the_sz 3:ecf7f1f8d749 60 }
the_sz 3:ecf7f1f8d749 61 else
the_sz 3:ecf7f1f8d749 62 {
the_sz 3:ecf7f1f8d749 63 uiLcd.DisplayChar(x,y,*text);
the_sz 3:ecf7f1f8d749 64 x+=charWidth;
the_sz 3:ecf7f1f8d749 65 }
the_sz 3:ecf7f1f8d749 66
the_sz 3:ecf7f1f8d749 67 text++;
the_sz 3:ecf7f1f8d749 68 }
the_sz 3:ecf7f1f8d749 69 }
the_sz 3:ecf7f1f8d749 70
the_sz 2:80026d18fcf3 71 //
the_sz 2:80026d18fcf3 72 // box list
the_sz 2:80026d18fcf3 73 //
the_sz 2:80026d18fcf3 74 void UI_ShowBoxList(bool initial)
the_sz 2:80026d18fcf3 75 {
the_sz 2:80026d18fcf3 76 if (initial==true)
the_sz 2:80026d18fcf3 77 {
the_sz 3:ecf7f1f8d749 78 int8_t lines;
the_sz 3:ecf7f1f8d749 79 int8_t columns;
the_sz 3:ecf7f1f8d749 80 int8_t box;
the_sz 3:ecf7f1f8d749 81 int16_t width;
the_sz 3:ecf7f1f8d749 82 int16_t height;
the_sz 3:ecf7f1f8d749 83 int16_t startX;
the_sz 3:ecf7f1f8d749 84 int16_t startY;
the_sz 3:ecf7f1f8d749 85
the_sz 2:80026d18fcf3 86 // fill background
the_sz 2:80026d18fcf3 87 UI_ShowClearClientRect();
the_sz 3:ecf7f1f8d749 88
the_sz 3:ecf7f1f8d749 89 // paint boxes
the_sz 3:ecf7f1f8d749 90 if (uiCurrent->data.boxList.count<=MAX_BOXES_PER_LINE)
the_sz 3:ecf7f1f8d749 91 lines=1;
the_sz 3:ecf7f1f8d749 92 else
the_sz 3:ecf7f1f8d749 93 lines=2;
the_sz 3:ecf7f1f8d749 94
the_sz 3:ecf7f1f8d749 95 columns=((uiCurrent->data.boxList.count + (lines-1)) / lines);
the_sz 3:ecf7f1f8d749 96
the_sz 3:ecf7f1f8d749 97 width=(uiLcd.GetXSize() - BOX_SPACING) / columns;
the_sz 3:ecf7f1f8d749 98 height=(uiLcd.GetYSize() - HEADER_HEIGHT - BOX_SPACING) / lines;
the_sz 3:ecf7f1f8d749 99
the_sz 3:ecf7f1f8d749 100 for (box=0;box<uiCurrent->data.boxList.count;box++)
the_sz 3:ecf7f1f8d749 101 {
the_sz 3:ecf7f1f8d749 102 startX=BOX_SPACING+(width*(box % columns));
the_sz 3:ecf7f1f8d749 103 startY=HEADER_HEIGHT+BOX_SPACING+(height*(box/columns));
the_sz 3:ecf7f1f8d749 104
the_sz 3:ecf7f1f8d749 105 // paint box background
the_sz 3:ecf7f1f8d749 106 uiLcd.SetTextColor(BOX_COLOR_BG);
the_sz 3:ecf7f1f8d749 107 uiLcd.FillRect(startX,startY,width-BOX_SPACING,height-BOX_SPACING);
the_sz 3:ecf7f1f8d749 108
the_sz 3:ecf7f1f8d749 109 // paint box text
the_sz 3:ecf7f1f8d749 110 uiLcd.SetFont(&display_font_12x22);
the_sz 3:ecf7f1f8d749 111 uiLcd.SetBackColor(BOX_COLOR_BG);
the_sz 3:ecf7f1f8d749 112 uiLcd.SetTextColor(BOX_COLOR_FG);
the_sz 3:ecf7f1f8d749 113 UI_ShowDisplayText(startX+BOX_TEXT_SPACING,startY+BOX_TEXT_SPACING,uiCurrent->data.boxList.items[box].name);
the_sz 3:ecf7f1f8d749 114 }
the_sz 3:ecf7f1f8d749 115 }
the_sz 2:80026d18fcf3 116 }
the_sz 2:80026d18fcf3 117
the_sz 2:80026d18fcf3 118 void UI_ClickBoxList(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 119 {
the_sz 3:ecf7f1f8d749 120 int8_t lines;
the_sz 3:ecf7f1f8d749 121 int8_t columns;
the_sz 3:ecf7f1f8d749 122 int8_t box;
the_sz 3:ecf7f1f8d749 123 int16_t width;
the_sz 3:ecf7f1f8d749 124 int16_t height;
the_sz 3:ecf7f1f8d749 125 int16_t startX;
the_sz 3:ecf7f1f8d749 126 int16_t startY;
the_sz 3:ecf7f1f8d749 127
the_sz 3:ecf7f1f8d749 128 // detect at which box was clicked
the_sz 3:ecf7f1f8d749 129 if (uiCurrent->data.boxList.count<=MAX_BOXES_PER_LINE)
the_sz 3:ecf7f1f8d749 130 lines=1;
the_sz 3:ecf7f1f8d749 131 else
the_sz 3:ecf7f1f8d749 132 lines=2;
the_sz 3:ecf7f1f8d749 133
the_sz 3:ecf7f1f8d749 134 columns=((uiCurrent->data.boxList.count + (lines-1)) / lines);
the_sz 3:ecf7f1f8d749 135
the_sz 3:ecf7f1f8d749 136 width=(uiLcd.GetXSize() - BOX_SPACING) / columns;
the_sz 3:ecf7f1f8d749 137 height=(uiLcd.GetYSize() - HEADER_HEIGHT - BOX_SPACING) / lines;
the_sz 3:ecf7f1f8d749 138
the_sz 3:ecf7f1f8d749 139 for (box=0;box<uiCurrent->data.boxList.count;box++)
the_sz 3:ecf7f1f8d749 140 {
the_sz 3:ecf7f1f8d749 141 startX=BOX_SPACING+(width*(box % columns));
the_sz 3:ecf7f1f8d749 142 startY=HEADER_HEIGHT+BOX_SPACING+(height*(box/columns));
the_sz 3:ecf7f1f8d749 143
the_sz 3:ecf7f1f8d749 144 if ( (x>=startX) && (x<(startX+width-BOX_SPACING))
the_sz 3:ecf7f1f8d749 145 &&
the_sz 3:ecf7f1f8d749 146 (y>=startY) && (y<(startY+height-BOX_SPACING))
the_sz 3:ecf7f1f8d749 147 )
the_sz 3:ecf7f1f8d749 148 {
the_sz 3:ecf7f1f8d749 149 uiCurrent->handler(UR_CLICK,box,uiCurrent);
the_sz 3:ecf7f1f8d749 150 break;
the_sz 3:ecf7f1f8d749 151 }
the_sz 3:ecf7f1f8d749 152 }
the_sz 2:80026d18fcf3 153 }
the_sz 2:80026d18fcf3 154
the_sz 2:80026d18fcf3 155 //
the_sz 2:80026d18fcf3 156 // message box
the_sz 2:80026d18fcf3 157 //
the_sz 2:80026d18fcf3 158 void UI_ShowMessageBox(bool initial)
the_sz 2:80026d18fcf3 159 {
the_sz 2:80026d18fcf3 160 if (initial==true)
the_sz 2:80026d18fcf3 161 {
the_sz 2:80026d18fcf3 162 // fill background
the_sz 2:80026d18fcf3 163 UI_ShowClearClientRect();
the_sz 2:80026d18fcf3 164 }
the_sz 2:80026d18fcf3 165 }
the_sz 2:80026d18fcf3 166
the_sz 2:80026d18fcf3 167 void UI_ClickMessageBox(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 168 {
the_sz 3:ecf7f1f8d749 169 uint32_t index;
the_sz 3:ecf7f1f8d749 170
the_sz 2:80026d18fcf3 171 // detect at which button was clicked
the_sz 3:ecf7f1f8d749 172 index=0;
the_sz 3:ecf7f1f8d749 173
the_sz 3:ecf7f1f8d749 174 uiCurrent->handler(UR_CLICK,index,uiCurrent);
the_sz 2:80026d18fcf3 175 }
the_sz 2:80026d18fcf3 176
the_sz 2:80026d18fcf3 177 //
the_sz 2:80026d18fcf3 178 // clock
the_sz 2:80026d18fcf3 179 //
the_sz 2:80026d18fcf3 180 void UI_ShowClock(bool initial)
the_sz 2:80026d18fcf3 181 {
the_sz 2:80026d18fcf3 182 char buffer[100];
the_sz 3:ecf7f1f8d749 183 struct tm *tmStruct;
the_sz 3:ecf7f1f8d749 184 time_t timeValue;
the_sz 2:80026d18fcf3 185
the_sz 2:80026d18fcf3 186 if (initial==true)
the_sz 2:80026d18fcf3 187 {
the_sz 2:80026d18fcf3 188 // fill background
the_sz 2:80026d18fcf3 189 uiLcd.SetTextColor(CLOCK_COLOR_BG);
the_sz 2:80026d18fcf3 190 uiLcd.FillRect(0,0,uiLcd.GetXSize()-1,uiLcd.GetYSize()-1);
the_sz 2:80026d18fcf3 191 }
the_sz 2:80026d18fcf3 192
the_sz 2:80026d18fcf3 193 // show clock
the_sz 2:80026d18fcf3 194 uiLcd.SetFont(&display_font_12x22);
the_sz 2:80026d18fcf3 195 uiLcd.SetBackColor(CLOCK_COLOR_BG);
the_sz 2:80026d18fcf3 196 uiLcd.SetTextColor(CLOCK_COLOR_FG);
the_sz 3:ecf7f1f8d749 197 timeValue=time(NULL);
the_sz 3:ecf7f1f8d749 198 tmStruct=localtime(&timeValue);
the_sz 3:ecf7f1f8d749 199 snprintf(buffer,sizeof(buffer),"%u:%02u:%02u",tmStruct->tm_hour,tmStruct->tm_min,tmStruct->tm_sec);
the_sz 2:80026d18fcf3 200 uiLcd.DisplayStringAt(0,100,(uint8_t *)buffer,CENTER_MODE);
the_sz 2:80026d18fcf3 201 }
the_sz 2:80026d18fcf3 202
the_sz 2:80026d18fcf3 203 void UI_ClickClock(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 204 {
the_sz 2:80026d18fcf3 205 // exit view
the_sz 3:ecf7f1f8d749 206 UI_Show(&uiMain);
the_sz 2:80026d18fcf3 207 }
the_sz 2:80026d18fcf3 208
the_sz 2:80026d18fcf3 209 //
the_sz 2:80026d18fcf3 210 // clock in words
the_sz 2:80026d18fcf3 211 //
the_sz 2:80026d18fcf3 212 void UI_ShowClockInWords(bool initial)
the_sz 2:80026d18fcf3 213 {
the_sz 2:80026d18fcf3 214 if (initial==true)
the_sz 2:80026d18fcf3 215 {
the_sz 2:80026d18fcf3 216 // fill background
the_sz 2:80026d18fcf3 217 UI_ShowClearClientRect();
the_sz 2:80026d18fcf3 218 }
the_sz 2:80026d18fcf3 219
the_sz 2:80026d18fcf3 220 // show clock in words
the_sz 2:80026d18fcf3 221 uiLcd.SetFont(&display_font_12x22);
the_sz 2:80026d18fcf3 222 uiLcd.SetBackColor(CLIENT_COLOR_BG);
the_sz 2:80026d18fcf3 223 uiLcd.SetTextColor(CLIENT_COLOR_FG);
the_sz 2:80026d18fcf3 224 uiLcd.DisplayStringAt(5,30,(uint8_t *)"UM F\x9ANF ZEHN VIERTEL HALB",LEFT_MODE);
the_sz 2:80026d18fcf3 225 uiLcd.DisplayStringAt(5,60,(uint8_t *)"NACH VOR",LEFT_MODE);
the_sz 2:80026d18fcf3 226 uiLcd.DisplayStringAt(5,90,(uint8_t *)"EINS ZWEI DREI VIER",LEFT_MODE);
the_sz 2:80026d18fcf3 227 uiLcd.DisplayStringAt(5,120,(uint8_t *)"F\x9ANF SECHS SIEBEN ACHT",LEFT_MODE);
the_sz 2:80026d18fcf3 228 uiLcd.DisplayStringAt(5,150,(uint8_t *)"NEUN ZEHN ELF ZW\x99LF",LEFT_MODE);
the_sz 2:80026d18fcf3 229
the_sz 2:80026d18fcf3 230 // draw charset
the_sz 2:80026d18fcf3 231 /*
the_sz 2:80026d18fcf3 232 int x;
the_sz 2:80026d18fcf3 233 for (x=0x80;x<=0xFF;x++)
the_sz 2:80026d18fcf3 234 {
the_sz 2:80026d18fcf3 235 uiLcd.DisplayChar(1+(((x-0x80) % 16)*14),30+(((x-0x80)/16)*20),x);
the_sz 2:80026d18fcf3 236 }
the_sz 2:80026d18fcf3 237 */
the_sz 2:80026d18fcf3 238 }
the_sz 2:80026d18fcf3 239
the_sz 2:80026d18fcf3 240 void UI_ClickClockInWords(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 241 {
the_sz 2:80026d18fcf3 242 // exit view
the_sz 3:ecf7f1f8d749 243 UI_Show(&uiMain);
the_sz 2:80026d18fcf3 244 }
the_sz 2:80026d18fcf3 245
the_sz 2:80026d18fcf3 246 //
the_sz 2:80026d18fcf3 247 // timer adjust
the_sz 2:80026d18fcf3 248 //
the_sz 2:80026d18fcf3 249 void UI_ShowTimerAdjust(bool initial)
the_sz 2:80026d18fcf3 250 {
the_sz 2:80026d18fcf3 251 if (initial==true)
the_sz 2:80026d18fcf3 252 {
the_sz 2:80026d18fcf3 253 // fill background
the_sz 2:80026d18fcf3 254 UI_ShowClearClientRect();
the_sz 2:80026d18fcf3 255 }
the_sz 2:80026d18fcf3 256 }
the_sz 2:80026d18fcf3 257
the_sz 2:80026d18fcf3 258 void UI_ClickTimerAdjust(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 259 {
the_sz 3:ecf7f1f8d749 260 uint32_t index;
the_sz 3:ecf7f1f8d749 261
the_sz 2:80026d18fcf3 262 // detect at which button was clicked
the_sz 3:ecf7f1f8d749 263 index=0;
the_sz 3:ecf7f1f8d749 264
the_sz 3:ecf7f1f8d749 265 uiCurrent->handler(UR_CLICK,index,uiCurrent);
the_sz 2:80026d18fcf3 266 }
the_sz 2:80026d18fcf3 267
the_sz 2:80026d18fcf3 268 //
the_sz 2:80026d18fcf3 269 // common
the_sz 2:80026d18fcf3 270 //
the_sz 2:80026d18fcf3 271 void UI_Init(void)
the_sz 2:80026d18fcf3 272 {
the_sz 2:80026d18fcf3 273 uiCurrent=NULL;
the_sz 2:80026d18fcf3 274
the_sz 3:ecf7f1f8d749 275 uiLastTouchX=0;
the_sz 3:ecf7f1f8d749 276 uiLastTouchY=0;
the_sz 3:ecf7f1f8d749 277
the_sz 2:80026d18fcf3 278 uiLcd.Init();
the_sz 2:80026d18fcf3 279 uiLcd.Clear(COLOR_BG);
the_sz 2:80026d18fcf3 280
the_sz 2:80026d18fcf3 281 if (uiTs.Init(uiLcd.GetXSize(),uiLcd.GetYSize())==TS_OK)
the_sz 2:80026d18fcf3 282 DPrintf("UI_Init: Size: %ux%u.\r\n",uiLcd.GetXSize(),uiLcd.GetYSize());
the_sz 2:80026d18fcf3 283 else
the_sz 2:80026d18fcf3 284 DPrintf("UI_Init: Can't init touch screen.\r\n");
the_sz 3:ecf7f1f8d749 285
the_sz 3:ecf7f1f8d749 286 // setup ui structs
the_sz 3:ecf7f1f8d749 287 uiClock.flags=UI_FLAG_TYPE_CLOCK;
the_sz 3:ecf7f1f8d749 288 uiClock.handler=NULL;
the_sz 3:ecf7f1f8d749 289 uiClockInWords.flags=UI_FLAG_TYPE_CLOCK_IN_WORDS;
the_sz 3:ecf7f1f8d749 290 uiClockInWords.handler=NULL;
the_sz 3:ecf7f1f8d749 291 uiWakeup.flags=UI_FLAG_TYPE_BOX_LIST;
the_sz 3:ecf7f1f8d749 292 uiWakeup.handler=UI_WakeupHandler;
the_sz 3:ecf7f1f8d749 293 uiMain.flags=UI_FLAG_TYPE_BOX_LIST;
the_sz 3:ecf7f1f8d749 294 uiMain.handler=UI_MainHandler;
the_sz 3:ecf7f1f8d749 295 uiMain.data.boxList.items=uiMainItems;
the_sz 3:ecf7f1f8d749 296 uiMain.data.boxList.count=COUNT_OF(uiMainItems);
the_sz 3:ecf7f1f8d749 297
the_sz 3:ecf7f1f8d749 298 UI_Show(&uiMain);
the_sz 2:80026d18fcf3 299 }
the_sz 2:80026d18fcf3 300
the_sz 2:80026d18fcf3 301 void UI_ShowChrome(bool initial)
the_sz 2:80026d18fcf3 302 {
the_sz 2:80026d18fcf3 303 char buffer[100];
the_sz 3:ecf7f1f8d749 304 struct tm *tmStruct;
the_sz 3:ecf7f1f8d749 305 time_t timeValue;
the_sz 2:80026d18fcf3 306
the_sz 2:80026d18fcf3 307 if (initial==true)
the_sz 2:80026d18fcf3 308 {
the_sz 2:80026d18fcf3 309 // fill background
the_sz 2:80026d18fcf3 310 uiLcd.SetTextColor(HEADER_COLOR_BG);
the_sz 2:80026d18fcf3 311 uiLcd.FillRect(0,0,uiLcd.GetXSize()-1,HEADER_HEIGHT);
the_sz 2:80026d18fcf3 312 }
the_sz 2:80026d18fcf3 313
the_sz 2:80026d18fcf3 314 // show clock
the_sz 2:80026d18fcf3 315 uiLcd.SetFont(&display_font_12x22);
the_sz 2:80026d18fcf3 316 uiLcd.SetBackColor(HEADER_COLOR_BG);
the_sz 2:80026d18fcf3 317 uiLcd.SetTextColor(HEADER_COLOR_FG);
the_sz 3:ecf7f1f8d749 318 timeValue=time(NULL);
the_sz 3:ecf7f1f8d749 319 tmStruct=localtime(&timeValue);
the_sz 3:ecf7f1f8d749 320 snprintf(buffer,sizeof(buffer),"%u:%02u",tmStruct->tm_hour,tmStruct->tm_min);
the_sz 2:80026d18fcf3 321 uiLcd.DisplayStringAt(0,3,(uint8_t *)buffer,CENTER_MODE);
the_sz 2:80026d18fcf3 322
the_sz 2:80026d18fcf3 323 // show next alarm
the_sz 3:ecf7f1f8d749 324 //XXX
the_sz 2:80026d18fcf3 325 }
the_sz 2:80026d18fcf3 326
the_sz 2:80026d18fcf3 327 void UI_Update(bool initial)
the_sz 2:80026d18fcf3 328 {
the_sz 3:ecf7f1f8d749 329 uint8_t typeFlag;
the_sz 3:ecf7f1f8d749 330
the_sz 2:80026d18fcf3 331 if ((uiCurrent->flags & UI_FLAG_NEEDS_CHROME)!=0)
the_sz 2:80026d18fcf3 332 UI_ShowChrome(initial);
the_sz 2:80026d18fcf3 333
the_sz 3:ecf7f1f8d749 334 typeFlag=uiCurrent->flags & ~UI_FLAG_NEEDS_CHROME;
the_sz 3:ecf7f1f8d749 335 if ((typeFlag & UI_FLAG_TYPE_BOX_LIST)!=0)
the_sz 2:80026d18fcf3 336 UI_ShowBoxList(initial);
the_sz 3:ecf7f1f8d749 337 else if ((typeFlag & UI_FLAG_TYPE_MESSAGE_BOX)!=0)
the_sz 2:80026d18fcf3 338 UI_ShowMessageBox(initial);
the_sz 3:ecf7f1f8d749 339 else if ((typeFlag & UI_FLAG_TYPE_CLOCK)!=0)
the_sz 2:80026d18fcf3 340 UI_ShowClock(initial);
the_sz 3:ecf7f1f8d749 341 else if ((typeFlag & UI_FLAG_TYPE_CLOCK_IN_WORDS)!=0)
the_sz 2:80026d18fcf3 342 UI_ShowClockInWords(initial);
the_sz 3:ecf7f1f8d749 343 else if ((typeFlag & UI_FLAG_TYPE_TIMER_ADJUST)!=0)
the_sz 2:80026d18fcf3 344 UI_ShowTimerAdjust(initial);
the_sz 2:80026d18fcf3 345 }
the_sz 2:80026d18fcf3 346
the_sz 2:80026d18fcf3 347 void UI_Show(UI_STRUCT *ui)
the_sz 2:80026d18fcf3 348 {
the_sz 3:ecf7f1f8d749 349 DPrintf("UI_Show: 0x%X.\r\n",ui->flags);
the_sz 3:ecf7f1f8d749 350
the_sz 2:80026d18fcf3 351 uiCurrent=ui;
the_sz 2:80026d18fcf3 352
the_sz 3:ecf7f1f8d749 353 if (uiCurrent->handler!=NULL)
the_sz 3:ecf7f1f8d749 354 uiCurrent->handler(UR_SHOW,0,uiCurrent);
the_sz 3:ecf7f1f8d749 355
the_sz 2:80026d18fcf3 356 UI_Update(true);
the_sz 2:80026d18fcf3 357 }
the_sz 2:80026d18fcf3 358
the_sz 2:80026d18fcf3 359 void UI_Click(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 360 {
the_sz 3:ecf7f1f8d749 361 uint8_t typeFlag;
the_sz 3:ecf7f1f8d749 362
the_sz 3:ecf7f1f8d749 363 typeFlag=uiCurrent->flags & ~UI_FLAG_NEEDS_CHROME;
the_sz 3:ecf7f1f8d749 364 if ((typeFlag & UI_FLAG_TYPE_BOX_LIST)!=0)
the_sz 2:80026d18fcf3 365 UI_ClickBoxList(x,y);
the_sz 3:ecf7f1f8d749 366 else if ((typeFlag & UI_FLAG_TYPE_MESSAGE_BOX)!=0)
the_sz 2:80026d18fcf3 367 UI_ClickMessageBox(x,y);
the_sz 3:ecf7f1f8d749 368 else if ((typeFlag & UI_FLAG_TYPE_CLOCK)!=0)
the_sz 2:80026d18fcf3 369 UI_ClickClock(x,y);
the_sz 3:ecf7f1f8d749 370 else if ((typeFlag & UI_FLAG_TYPE_CLOCK_IN_WORDS)!=0)
the_sz 2:80026d18fcf3 371 UI_ClickClockInWords(x,y);
the_sz 3:ecf7f1f8d749 372 else if ((typeFlag & UI_FLAG_TYPE_TIMER_ADJUST)!=0)
the_sz 2:80026d18fcf3 373 UI_ClickTimerAdjust(x,y);
the_sz 2:80026d18fcf3 374 }
the_sz 2:80026d18fcf3 375
the_sz 2:80026d18fcf3 376 void UI_Poll(void)
the_sz 2:80026d18fcf3 377 {
the_sz 2:80026d18fcf3 378 TS_StateTypeDef tsState;
the_sz 2:80026d18fcf3 379
the_sz 2:80026d18fcf3 380 uiTs.GetState(&tsState);
the_sz 2:80026d18fcf3 381 if (tsState.touchDetected>0)
the_sz 2:80026d18fcf3 382 {
the_sz 3:ecf7f1f8d749 383 if ( (ABS(uiLastTouchX-tsState.touchX[0])>4)
the_sz 3:ecf7f1f8d749 384 ||
the_sz 3:ecf7f1f8d749 385 (ABS(uiLastTouchY-tsState.touchY[0])>4)
the_sz 3:ecf7f1f8d749 386 )
the_sz 3:ecf7f1f8d749 387 {
the_sz 3:ecf7f1f8d749 388 DPrintf("UI_Poll: #%u - %ux%u.\r\n",tsState.touchDetected,tsState.touchX[0],tsState.touchY[0]);
the_sz 3:ecf7f1f8d749 389
the_sz 3:ecf7f1f8d749 390 uiLastTouchX=tsState.touchX[0];
the_sz 3:ecf7f1f8d749 391 uiLastTouchY=tsState.touchY[0];
the_sz 3:ecf7f1f8d749 392
the_sz 3:ecf7f1f8d749 393 if (uiCurrent!=NULL)
the_sz 3:ecf7f1f8d749 394 UI_Click(tsState.touchX[0],tsState.touchY[0]);
the_sz 3:ecf7f1f8d749 395 }
the_sz 2:80026d18fcf3 396 }
the_sz 2:80026d18fcf3 397
the_sz 2:80026d18fcf3 398 if (uiCurrent!=NULL)
the_sz 3:ecf7f1f8d749 399 {
the_sz 3:ecf7f1f8d749 400 if (uiCurrent->handler!=NULL)
the_sz 3:ecf7f1f8d749 401 uiCurrent->handler(UR_TIMER,0,uiCurrent);
the_sz 3:ecf7f1f8d749 402
the_sz 2:80026d18fcf3 403 UI_Update(false);
the_sz 3:ecf7f1f8d749 404 }
the_sz 2:80026d18fcf3 405 }