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:
Sun Jan 31 01:02:36 2016 +0000
Revision:
12:a89096944f20
Parent:
11:3c6366ea1021
Child:
13:811a5c5b3fd6
date adjust 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 6:aa51cc3b9f90 3 #include "Images/ic_navigate_before_white_24dp_1x.h"
the_sz 6:aa51cc3b9f90 4 #include "Images/ic_notifications_none_white_48dp_1x.h"
the_sz 6:aa51cc3b9f90 5 #include "Images/ic_query_builder_white_48dp_1x.h"
the_sz 12:a89096944f20 6 #include "Images/ic_slideshow_white_48dp_1x.h"
the_sz 12:a89096944f20 7 #include "Images/ic_visibility_off_white_48dp_1x.h"
the_sz 12:a89096944f20 8 #include "Images/ic_visibility_white_48dp_1x.h"
the_sz 12:a89096944f20 9 #include "Images/ic_equalizer_white_48dp_1x.h"
the_sz 12:a89096944f20 10 #include "Images/ic_settings_white_48dp_1x.h"
the_sz 6:aa51cc3b9f90 11
the_sz 7:dc29f6647486 12 #define CLIENT_COLOR_BG ((uint32_t)0xFF000000)
the_sz 7:dc29f6647486 13 #define CLIENT_COLOR_FG ((uint32_t)0xFFD0D0D0)
the_sz 2:80026d18fcf3 14
the_sz 7:dc29f6647486 15 #define HEADER_HEIGHT 25
the_sz 7:dc29f6647486 16 #define HEADER_COLOR_BG ((uint32_t)0xFF404040)
the_sz 7:dc29f6647486 17 #define HEADER_COLOR_FG ((uint32_t)0xFFD3D3D3)
the_sz 7:dc29f6647486 18
the_sz 7:dc29f6647486 19 #define CLOCK_COLOR_BG ((uint32_t)0xFF000000)
the_sz 7:dc29f6647486 20 #define CLOCK_COLOR_FG ((uint32_t)0xFF707070)
the_sz 2:80026d18fcf3 21
the_sz 9:fe2c9b3a312b 22 #define SLIDESHOW_COLOR_BG ((uint32_t)0xFF000000)
the_sz 9:fe2c9b3a312b 23 #define SLIDESHOW_COLOR_FG ((uint32_t)0xFF707070)
the_sz 12:a89096944f20 24 #define SLIDESHOW_TRANSPARENCY 128
the_sz 12:a89096944f20 25 #define SLIDESHOW_FADE_STEP 5
the_sz 12:a89096944f20 26 #define SLIDESHOW_TIMEOUT 15
the_sz 9:fe2c9b3a312b 27
the_sz 7:dc29f6647486 28 #define BUTTON_WIDTH 100
the_sz 7:dc29f6647486 29 #define BUTTON_HEIGHT 60
the_sz 7:dc29f6647486 30 #define BUTTON_SMALL_WIDTH 50
the_sz 7:dc29f6647486 31 #define BUTTON_SMALL_HEIGHT 40
the_sz 7:dc29f6647486 32 #define BUTTON_COLOR_BG ((uint32_t)0x00000000)
the_sz 7:dc29f6647486 33 #define BUTTON_COLOR_FG CLIENT_COLOR_FG
the_sz 7:dc29f6647486 34 #define BUTTON_COLOR_BG_START 0x0C2696
the_sz 7:dc29f6647486 35 #define BUTTON_COLOR_BG_END 0x07185E
the_sz 7:dc29f6647486 36 #define BUTTON_COLOR_BG_START_INACTIVE 0x515151
the_sz 7:dc29f6647486 37 #define BUTTON_COLOR_BG_END_INACTIVE 0x333333
the_sz 2:80026d18fcf3 38
the_sz 7:dc29f6647486 39 #define COLOR_BG ((uint32_t)0xFF000000)
the_sz 7:dc29f6647486 40
the_sz 7:dc29f6647486 41 #define MAX_BOXES_PER_LINE 3
the_sz 7:dc29f6647486 42 #define BOX_SPACING 10
the_sz 7:dc29f6647486 43 #define BOX_TEXT_SPACING 10
the_sz 7:dc29f6647486 44 #define BOX_COLOR_BG BUTTON_COLOR_BG
the_sz 7:dc29f6647486 45 #define BOX_COLOR_FG CLIENT_COLOR_FG
the_sz 7:dc29f6647486 46 #define BOX_COLOR_BG_START BUTTON_COLOR_BG_START
the_sz 7:dc29f6647486 47 #define BOX_COLOR_BG_END BUTTON_COLOR_BG_END
the_sz 3:ecf7f1f8d749 48
the_sz 7:dc29f6647486 49 LCD_DISCO_F746NG uiLcd;
the_sz 7:dc29f6647486 50 TS_DISCO_F746NG uiTs;
the_sz 7:dc29f6647486 51 uint16_t uiLastTouchX;
the_sz 7:dc29f6647486 52 uint16_t uiLastTouchY;
the_sz 9:fe2c9b3a312b 53 int lastSlideshowTick=0;
the_sz 7:dc29f6647486 54 UI_STRUCT *uiCurrent=NULL;
the_sz 7:dc29f6647486 55 UI_STRUCT uiClock;
the_sz 7:dc29f6647486 56 UI_STRUCT uiClockInWords;
the_sz 7:dc29f6647486 57 UI_STRUCT uiColorTest;
the_sz 7:dc29f6647486 58 UI_STRUCT uiWakeup;
the_sz 9:fe2c9b3a312b 59 UI_STRUCT uiSlideshow;
the_sz 7:dc29f6647486 60 UI_STRUCT uiMain;
the_sz 7:dc29f6647486 61 static UI_BOX_LIST_ITEM_STRUCT uiMainItems[]=
the_sz 3:ecf7f1f8d749 62 {
the_sz 12:a89096944f20 63 { "Clock", ic_query_builder_white_48dp_1x }, { "Clock\nWith Words", ic_query_builder_white_48dp_1x }, { "Slideshow", ic_slideshow_white_48dp_1x }, { "Adjust\nTimers", ic_notifications_none_white_48dp_1x }, { "Adjust\nClock", ic_settings_white_48dp_1x }, { "Lights\nOn", ic_visibility_white_48dp_1x }, { "Lights\nOff", ic_visibility_off_white_48dp_1x }, { "My Color", ic_equalizer_white_48dp_1x }
the_sz 3:ecf7f1f8d749 64 };
the_sz 2:80026d18fcf3 65
the_sz 2:80026d18fcf3 66 //
the_sz 2:80026d18fcf3 67 // helper function
the_sz 2:80026d18fcf3 68 //
the_sz 2:80026d18fcf3 69 void UI_ShowClearClientRect(void)
the_sz 2:80026d18fcf3 70 {
the_sz 2:80026d18fcf3 71 uiLcd.SetTextColor(CLIENT_COLOR_BG);
the_sz 5:13c70bcde7f6 72 uiLcd.FillRect(0,HEADER_HEIGHT,uiLcd.GetXSize(),uiLcd.GetYSize()-HEADER_HEIGHT);
the_sz 2:80026d18fcf3 73 }
the_sz 2:80026d18fcf3 74
the_sz 3:ecf7f1f8d749 75 void UI_ShowDisplayText(int16_t x,int16_t y,char *text)
the_sz 3:ecf7f1f8d749 76 {
the_sz 3:ecf7f1f8d749 77 int16_t xStart;
the_sz 3:ecf7f1f8d749 78 int16_t charWidth;
the_sz 3:ecf7f1f8d749 79 int16_t charHeight;
the_sz 3:ecf7f1f8d749 80
the_sz 3:ecf7f1f8d749 81 xStart=x;
the_sz 3:ecf7f1f8d749 82 charHeight=uiLcd.GetFont()->Height+3;
the_sz 3:ecf7f1f8d749 83 charWidth=uiLcd.GetFont()->Width;
the_sz 3:ecf7f1f8d749 84
the_sz 3:ecf7f1f8d749 85 while ((*text)!='\0')
the_sz 3:ecf7f1f8d749 86 {
the_sz 3:ecf7f1f8d749 87 if ((*text)=='\n')
the_sz 3:ecf7f1f8d749 88 {
the_sz 3:ecf7f1f8d749 89 y+=charHeight;
the_sz 3:ecf7f1f8d749 90 x=xStart;
the_sz 3:ecf7f1f8d749 91 }
the_sz 3:ecf7f1f8d749 92 else
the_sz 3:ecf7f1f8d749 93 {
the_sz 3:ecf7f1f8d749 94 uiLcd.DisplayChar(x,y,*text);
the_sz 3:ecf7f1f8d749 95 x+=charWidth;
the_sz 3:ecf7f1f8d749 96 }
the_sz 3:ecf7f1f8d749 97
the_sz 3:ecf7f1f8d749 98 text++;
the_sz 3:ecf7f1f8d749 99 }
the_sz 3:ecf7f1f8d749 100 }
the_sz 5:13c70bcde7f6 101
the_sz 5:13c70bcde7f6 102 void UI_ShowDisplayTextCenter(int16_t x,int16_t y,int16_t width,int16_t height,char *text)
the_sz 5:13c70bcde7f6 103 {
the_sz 5:13c70bcde7f6 104 int16_t charWidth;
the_sz 5:13c70bcde7f6 105 int16_t charHeight;
the_sz 5:13c70bcde7f6 106
the_sz 5:13c70bcde7f6 107 charHeight=uiLcd.GetFont()->Height+3;
the_sz 5:13c70bcde7f6 108 charWidth=uiLcd.GetFont()->Width;
the_sz 5:13c70bcde7f6 109
the_sz 5:13c70bcde7f6 110 x+=((width-(strlen(text)*charWidth))/2);
the_sz 7:dc29f6647486 111 y+=(((height-charHeight)/2)+3); // +3 to have it more centered
the_sz 5:13c70bcde7f6 112
the_sz 5:13c70bcde7f6 113 while ((*text)!='\0')
the_sz 5:13c70bcde7f6 114 {
the_sz 5:13c70bcde7f6 115 uiLcd.DisplayChar(x,y,*text);
the_sz 5:13c70bcde7f6 116 x+=charWidth;
the_sz 5:13c70bcde7f6 117
the_sz 5:13c70bcde7f6 118 text++;
the_sz 5:13c70bcde7f6 119 }
the_sz 5:13c70bcde7f6 120 }
the_sz 5:13c70bcde7f6 121
the_sz 5:13c70bcde7f6 122 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 123 {
the_sz 5:13c70bcde7f6 124 float deltaRed;
the_sz 5:13c70bcde7f6 125 float deltaGreen;
the_sz 5:13c70bcde7f6 126 float deltaBlue;
the_sz 5:13c70bcde7f6 127 float red;
the_sz 5:13c70bcde7f6 128 float green;
the_sz 5:13c70bcde7f6 129 float blue;
the_sz 5:13c70bcde7f6 130 uint16_t offset;
the_sz 5:13c70bcde7f6 131 uint32_t color;
the_sz 5:13c70bcde7f6 132
the_sz 5:13c70bcde7f6 133 deltaRed=(float)((int32_t)(colorEnd & 0xFF) - (int32_t)(colorStart & 0xFF))/height;
the_sz 5:13c70bcde7f6 134 deltaGreen=(float)((int32_t)((colorEnd >> 8) & 0xFF) - (int32_t)((colorStart >> 8)& 0xFF))/height;
the_sz 5:13c70bcde7f6 135 deltaBlue=(float)((int32_t)((colorEnd >> 16) & 0xFF) - (int32_t)((colorStart >> 16)& 0xFF))/height;
the_sz 5:13c70bcde7f6 136
the_sz 5:13c70bcde7f6 137 red=colorStart & 0xFF;
the_sz 5:13c70bcde7f6 138 green=((colorStart >> 8)& 0xFF);
the_sz 5:13c70bcde7f6 139 blue=((colorStart >> 16)& 0xFF);
the_sz 5:13c70bcde7f6 140
the_sz 5:13c70bcde7f6 141 for (offset=0;offset<height;offset++)
the_sz 5:13c70bcde7f6 142 {
the_sz 5:13c70bcde7f6 143 color=(uint8_t)red | (((uint8_t)green)<<8) | (((uint8_t)blue)<<16) | (((uint32_t)0xFF)<<24);
the_sz 5:13c70bcde7f6 144 uiLcd.SetTextColor(color);
the_sz 5:13c70bcde7f6 145
the_sz 5:13c70bcde7f6 146 if ((offset==0) || (offset==(height-1)))
the_sz 5:13c70bcde7f6 147 uiLcd.DrawHLine(x+1,y+offset,width-2);
the_sz 5:13c70bcde7f6 148 else
the_sz 5:13c70bcde7f6 149 uiLcd.DrawHLine(x,y+offset,width);
the_sz 5:13c70bcde7f6 150
the_sz 5:13c70bcde7f6 151 red+=deltaRed;
the_sz 5:13c70bcde7f6 152 green+=deltaGreen;
the_sz 5:13c70bcde7f6 153 blue+=deltaBlue;
the_sz 5:13c70bcde7f6 154 }
the_sz 5:13c70bcde7f6 155 }
the_sz 5:13c70bcde7f6 156
the_sz 7:dc29f6647486 157 void UI_ShowDrawButtonEx(uint16_t x,uint16_t y,uint16_t width,uint16_t height,char *text,bool active)
the_sz 5:13c70bcde7f6 158 {
the_sz 5:13c70bcde7f6 159 // paint button background
the_sz 7:dc29f6647486 160 if (active==true)
the_sz 7:dc29f6647486 161 UI_ShowDrawGradientButton(x,y,width,height,BUTTON_COLOR_BG_START,BUTTON_COLOR_BG_END);
the_sz 7:dc29f6647486 162 else
the_sz 7:dc29f6647486 163 UI_ShowDrawGradientButton(x,y,width,height,BUTTON_COLOR_BG_START_INACTIVE,BUTTON_COLOR_BG_END_INACTIVE);
the_sz 5:13c70bcde7f6 164
the_sz 5:13c70bcde7f6 165 // paint button text
the_sz 5:13c70bcde7f6 166 uiLcd.SetFont(&display_font_12x22);
the_sz 5:13c70bcde7f6 167 uiLcd.SetBackColor(BUTTON_COLOR_BG);
the_sz 5:13c70bcde7f6 168 uiLcd.SetTextColor(BUTTON_COLOR_FG);
the_sz 5:13c70bcde7f6 169
the_sz 7:dc29f6647486 170 UI_ShowDisplayTextCenter(x,y,width,height,text);
the_sz 7:dc29f6647486 171 }
the_sz 7:dc29f6647486 172
the_sz 7:dc29f6647486 173 void UI_ShowDrawButton(uint16_t x,uint16_t y,uint16_t width,uint16_t height,char *text)
the_sz 7:dc29f6647486 174 {
the_sz 7:dc29f6647486 175 UI_ShowDrawButtonEx(x,y,width,height,text,true);
the_sz 5:13c70bcde7f6 176 }
the_sz 5:13c70bcde7f6 177
the_sz 6:aa51cc3b9f90 178 void UI_DrawBitmapWithAlpha(uint32_t Xpos,uint32_t Ypos,uint8_t *pbmp)
the_sz 6:aa51cc3b9f90 179 {
the_sz 6:aa51cc3b9f90 180 uint32_t index = 0, width = 0, height = 0, bit_pixel = 0;
the_sz 6:aa51cc3b9f90 181 uint32_t x;
the_sz 6:aa51cc3b9f90 182 uint32_t part;
the_sz 6:aa51cc3b9f90 183 uint32_t color[3];
the_sz 6:aa51cc3b9f90 184 uint32_t value;
the_sz 6:aa51cc3b9f90 185
the_sz 6:aa51cc3b9f90 186 /* Get bitmap data address offset */
the_sz 6:aa51cc3b9f90 187 index = *(__IO uint16_t *) (pbmp + 10);
the_sz 6:aa51cc3b9f90 188 index |= (*(__IO uint16_t *) (pbmp + 12)) << 16;
the_sz 6:aa51cc3b9f90 189
the_sz 6:aa51cc3b9f90 190 /* Read bitmap width */
the_sz 6:aa51cc3b9f90 191 width = *(uint16_t *) (pbmp + 18);
the_sz 6:aa51cc3b9f90 192 width |= (*(uint16_t *) (pbmp + 20)) << 16;
the_sz 6:aa51cc3b9f90 193
the_sz 6:aa51cc3b9f90 194 /* Read bitmap height */
the_sz 6:aa51cc3b9f90 195 height = *(uint16_t *) (pbmp + 22);
the_sz 6:aa51cc3b9f90 196 height |= (*(uint16_t *) (pbmp + 24)) << 16;
the_sz 6:aa51cc3b9f90 197
the_sz 6:aa51cc3b9f90 198 /* Read bit/pixel */
the_sz 6:aa51cc3b9f90 199 bit_pixel = *(uint16_t *) (pbmp + 28);
the_sz 6:aa51cc3b9f90 200
the_sz 6:aa51cc3b9f90 201 /* Get the layer pixel format */
the_sz 6:aa51cc3b9f90 202 if ((bit_pixel/8) != 4)
the_sz 6:aa51cc3b9f90 203 {
the_sz 6:aa51cc3b9f90 204 DPrintf("UI_DrawBitmapWithAlpha: This is no alpha picture.\r\n");
the_sz 6:aa51cc3b9f90 205 return;
the_sz 6:aa51cc3b9f90 206 }
the_sz 6:aa51cc3b9f90 207
the_sz 6:aa51cc3b9f90 208 /* Bypass the bitmap header */
the_sz 6:aa51cc3b9f90 209 pbmp += (index + (width * (height - 1) * (bit_pixel/8)));
the_sz 6:aa51cc3b9f90 210
the_sz 6:aa51cc3b9f90 211 for(index=0; index < height; index++)
the_sz 6:aa51cc3b9f90 212 {
the_sz 6:aa51cc3b9f90 213 for (x=0;x<width;x++)
the_sz 6:aa51cc3b9f90 214 {
the_sz 6:aa51cc3b9f90 215 value=uiLcd.ReadPixel(Xpos+x,Ypos+index);
the_sz 6:aa51cc3b9f90 216
the_sz 6:aa51cc3b9f90 217 color[0]=value & 0xFF;
the_sz 6:aa51cc3b9f90 218 color[1]=(value >> 8) & 0xFF;
the_sz 6:aa51cc3b9f90 219 color[2]=(value >> 16) & 0xFF;
the_sz 6:aa51cc3b9f90 220
the_sz 6:aa51cc3b9f90 221 if (pbmp[3]>0)
the_sz 6:aa51cc3b9f90 222 {
the_sz 6:aa51cc3b9f90 223 // add red
the_sz 6:aa51cc3b9f90 224 part=(color[0]+(pbmp[0]*pbmp[3]/255));
the_sz 6:aa51cc3b9f90 225 if (part>255)
the_sz 6:aa51cc3b9f90 226 part=255;
the_sz 6:aa51cc3b9f90 227 color[0]=part;
the_sz 6:aa51cc3b9f90 228
the_sz 6:aa51cc3b9f90 229 // add green
the_sz 6:aa51cc3b9f90 230 part=(color[1]+(pbmp[1]*pbmp[3]/255));
the_sz 6:aa51cc3b9f90 231 if (part>255)
the_sz 6:aa51cc3b9f90 232 part=255;
the_sz 6:aa51cc3b9f90 233 color[1]=part;
the_sz 6:aa51cc3b9f90 234
the_sz 6:aa51cc3b9f90 235 // add blue
the_sz 6:aa51cc3b9f90 236 part=(color[2]+(pbmp[2]*pbmp[3]/255));
the_sz 6:aa51cc3b9f90 237 if (part>255)
the_sz 6:aa51cc3b9f90 238 part=255;
the_sz 6:aa51cc3b9f90 239 color[2]=part;
the_sz 6:aa51cc3b9f90 240
the_sz 6:aa51cc3b9f90 241 // draw pixel
the_sz 6:aa51cc3b9f90 242 uiLcd.DrawPixel(Xpos+x,Ypos+index,color[0] | (color[1] << 8) | (color[2] << 16) | ((uint32_t)0xFF << 24));
the_sz 6:aa51cc3b9f90 243 }
the_sz 6:aa51cc3b9f90 244
the_sz 6:aa51cc3b9f90 245 pbmp+=4;
the_sz 6:aa51cc3b9f90 246 }
the_sz 6:aa51cc3b9f90 247
the_sz 6:aa51cc3b9f90 248 /* Increment the source and destination buffers */
the_sz 6:aa51cc3b9f90 249 pbmp -= 2*(width*(bit_pixel/8));
the_sz 6:aa51cc3b9f90 250 }
the_sz 6:aa51cc3b9f90 251 }
the_sz 6:aa51cc3b9f90 252
the_sz 2:80026d18fcf3 253 //
the_sz 2:80026d18fcf3 254 // box list
the_sz 2:80026d18fcf3 255 //
the_sz 2:80026d18fcf3 256 void UI_ShowBoxList(bool initial)
the_sz 2:80026d18fcf3 257 {
the_sz 2:80026d18fcf3 258 if (initial==true)
the_sz 2:80026d18fcf3 259 {
the_sz 3:ecf7f1f8d749 260 int8_t lines;
the_sz 3:ecf7f1f8d749 261 int8_t columns;
the_sz 3:ecf7f1f8d749 262 int8_t box;
the_sz 3:ecf7f1f8d749 263 int16_t width;
the_sz 3:ecf7f1f8d749 264 int16_t height;
the_sz 3:ecf7f1f8d749 265 int16_t startX;
the_sz 3:ecf7f1f8d749 266 int16_t startY;
the_sz 3:ecf7f1f8d749 267
the_sz 2:80026d18fcf3 268 // fill background
the_sz 2:80026d18fcf3 269 UI_ShowClearClientRect();
the_sz 3:ecf7f1f8d749 270
the_sz 3:ecf7f1f8d749 271 // paint boxes
the_sz 3:ecf7f1f8d749 272 if (uiCurrent->data.boxList.count<=MAX_BOXES_PER_LINE)
the_sz 3:ecf7f1f8d749 273 lines=1;
the_sz 3:ecf7f1f8d749 274 else
the_sz 3:ecf7f1f8d749 275 lines=2;
the_sz 3:ecf7f1f8d749 276
the_sz 3:ecf7f1f8d749 277 columns=((uiCurrent->data.boxList.count + (lines-1)) / lines);
the_sz 3:ecf7f1f8d749 278
the_sz 3:ecf7f1f8d749 279 width=(uiLcd.GetXSize() - BOX_SPACING) / columns;
the_sz 3:ecf7f1f8d749 280 height=(uiLcd.GetYSize() - HEADER_HEIGHT - BOX_SPACING) / lines;
the_sz 3:ecf7f1f8d749 281
the_sz 3:ecf7f1f8d749 282 for (box=0;box<uiCurrent->data.boxList.count;box++)
the_sz 3:ecf7f1f8d749 283 {
the_sz 3:ecf7f1f8d749 284 startX=BOX_SPACING+(width*(box % columns));
the_sz 3:ecf7f1f8d749 285 startY=HEADER_HEIGHT+BOX_SPACING+(height*(box/columns));
the_sz 3:ecf7f1f8d749 286
the_sz 3:ecf7f1f8d749 287 // paint box background
the_sz 5:13c70bcde7f6 288 UI_ShowDrawGradientButton(startX,startY,width-BOX_SPACING,height-BOX_SPACING,BOX_COLOR_BG_START,BOX_COLOR_BG_END);
the_sz 5:13c70bcde7f6 289
the_sz 3:ecf7f1f8d749 290 // paint box text
the_sz 3:ecf7f1f8d749 291 uiLcd.SetFont(&display_font_12x22);
the_sz 3:ecf7f1f8d749 292 uiLcd.SetBackColor(BOX_COLOR_BG);
the_sz 3:ecf7f1f8d749 293 uiLcd.SetTextColor(BOX_COLOR_FG);
the_sz 3:ecf7f1f8d749 294 UI_ShowDisplayText(startX+BOX_TEXT_SPACING,startY+BOX_TEXT_SPACING,uiCurrent->data.boxList.items[box].name);
the_sz 6:aa51cc3b9f90 295
the_sz 6:aa51cc3b9f90 296 // draw icon
the_sz 6:aa51cc3b9f90 297 if (uiCurrent->data.boxList.items[box].image!=NULL)
the_sz 6:aa51cc3b9f90 298 UI_DrawBitmapWithAlpha(startX+width-BOX_SPACING-48,startY+height-BOX_SPACING-48,uiCurrent->data.boxList.items[box].image);
the_sz 3:ecf7f1f8d749 299 }
the_sz 5:13c70bcde7f6 300 }
the_sz 2:80026d18fcf3 301 }
the_sz 2:80026d18fcf3 302
the_sz 2:80026d18fcf3 303 void UI_ClickBoxList(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 304 {
the_sz 3:ecf7f1f8d749 305 int8_t lines;
the_sz 3:ecf7f1f8d749 306 int8_t columns;
the_sz 3:ecf7f1f8d749 307 int8_t box;
the_sz 3:ecf7f1f8d749 308 int16_t width;
the_sz 3:ecf7f1f8d749 309 int16_t height;
the_sz 3:ecf7f1f8d749 310 int16_t startX;
the_sz 3:ecf7f1f8d749 311 int16_t startY;
the_sz 3:ecf7f1f8d749 312
the_sz 3:ecf7f1f8d749 313 // detect at which box was clicked
the_sz 3:ecf7f1f8d749 314 if (uiCurrent->data.boxList.count<=MAX_BOXES_PER_LINE)
the_sz 3:ecf7f1f8d749 315 lines=1;
the_sz 3:ecf7f1f8d749 316 else
the_sz 3:ecf7f1f8d749 317 lines=2;
the_sz 3:ecf7f1f8d749 318
the_sz 3:ecf7f1f8d749 319 columns=((uiCurrent->data.boxList.count + (lines-1)) / lines);
the_sz 3:ecf7f1f8d749 320
the_sz 3:ecf7f1f8d749 321 width=(uiLcd.GetXSize() - BOX_SPACING) / columns;
the_sz 3:ecf7f1f8d749 322 height=(uiLcd.GetYSize() - HEADER_HEIGHT - BOX_SPACING) / lines;
the_sz 3:ecf7f1f8d749 323
the_sz 3:ecf7f1f8d749 324 for (box=0;box<uiCurrent->data.boxList.count;box++)
the_sz 3:ecf7f1f8d749 325 {
the_sz 3:ecf7f1f8d749 326 startX=BOX_SPACING+(width*(box % columns));
the_sz 3:ecf7f1f8d749 327 startY=HEADER_HEIGHT+BOX_SPACING+(height*(box/columns));
the_sz 3:ecf7f1f8d749 328
the_sz 3:ecf7f1f8d749 329 if ( (x>=startX) && (x<(startX+width-BOX_SPACING))
the_sz 3:ecf7f1f8d749 330 &&
the_sz 3:ecf7f1f8d749 331 (y>=startY) && (y<(startY+height-BOX_SPACING))
the_sz 3:ecf7f1f8d749 332 )
the_sz 3:ecf7f1f8d749 333 {
the_sz 3:ecf7f1f8d749 334 uiCurrent->handler(UR_CLICK,box,uiCurrent);
the_sz 3:ecf7f1f8d749 335 break;
the_sz 3:ecf7f1f8d749 336 }
the_sz 3:ecf7f1f8d749 337 }
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 2:80026d18fcf3 347
the_sz 2:80026d18fcf3 348 if (initial==true)
the_sz 2:80026d18fcf3 349 {
the_sz 2:80026d18fcf3 350 // fill background
the_sz 2:80026d18fcf3 351 uiLcd.SetTextColor(CLOCK_COLOR_BG);
the_sz 5:13c70bcde7f6 352 uiLcd.FillRect(0,0,uiLcd.GetXSize(),uiLcd.GetYSize());
the_sz 2:80026d18fcf3 353 }
the_sz 2:80026d18fcf3 354
the_sz 2:80026d18fcf3 355 // show clock
the_sz 2:80026d18fcf3 356 uiLcd.SetFont(&display_font_12x22);
the_sz 2:80026d18fcf3 357 uiLcd.SetBackColor(CLOCK_COLOR_BG);
the_sz 2:80026d18fcf3 358 uiLcd.SetTextColor(CLOCK_COLOR_FG);
the_sz 12:a89096944f20 359 RTC_Get(&tmStruct);
the_sz 3:ecf7f1f8d749 360 snprintf(buffer,sizeof(buffer),"%u:%02u:%02u",tmStruct->tm_hour,tmStruct->tm_min,tmStruct->tm_sec);
the_sz 2:80026d18fcf3 361 uiLcd.DisplayStringAt(0,100,(uint8_t *)buffer,CENTER_MODE);
the_sz 2:80026d18fcf3 362 }
the_sz 2:80026d18fcf3 363
the_sz 2:80026d18fcf3 364 void UI_ClickClock(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 365 {
the_sz 2:80026d18fcf3 366 // exit view
the_sz 3:ecf7f1f8d749 367 UI_Show(&uiMain);
the_sz 2:80026d18fcf3 368 }
the_sz 2:80026d18fcf3 369
the_sz 2:80026d18fcf3 370 //
the_sz 2:80026d18fcf3 371 // clock in words
the_sz 2:80026d18fcf3 372 //
the_sz 2:80026d18fcf3 373 void UI_ShowClockInWords(bool initial)
the_sz 2:80026d18fcf3 374 {
the_sz 2:80026d18fcf3 375 if (initial==true)
the_sz 2:80026d18fcf3 376 {
the_sz 2:80026d18fcf3 377 // fill background
the_sz 2:80026d18fcf3 378 UI_ShowClearClientRect();
the_sz 2:80026d18fcf3 379 }
the_sz 2:80026d18fcf3 380
the_sz 2:80026d18fcf3 381 // show clock in words
the_sz 2:80026d18fcf3 382 uiLcd.SetFont(&display_font_12x22);
the_sz 2:80026d18fcf3 383 uiLcd.SetBackColor(CLIENT_COLOR_BG);
the_sz 2:80026d18fcf3 384 uiLcd.SetTextColor(CLIENT_COLOR_FG);
the_sz 2:80026d18fcf3 385 uiLcd.DisplayStringAt(5,30,(uint8_t *)"UM F\x9ANF ZEHN VIERTEL HALB",LEFT_MODE);
the_sz 2:80026d18fcf3 386 uiLcd.DisplayStringAt(5,60,(uint8_t *)"NACH VOR",LEFT_MODE);
the_sz 2:80026d18fcf3 387 uiLcd.DisplayStringAt(5,90,(uint8_t *)"EINS ZWEI DREI VIER",LEFT_MODE);
the_sz 2:80026d18fcf3 388 uiLcd.DisplayStringAt(5,120,(uint8_t *)"F\x9ANF SECHS SIEBEN ACHT",LEFT_MODE);
the_sz 2:80026d18fcf3 389 uiLcd.DisplayStringAt(5,150,(uint8_t *)"NEUN ZEHN ELF ZW\x99LF",LEFT_MODE);
the_sz 2:80026d18fcf3 390
the_sz 2:80026d18fcf3 391 // draw charset
the_sz 2:80026d18fcf3 392 /*
the_sz 2:80026d18fcf3 393 int x;
the_sz 2:80026d18fcf3 394 for (x=0x80;x<=0xFF;x++)
the_sz 2:80026d18fcf3 395 {
the_sz 2:80026d18fcf3 396 uiLcd.DisplayChar(1+(((x-0x80) % 16)*14),30+(((x-0x80)/16)*20),x);
the_sz 2:80026d18fcf3 397 }
the_sz 2:80026d18fcf3 398 */
the_sz 2:80026d18fcf3 399 }
the_sz 2:80026d18fcf3 400
the_sz 2:80026d18fcf3 401 void UI_ClickClockInWords(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 402 {
the_sz 2:80026d18fcf3 403 // exit view
the_sz 3:ecf7f1f8d749 404 UI_Show(&uiMain);
the_sz 2:80026d18fcf3 405 }
the_sz 2:80026d18fcf3 406
the_sz 2:80026d18fcf3 407 //
the_sz 9:fe2c9b3a312b 408 // slideshow
the_sz 9:fe2c9b3a312b 409 //
the_sz 12:a89096944f20 410 void UI_ShowSlideshowFade(uint8_t from,uint8_t to)
the_sz 12:a89096944f20 411 {
the_sz 12:a89096944f20 412 if (from<to)
the_sz 12:a89096944f20 413 {
the_sz 12:a89096944f20 414 while (from<to)
the_sz 12:a89096944f20 415 {
the_sz 12:a89096944f20 416 uiLcd.SetTransparency(0,from);
the_sz 12:a89096944f20 417
the_sz 12:a89096944f20 418 wait_ms(30);
the_sz 12:a89096944f20 419
the_sz 12:a89096944f20 420 if ((to-from)<SLIDESHOW_FADE_STEP)
the_sz 12:a89096944f20 421 break;
the_sz 12:a89096944f20 422
the_sz 12:a89096944f20 423 from+=SLIDESHOW_FADE_STEP;
the_sz 12:a89096944f20 424 }
the_sz 12:a89096944f20 425 }
the_sz 12:a89096944f20 426 else
the_sz 12:a89096944f20 427 {
the_sz 12:a89096944f20 428 while (from>to)
the_sz 12:a89096944f20 429 {
the_sz 12:a89096944f20 430 uiLcd.SetTransparency(0,from);
the_sz 12:a89096944f20 431
the_sz 12:a89096944f20 432 wait_ms(30);
the_sz 12:a89096944f20 433
the_sz 12:a89096944f20 434 if ((from-to)<SLIDESHOW_FADE_STEP)
the_sz 12:a89096944f20 435 break;
the_sz 12:a89096944f20 436
the_sz 12:a89096944f20 437 from-=SLIDESHOW_FADE_STEP;
the_sz 12:a89096944f20 438 }
the_sz 12:a89096944f20 439 }
the_sz 12:a89096944f20 440
the_sz 12:a89096944f20 441 uiLcd.SetTransparency(0,to);
the_sz 12:a89096944f20 442 }
the_sz 12:a89096944f20 443
the_sz 9:fe2c9b3a312b 444 void UI_ShowSlideshow(bool initial)
the_sz 9:fe2c9b3a312b 445 {
the_sz 9:fe2c9b3a312b 446 char buffer[100];
the_sz 9:fe2c9b3a312b 447 struct tm *tmStruct;
the_sz 9:fe2c9b3a312b 448
the_sz 12:a89096944f20 449 RTC_Get(&tmStruct);
the_sz 9:fe2c9b3a312b 450
the_sz 12:a89096944f20 451 if (((tmStruct->tm_sec / SLIDESHOW_TIMEOUT)!=lastSlideshowTick) || (initial==true))
the_sz 9:fe2c9b3a312b 452 {
the_sz 12:a89096944f20 453 lastSlideshowTick=(tmStruct->tm_sec / SLIDESHOW_TIMEOUT);
the_sz 9:fe2c9b3a312b 454
the_sz 12:a89096944f20 455 // fill background with transparent color
the_sz 12:a89096944f20 456 uiLcd.SetTextColor(0x00000000);
the_sz 9:fe2c9b3a312b 457 uiLcd.FillRect(0,0,uiLcd.GetXSize(),uiLcd.GetYSize());
the_sz 12:a89096944f20 458
the_sz 9:fe2c9b3a312b 459 // show clock
the_sz 9:fe2c9b3a312b 460 uiLcd.SetFont(&display_font_12x22);
the_sz 9:fe2c9b3a312b 461 uiLcd.SetBackColor(0x00000000);
the_sz 9:fe2c9b3a312b 462 uiLcd.SetTextColor(SLIDESHOW_COLOR_FG);
the_sz 9:fe2c9b3a312b 463 snprintf(buffer,sizeof(buffer),"%u:%02u",tmStruct->tm_hour,tmStruct->tm_min);
the_sz 9:fe2c9b3a312b 464 uiLcd.DisplayStringAt(30,220,(uint8_t *)buffer,RIGHT_MODE);
the_sz 12:a89096944f20 465
the_sz 12:a89096944f20 466 // hide picture layer
the_sz 12:a89096944f20 467 if (initial==true)
the_sz 12:a89096944f20 468 uiLcd.SetTransparency(0,0);
the_sz 12:a89096944f20 469 else
the_sz 12:a89096944f20 470 UI_ShowSlideshowFade(SLIDESHOW_TRANSPARENCY,0);
the_sz 12:a89096944f20 471 uiLcd.SelectLayer(0);
the_sz 12:a89096944f20 472 // clear old picture
the_sz 12:a89096944f20 473 uiLcd.Clear(LCD_COLOR_BLACK);
the_sz 12:a89096944f20 474
the_sz 12:a89096944f20 475 // load picture
the_sz 12:a89096944f20 476 SD_ShowRandomPicture();
the_sz 12:a89096944f20 477
the_sz 12:a89096944f20 478 // show new picture
the_sz 12:a89096944f20 479 if (initial==true)
the_sz 12:a89096944f20 480 uiLcd.SetLayerVisible(0,ENABLE);
the_sz 12:a89096944f20 481 UI_ShowSlideshowFade(0,SLIDESHOW_TRANSPARENCY);
the_sz 12:a89096944f20 482 uiLcd.SelectLayer(1);
the_sz 9:fe2c9b3a312b 483 }
the_sz 9:fe2c9b3a312b 484 }
the_sz 9:fe2c9b3a312b 485
the_sz 9:fe2c9b3a312b 486 void UI_ClickSlideshow(uint16_t x,uint16_t y)
the_sz 9:fe2c9b3a312b 487 {
the_sz 9:fe2c9b3a312b 488 // exit view
the_sz 12:a89096944f20 489 uiLcd.SetLayerVisible(0,DISABLE);
the_sz 9:fe2c9b3a312b 490 UI_Show(&uiMain);
the_sz 9:fe2c9b3a312b 491 }
the_sz 9:fe2c9b3a312b 492
the_sz 9:fe2c9b3a312b 493 //
the_sz 5:13c70bcde7f6 494 // value adjust
the_sz 2:80026d18fcf3 495 //
the_sz 5:13c70bcde7f6 496 void UI_ShowValueAdjust(bool initial)
the_sz 2:80026d18fcf3 497 {
the_sz 5:13c70bcde7f6 498 char buffer[20];
the_sz 5:13c70bcde7f6 499
the_sz 2:80026d18fcf3 500 if (initial==true)
the_sz 2:80026d18fcf3 501 {
the_sz 2:80026d18fcf3 502 // fill background
the_sz 2:80026d18fcf3 503 UI_ShowClearClientRect();
the_sz 5:13c70bcde7f6 504
the_sz 7:dc29f6647486 505 if (uiCurrent->data.valueAdjust.count==10)
the_sz 5:13c70bcde7f6 506 {
the_sz 7:dc29f6647486 507 UI_ShowDrawButton(60+(0*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+");
the_sz 7:dc29f6647486 508 UI_ShowDrawButton(205+(0*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+");
the_sz 7:dc29f6647486 509 UI_ShowDrawButton(205+(1*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+");
the_sz 7:dc29f6647486 510
the_sz 12:a89096944f20 511 if (uiCurrent->data.valueAdjust.isTime==true)
the_sz 12:a89096944f20 512 UI_ShowDisplayTextCenter(132,92,BUTTON_WIDTH,BUTTON_HEIGHT,":");
the_sz 5:13c70bcde7f6 513
the_sz 7:dc29f6647486 514 UI_ShowDrawButton(60+(0*(BUTTON_WIDTH+15)),140,BUTTON_WIDTH,BUTTON_HEIGHT,"-");
the_sz 7:dc29f6647486 515 UI_ShowDrawButton(205+(0*(BUTTON_WIDTH+15)),140,BUTTON_WIDTH,BUTTON_HEIGHT,"-");
the_sz 7:dc29f6647486 516 UI_ShowDrawButton(205+(1*(BUTTON_WIDTH+15)),140,BUTTON_WIDTH,BUTTON_HEIGHT,"-");
the_sz 7:dc29f6647486 517 }
the_sz 7:dc29f6647486 518 else if (uiCurrent->data.valueAdjust.count==4)
the_sz 7:dc29f6647486 519 {
the_sz 7:dc29f6647486 520 UI_ShowDrawButton(17+(0*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+");
the_sz 7:dc29f6647486 521 UI_ShowDrawButton(17+(1*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+");
the_sz 7:dc29f6647486 522 UI_ShowDrawButton(17+(2*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+");
the_sz 7:dc29f6647486 523 UI_ShowDrawButton(17+(3*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+");
the_sz 7:dc29f6647486 524
the_sz 7:dc29f6647486 525 UI_ShowDrawButton(17+(0*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-");
the_sz 7:dc29f6647486 526 UI_ShowDrawButton(17+(1*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-");
the_sz 7:dc29f6647486 527 UI_ShowDrawButton(17+(2*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-");
the_sz 7:dc29f6647486 528 UI_ShowDrawButton(17+(3*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-");
the_sz 5:13c70bcde7f6 529 }
the_sz 12:a89096944f20 530 else if (uiCurrent->data.valueAdjust.count==3)
the_sz 12:a89096944f20 531 {
the_sz 12:a89096944f20 532 if (uiCurrent->data.valueAdjust.isTime==true)
the_sz 12:a89096944f20 533 {
the_sz 12:a89096944f20 534 UI_ShowDrawButton(60+(0*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+");
the_sz 12:a89096944f20 535 UI_ShowDrawButton(205+(0*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+");
the_sz 12:a89096944f20 536 UI_ShowDrawButton(205+(1*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+");
the_sz 12:a89096944f20 537
the_sz 12:a89096944f20 538 UI_ShowDisplayTextCenter(132,125,BUTTON_WIDTH,BUTTON_HEIGHT,":");
the_sz 12:a89096944f20 539
the_sz 12:a89096944f20 540 UI_ShowDrawButton(60+(0*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-");
the_sz 12:a89096944f20 541 UI_ShowDrawButton(205+(0*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-");
the_sz 12:a89096944f20 542 UI_ShowDrawButton(205+(1*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-");
the_sz 12:a89096944f20 543 }
the_sz 12:a89096944f20 544 else
the_sz 12:a89096944f20 545 {
the_sz 12:a89096944f20 546 UI_ShowDrawButton(74+(0*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+");
the_sz 12:a89096944f20 547 UI_ShowDrawButton(74+(1*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+");
the_sz 12:a89096944f20 548 UI_ShowDrawButton(74+(2*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+");
the_sz 12:a89096944f20 549
the_sz 12:a89096944f20 550 UI_ShowDisplayTextCenter(130,125,BUTTON_WIDTH,BUTTON_HEIGHT,".");
the_sz 12:a89096944f20 551 UI_ShowDisplayTextCenter(246,125,BUTTON_WIDTH,BUTTON_HEIGHT,".");
the_sz 12:a89096944f20 552
the_sz 12:a89096944f20 553 UI_ShowDrawButton(74+(0*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-");
the_sz 12:a89096944f20 554 UI_ShowDrawButton(74+(1*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-");
the_sz 12:a89096944f20 555 UI_ShowDrawButton(74+(2*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-");
the_sz 12:a89096944f20 556 }
the_sz 12:a89096944f20 557 }
the_sz 5:13c70bcde7f6 558 }
the_sz 5:13c70bcde7f6 559
the_sz 5:13c70bcde7f6 560 uiLcd.SetBackColor(CLIENT_COLOR_BG);
the_sz 5:13c70bcde7f6 561 uiLcd.SetTextColor(CLIENT_COLOR_FG);
the_sz 5:13c70bcde7f6 562
the_sz 7:dc29f6647486 563 if (uiCurrent->data.valueAdjust.count==10)
the_sz 7:dc29f6647486 564 {
the_sz 7:dc29f6647486 565 snprintf(buffer,sizeof(buffer),"% 2u",uiCurrent->data.valueAdjust.values[0]);
the_sz 7:dc29f6647486 566 UI_ShowDisplayTextCenter(60+(0*(BUTTON_WIDTH+15)),92,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 7:dc29f6647486 567
the_sz 7:dc29f6647486 568 snprintf(buffer,sizeof(buffer),"%u",uiCurrent->data.valueAdjust.values[1]);
the_sz 7:dc29f6647486 569 UI_ShowDisplayTextCenter(205+(0*(BUTTON_WIDTH+15)),92,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 7:dc29f6647486 570
the_sz 7:dc29f6647486 571 snprintf(buffer,sizeof(buffer),"%u",uiCurrent->data.valueAdjust.values[2]);
the_sz 7:dc29f6647486 572 UI_ShowDisplayTextCenter(205+(1*(BUTTON_WIDTH+15)),92,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 7:dc29f6647486 573
the_sz 7:dc29f6647486 574 if (uiCurrent->data.valueAdjust.values[3]==1)
the_sz 7:dc29f6647486 575 UI_ShowDrawButton(17+(0*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Mo");
the_sz 7:dc29f6647486 576 else
the_sz 7:dc29f6647486 577 UI_ShowDrawButtonEx(17+(0*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Mo",false);
the_sz 7:dc29f6647486 578
the_sz 7:dc29f6647486 579 if (uiCurrent->data.valueAdjust.values[4]==1)
the_sz 7:dc29f6647486 580 UI_ShowDrawButton(17+(1*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Di");
the_sz 7:dc29f6647486 581 else
the_sz 7:dc29f6647486 582 UI_ShowDrawButtonEx(17+(1*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Di",false);
the_sz 7:dc29f6647486 583
the_sz 7:dc29f6647486 584 if (uiCurrent->data.valueAdjust.values[5]==1)
the_sz 7:dc29f6647486 585 UI_ShowDrawButton(17+(2*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Mi");
the_sz 7:dc29f6647486 586 else
the_sz 7:dc29f6647486 587 UI_ShowDrawButtonEx(17+(2*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Mi",false);
the_sz 7:dc29f6647486 588
the_sz 7:dc29f6647486 589 if (uiCurrent->data.valueAdjust.values[6]==1)
the_sz 7:dc29f6647486 590 UI_ShowDrawButton(17+(3*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Do");
the_sz 7:dc29f6647486 591 else
the_sz 7:dc29f6647486 592 UI_ShowDrawButtonEx(17+(3*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Do",false);
the_sz 7:dc29f6647486 593
the_sz 7:dc29f6647486 594 if (uiCurrent->data.valueAdjust.values[7]==1)
the_sz 7:dc29f6647486 595 UI_ShowDrawButton(17+(4*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Fr");
the_sz 7:dc29f6647486 596 else
the_sz 7:dc29f6647486 597 UI_ShowDrawButtonEx(17+(4*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Fr",false);
the_sz 7:dc29f6647486 598
the_sz 7:dc29f6647486 599 if (uiCurrent->data.valueAdjust.values[8]==1)
the_sz 7:dc29f6647486 600 UI_ShowDrawButton(17+(5*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Sa");
the_sz 7:dc29f6647486 601 else
the_sz 7:dc29f6647486 602 UI_ShowDrawButtonEx(17+(5*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Sa",false);
the_sz 7:dc29f6647486 603
the_sz 7:dc29f6647486 604 if (uiCurrent->data.valueAdjust.values[9]==1)
the_sz 7:dc29f6647486 605 UI_ShowDrawButton(17+(6*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"So");
the_sz 7:dc29f6647486 606 else
the_sz 7:dc29f6647486 607 UI_ShowDrawButtonEx(17+(6*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"So",false);
the_sz 7:dc29f6647486 608 }
the_sz 7:dc29f6647486 609 else if (uiCurrent->data.valueAdjust.count==4)
the_sz 5:13c70bcde7f6 610 {
the_sz 5:13c70bcde7f6 611 snprintf(buffer,sizeof(buffer),"0x%02X",uiCurrent->data.valueAdjust.values[0]);
the_sz 5:13c70bcde7f6 612 UI_ShowDisplayTextCenter(17+(0*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 5:13c70bcde7f6 613
the_sz 5:13c70bcde7f6 614 snprintf(buffer,sizeof(buffer),"0x%02X",uiCurrent->data.valueAdjust.values[1]);
the_sz 5:13c70bcde7f6 615 UI_ShowDisplayTextCenter(17+(1*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 5:13c70bcde7f6 616
the_sz 5:13c70bcde7f6 617 snprintf(buffer,sizeof(buffer),"0x%02X",uiCurrent->data.valueAdjust.values[2]);
the_sz 5:13c70bcde7f6 618 UI_ShowDisplayTextCenter(17+(2*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 5:13c70bcde7f6 619
the_sz 5:13c70bcde7f6 620 snprintf(buffer,sizeof(buffer),"0x%02X",uiCurrent->data.valueAdjust.values[3]);
the_sz 5:13c70bcde7f6 621 UI_ShowDisplayTextCenter(17+(3*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 2:80026d18fcf3 622 }
the_sz 12:a89096944f20 623 else if (uiCurrent->data.valueAdjust.count==3)
the_sz 12:a89096944f20 624 {
the_sz 12:a89096944f20 625 if (uiCurrent->data.valueAdjust.isTime==true)
the_sz 12:a89096944f20 626 {
the_sz 12:a89096944f20 627 snprintf(buffer,sizeof(buffer)," % 2u ",uiCurrent->data.valueAdjust.values[0]);
the_sz 12:a89096944f20 628 UI_ShowDisplayTextCenter(60+(0*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 12:a89096944f20 629
the_sz 12:a89096944f20 630 snprintf(buffer,sizeof(buffer)," % 2u ",uiCurrent->data.valueAdjust.values[1]);
the_sz 12:a89096944f20 631 UI_ShowDisplayTextCenter(205+(0*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 12:a89096944f20 632
the_sz 12:a89096944f20 633 snprintf(buffer,sizeof(buffer)," % 2u ",uiCurrent->data.valueAdjust.values[2]);
the_sz 12:a89096944f20 634 UI_ShowDisplayTextCenter(205+(1*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 12:a89096944f20 635 }
the_sz 12:a89096944f20 636 else
the_sz 12:a89096944f20 637 {
the_sz 12:a89096944f20 638 snprintf(buffer,sizeof(buffer)," % 2u ",uiCurrent->data.valueAdjust.values[0]);
the_sz 12:a89096944f20 639 UI_ShowDisplayTextCenter(74+(0*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 12:a89096944f20 640
the_sz 12:a89096944f20 641 snprintf(buffer,sizeof(buffer)," % 2u ",uiCurrent->data.valueAdjust.values[1]);
the_sz 12:a89096944f20 642 UI_ShowDisplayTextCenter(74+(1*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 12:a89096944f20 643
the_sz 12:a89096944f20 644 snprintf(buffer,sizeof(buffer)," %02u ",uiCurrent->data.valueAdjust.values[2]);
the_sz 12:a89096944f20 645 UI_ShowDisplayTextCenter(74+(2*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer);
the_sz 12:a89096944f20 646 }
the_sz 12:a89096944f20 647 }
the_sz 2:80026d18fcf3 648 }
the_sz 2:80026d18fcf3 649
the_sz 5:13c70bcde7f6 650 void UI_ClickValueAdjust(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 651 {
the_sz 5:13c70bcde7f6 652 int32_t index;
the_sz 3:ecf7f1f8d749 653
the_sz 2:80026d18fcf3 654 // detect at which button was clicked
the_sz 5:13c70bcde7f6 655 index=-1;
the_sz 3:ecf7f1f8d749 656
the_sz 7:dc29f6647486 657 if (uiCurrent->data.valueAdjust.count==10)
the_sz 7:dc29f6647486 658 {
the_sz 7:dc29f6647486 659 if ((y>=40) && (y<(40+BUTTON_HEIGHT)))
the_sz 7:dc29f6647486 660 {
the_sz 12:a89096944f20 661 if ((x>=(60+(0*(BUTTON_WIDTH+15)))) && (x<(60+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 7:dc29f6647486 662 index=0;
the_sz 7:dc29f6647486 663 else if ((x>=(205+(0*(BUTTON_WIDTH+15)))) && (x<(205+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 7:dc29f6647486 664 index=1;
the_sz 7:dc29f6647486 665 else if ((x>=(205+(1*(BUTTON_WIDTH+15)))) && (x<(205+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 7:dc29f6647486 666 index=2;
the_sz 7:dc29f6647486 667 }
the_sz 7:dc29f6647486 668 else if ((y>=140) && (y<(140+BUTTON_HEIGHT)))
the_sz 7:dc29f6647486 669 {
the_sz 7:dc29f6647486 670 if ((x>=(60+(0*(BUTTON_WIDTH+15)))) && (x<(60+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 7:dc29f6647486 671 index=3;
the_sz 7:dc29f6647486 672 else if ((x>=(205+(0*(BUTTON_WIDTH+15)))) && (x<(205+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 7:dc29f6647486 673 index=4;
the_sz 7:dc29f6647486 674 else if ((x>=(205+(1*(BUTTON_WIDTH+15)))) && (x<(205+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 7:dc29f6647486 675 index=5;
the_sz 7:dc29f6647486 676 }
the_sz 7:dc29f6647486 677 else if ((y>=215) && (y<(215+BUTTON_SMALL_HEIGHT)))
the_sz 7:dc29f6647486 678 {
the_sz 7:dc29f6647486 679 if ((x>=(17+(0*(BUTTON_SMALL_WIDTH+15)))) && (x<(17+(0*(BUTTON_SMALL_WIDTH+15))+BUTTON_SMALL_WIDTH)))
the_sz 7:dc29f6647486 680 index=6;
the_sz 7:dc29f6647486 681 else if ((x>=(17+(1*(BUTTON_SMALL_WIDTH+15)))) && (x<(17+(1*(BUTTON_SMALL_WIDTH+15))+BUTTON_SMALL_WIDTH)))
the_sz 7:dc29f6647486 682 index=7;
the_sz 7:dc29f6647486 683 else if ((x>=(17+(2*(BUTTON_SMALL_WIDTH+15)))) && (x<(17+(2*(BUTTON_SMALL_WIDTH+15))+BUTTON_SMALL_WIDTH)))
the_sz 7:dc29f6647486 684 index=8;
the_sz 7:dc29f6647486 685 else if ((x>=(17+(3*(BUTTON_SMALL_WIDTH+15)))) && (x<(17+(3*(BUTTON_SMALL_WIDTH+15))+BUTTON_SMALL_WIDTH)))
the_sz 7:dc29f6647486 686 index=9;
the_sz 7:dc29f6647486 687 else if ((x>=(17+(4*(BUTTON_SMALL_WIDTH+15)))) && (x<(17+(4*(BUTTON_SMALL_WIDTH+15))+BUTTON_SMALL_WIDTH)))
the_sz 7:dc29f6647486 688 index=10;
the_sz 7:dc29f6647486 689 else if ((x>=(17+(5*(BUTTON_SMALL_WIDTH+15)))) && (x<(17+(5*(BUTTON_SMALL_WIDTH+15))+BUTTON_SMALL_WIDTH)))
the_sz 7:dc29f6647486 690 index=11;
the_sz 7:dc29f6647486 691 else if ((x>=(17+(6*(BUTTON_SMALL_WIDTH+15)))) && (x<(17+(6*(BUTTON_SMALL_WIDTH+15))+BUTTON_SMALL_WIDTH)))
the_sz 7:dc29f6647486 692 index=12;
the_sz 7:dc29f6647486 693 }
the_sz 7:dc29f6647486 694 }
the_sz 7:dc29f6647486 695 else if (uiCurrent->data.valueAdjust.count==4)
the_sz 5:13c70bcde7f6 696 {
the_sz 5:13c70bcde7f6 697 if ((y>=40) && (y<(40+BUTTON_HEIGHT)))
the_sz 5:13c70bcde7f6 698 {
the_sz 5:13c70bcde7f6 699 if ((x>=(17+(0*(BUTTON_WIDTH+15)))) && (x<(17+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 700 index=0;
the_sz 5:13c70bcde7f6 701 else if ((x>=(17+(1*(BUTTON_WIDTH+15)))) && (x<(17+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 702 index=1;
the_sz 5:13c70bcde7f6 703 else if ((x>=(17+(2*(BUTTON_WIDTH+15)))) && (x<(17+(2*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 704 index=2;
the_sz 5:13c70bcde7f6 705 else if ((x>=(17+(3*(BUTTON_WIDTH+15)))) && (x<(17+(3*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 706 index=3;
the_sz 5:13c70bcde7f6 707 }
the_sz 5:13c70bcde7f6 708 else if ((y>=205) && (y<(205+BUTTON_HEIGHT)))
the_sz 5:13c70bcde7f6 709 {
the_sz 5:13c70bcde7f6 710 if ((x>=(17+(0*(BUTTON_WIDTH+15)))) && (x<(17+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 711 index=4;
the_sz 5:13c70bcde7f6 712 else if ((x>=(17+(1*(BUTTON_WIDTH+15)))) && (x<(17+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 713 index=5;
the_sz 5:13c70bcde7f6 714 else if ((x>=(17+(2*(BUTTON_WIDTH+15)))) && (x<(17+(2*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 715 index=6;
the_sz 5:13c70bcde7f6 716 else if ((x>=(17+(3*(BUTTON_WIDTH+15)))) && (x<(17+(3*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 5:13c70bcde7f6 717 index=7;
the_sz 5:13c70bcde7f6 718 }
the_sz 5:13c70bcde7f6 719 }
the_sz 12:a89096944f20 720 else if (uiCurrent->data.valueAdjust.count==3)
the_sz 12:a89096944f20 721 {
the_sz 12:a89096944f20 722 if (uiCurrent->data.valueAdjust.isTime==true)
the_sz 12:a89096944f20 723 {
the_sz 12:a89096944f20 724 if ((y>=40) && (y<(40+BUTTON_HEIGHT)))
the_sz 12:a89096944f20 725 {
the_sz 12:a89096944f20 726 if ((x>=(60+(0*(BUTTON_WIDTH+15)))) && (x<(60+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 12:a89096944f20 727 index=0;
the_sz 12:a89096944f20 728 else if ((x>=(205+(0*(BUTTON_WIDTH+15)))) && (x<(205+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 12:a89096944f20 729 index=1;
the_sz 12:a89096944f20 730 else if ((x>=(205+(1*(BUTTON_WIDTH+15)))) && (x<(205+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 12:a89096944f20 731 index=2;
the_sz 12:a89096944f20 732 }
the_sz 12:a89096944f20 733 else if ((y>=205) && (y<(205+BUTTON_HEIGHT)))
the_sz 12:a89096944f20 734 {
the_sz 12:a89096944f20 735 if ((x>=(60+(0*(BUTTON_WIDTH+15)))) && (x<(60+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 12:a89096944f20 736 index=3;
the_sz 12:a89096944f20 737 else if ((x>=(205+(0*(BUTTON_WIDTH+15)))) && (x<(205+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 12:a89096944f20 738 index=4;
the_sz 12:a89096944f20 739 else if ((x>=(205+(1*(BUTTON_WIDTH+15)))) && (x<(205+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 12:a89096944f20 740 index=5;
the_sz 12:a89096944f20 741 }
the_sz 12:a89096944f20 742 }
the_sz 12:a89096944f20 743 else
the_sz 12:a89096944f20 744 {
the_sz 12:a89096944f20 745 if ((y>=40) && (y<(40+BUTTON_HEIGHT)))
the_sz 12:a89096944f20 746 {
the_sz 12:a89096944f20 747 if ((x>=(74+(0*(BUTTON_WIDTH+15)))) && (x<(74+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 12:a89096944f20 748 index=0;
the_sz 12:a89096944f20 749 else if ((x>=(74+(1*(BUTTON_WIDTH+15)))) && (x<(74+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 12:a89096944f20 750 index=1;
the_sz 12:a89096944f20 751 else if ((x>=(74+(2*(BUTTON_WIDTH+15)))) && (x<(74+(2*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 12:a89096944f20 752 index=2;
the_sz 12:a89096944f20 753 }
the_sz 12:a89096944f20 754 else if ((y>=205) && (y<(205+BUTTON_HEIGHT)))
the_sz 12:a89096944f20 755 {
the_sz 12:a89096944f20 756 if ((x>=(74+(0*(BUTTON_WIDTH+15)))) && (x<(74+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 12:a89096944f20 757 index=3;
the_sz 12:a89096944f20 758 else if ((x>=(74+(1*(BUTTON_WIDTH+15)))) && (x<(74+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 12:a89096944f20 759 index=4;
the_sz 12:a89096944f20 760 else if ((x>=(74+(2*(BUTTON_WIDTH+15)))) && (x<(74+(2*(BUTTON_WIDTH+15))+BUTTON_WIDTH)))
the_sz 12:a89096944f20 761 index=5;
the_sz 12:a89096944f20 762 }
the_sz 12:a89096944f20 763 }
the_sz 12:a89096944f20 764 }
the_sz 5:13c70bcde7f6 765
the_sz 5:13c70bcde7f6 766 if (index!=-1)
the_sz 5:13c70bcde7f6 767 uiCurrent->handler(UR_CLICK,index,uiCurrent);
the_sz 2:80026d18fcf3 768 }
the_sz 2:80026d18fcf3 769
the_sz 2:80026d18fcf3 770 //
the_sz 2:80026d18fcf3 771 // common
the_sz 2:80026d18fcf3 772 //
the_sz 2:80026d18fcf3 773 void UI_Init(void)
the_sz 2:80026d18fcf3 774 {
the_sz 2:80026d18fcf3 775 uiCurrent=NULL;
the_sz 2:80026d18fcf3 776
the_sz 3:ecf7f1f8d749 777 uiLastTouchX=0;
the_sz 3:ecf7f1f8d749 778 uiLastTouchY=0;
the_sz 3:ecf7f1f8d749 779
the_sz 2:80026d18fcf3 780 uiLcd.Init();
the_sz 12:a89096944f20 781 // layer 0: slideshow pictures
the_sz 12:a89096944f20 782 // layer 1: all other ui
the_sz 12:a89096944f20 783 uiLcd.SelectLayer(1);
the_sz 2:80026d18fcf3 784 uiLcd.Clear(COLOR_BG);
the_sz 2:80026d18fcf3 785
the_sz 2:80026d18fcf3 786 if (uiTs.Init(uiLcd.GetXSize(),uiLcd.GetYSize())==TS_OK)
the_sz 2:80026d18fcf3 787 DPrintf("UI_Init: Size: %ux%u.\r\n",uiLcd.GetXSize(),uiLcd.GetYSize());
the_sz 2:80026d18fcf3 788 else
the_sz 2:80026d18fcf3 789 DPrintf("UI_Init: Can't init touch screen.\r\n");
the_sz 3:ecf7f1f8d749 790
the_sz 3:ecf7f1f8d749 791 // setup ui structs
the_sz 3:ecf7f1f8d749 792 uiClock.flags=UI_FLAG_TYPE_CLOCK;
the_sz 3:ecf7f1f8d749 793 uiClock.handler=NULL;
the_sz 5:13c70bcde7f6 794
the_sz 3:ecf7f1f8d749 795 uiClockInWords.flags=UI_FLAG_TYPE_CLOCK_IN_WORDS;
the_sz 3:ecf7f1f8d749 796 uiClockInWords.handler=NULL;
the_sz 5:13c70bcde7f6 797
the_sz 5:13c70bcde7f6 798 uiColorTest.flags=UI_FLAG_TYPE_VALUE_ADJUST;
the_sz 5:13c70bcde7f6 799 uiColorTest.handler=UI_ColorTestHandler;
the_sz 5:13c70bcde7f6 800 uiColorTest.data.valueAdjust.count=4;
the_sz 5:13c70bcde7f6 801 uiColorTest.data.valueAdjust.values[0]=0x80;
the_sz 5:13c70bcde7f6 802 uiColorTest.data.valueAdjust.values[1]=0x80;
the_sz 5:13c70bcde7f6 803 uiColorTest.data.valueAdjust.values[2]=0x80;
the_sz 5:13c70bcde7f6 804 uiColorTest.data.valueAdjust.values[3]=0x80;
the_sz 5:13c70bcde7f6 805
the_sz 3:ecf7f1f8d749 806 uiMain.flags=UI_FLAG_TYPE_BOX_LIST;
the_sz 3:ecf7f1f8d749 807 uiMain.handler=UI_MainHandler;
the_sz 3:ecf7f1f8d749 808 uiMain.data.boxList.items=uiMainItems;
the_sz 3:ecf7f1f8d749 809 uiMain.data.boxList.count=COUNT_OF(uiMainItems);
the_sz 3:ecf7f1f8d749 810
the_sz 9:fe2c9b3a312b 811 uiSlideshow.flags=UI_FLAG_TYPE_SLIDESHOW;
the_sz 9:fe2c9b3a312b 812
the_sz 3:ecf7f1f8d749 813 UI_Show(&uiMain);
the_sz 2:80026d18fcf3 814 }
the_sz 2:80026d18fcf3 815
the_sz 2:80026d18fcf3 816 void UI_ShowChrome(bool initial)
the_sz 2:80026d18fcf3 817 {
the_sz 2:80026d18fcf3 818 char buffer[100];
the_sz 3:ecf7f1f8d749 819 struct tm *tmStruct;
the_sz 2:80026d18fcf3 820
the_sz 2:80026d18fcf3 821 if (initial==true)
the_sz 2:80026d18fcf3 822 {
the_sz 2:80026d18fcf3 823 // fill background
the_sz 2:80026d18fcf3 824 uiLcd.SetTextColor(HEADER_COLOR_BG);
the_sz 5:13c70bcde7f6 825 uiLcd.FillRect(0,0,uiLcd.GetXSize(),HEADER_HEIGHT);
the_sz 5:13c70bcde7f6 826
the_sz 5:13c70bcde7f6 827 uiLcd.SetFont(&display_font_12x22);
the_sz 5:13c70bcde7f6 828 uiLcd.SetBackColor(HEADER_COLOR_BG);
the_sz 5:13c70bcde7f6 829 uiLcd.SetTextColor(HEADER_COLOR_FG);
the_sz 5:13c70bcde7f6 830 if ((uiCurrent->flags & UI_FLAG_HAS_BACK_BUTTON)!=0)
the_sz 6:aa51cc3b9f90 831 UI_DrawBitmapWithAlpha(0,1,ic_navigate_before_white_24dp_1x);
the_sz 2:80026d18fcf3 832 }
the_sz 2:80026d18fcf3 833
the_sz 2:80026d18fcf3 834 // show clock
the_sz 2:80026d18fcf3 835 uiLcd.SetFont(&display_font_12x22);
the_sz 2:80026d18fcf3 836 uiLcd.SetBackColor(HEADER_COLOR_BG);
the_sz 2:80026d18fcf3 837 uiLcd.SetTextColor(HEADER_COLOR_FG);
the_sz 12:a89096944f20 838 RTC_Get(&tmStruct);
the_sz 3:ecf7f1f8d749 839 snprintf(buffer,sizeof(buffer),"%u:%02u",tmStruct->tm_hour,tmStruct->tm_min);
the_sz 2:80026d18fcf3 840 uiLcd.DisplayStringAt(0,3,(uint8_t *)buffer,CENTER_MODE);
the_sz 2:80026d18fcf3 841
the_sz 2:80026d18fcf3 842 // show next alarm
the_sz 3:ecf7f1f8d749 843 //XXX
the_sz 2:80026d18fcf3 844 }
the_sz 2:80026d18fcf3 845
the_sz 2:80026d18fcf3 846 void UI_Update(bool initial)
the_sz 2:80026d18fcf3 847 {
the_sz 3:ecf7f1f8d749 848 uint8_t typeFlag;
the_sz 3:ecf7f1f8d749 849
the_sz 2:80026d18fcf3 850 if ((uiCurrent->flags & UI_FLAG_NEEDS_CHROME)!=0)
the_sz 2:80026d18fcf3 851 UI_ShowChrome(initial);
the_sz 2:80026d18fcf3 852
the_sz 5:13c70bcde7f6 853 typeFlag=uiCurrent->flags & ~(UI_FLAG_NEEDS_CHROME | UI_FLAG_HAS_BACK_BUTTON);
the_sz 3:ecf7f1f8d749 854 if ((typeFlag & UI_FLAG_TYPE_BOX_LIST)!=0)
the_sz 2:80026d18fcf3 855 UI_ShowBoxList(initial);
the_sz 3:ecf7f1f8d749 856 else if ((typeFlag & UI_FLAG_TYPE_CLOCK)!=0)
the_sz 2:80026d18fcf3 857 UI_ShowClock(initial);
the_sz 3:ecf7f1f8d749 858 else if ((typeFlag & UI_FLAG_TYPE_CLOCK_IN_WORDS)!=0)
the_sz 2:80026d18fcf3 859 UI_ShowClockInWords(initial);
the_sz 9:fe2c9b3a312b 860 else if ((typeFlag & UI_FLAG_TYPE_SLIDESHOW)!=0)
the_sz 9:fe2c9b3a312b 861 UI_ShowSlideshow(initial);
the_sz 5:13c70bcde7f6 862 else if ((typeFlag & UI_FLAG_TYPE_VALUE_ADJUST)!=0)
the_sz 5:13c70bcde7f6 863 UI_ShowValueAdjust(initial);
the_sz 2:80026d18fcf3 864 }
the_sz 2:80026d18fcf3 865
the_sz 2:80026d18fcf3 866 void UI_Show(UI_STRUCT *ui)
the_sz 2:80026d18fcf3 867 {
the_sz 5:13c70bcde7f6 868 DPrintf_("UI_Show: 0x%X.\r\n",ui->flags);
the_sz 3:ecf7f1f8d749 869
the_sz 2:80026d18fcf3 870 uiCurrent=ui;
the_sz 2:80026d18fcf3 871
the_sz 3:ecf7f1f8d749 872 if (uiCurrent->handler!=NULL)
the_sz 3:ecf7f1f8d749 873 uiCurrent->handler(UR_SHOW,0,uiCurrent);
the_sz 3:ecf7f1f8d749 874
the_sz 2:80026d18fcf3 875 UI_Update(true);
the_sz 2:80026d18fcf3 876 }
the_sz 2:80026d18fcf3 877
the_sz 2:80026d18fcf3 878 void UI_Click(uint16_t x,uint16_t y)
the_sz 2:80026d18fcf3 879 {
the_sz 3:ecf7f1f8d749 880 uint8_t typeFlag;
the_sz 3:ecf7f1f8d749 881
the_sz 5:13c70bcde7f6 882 DPrintf_("UI_Click: %u x %u.\r\n",x,y);
the_sz 5:13c70bcde7f6 883
the_sz 5:13c70bcde7f6 884 if ((uiCurrent->flags & UI_FLAG_HAS_BACK_BUTTON)!=0)
the_sz 5:13c70bcde7f6 885 {
the_sz 5:13c70bcde7f6 886 if ((y<40) && (x<40))
the_sz 5:13c70bcde7f6 887 {
the_sz 5:13c70bcde7f6 888 if (uiCurrent->handler!=NULL)
the_sz 5:13c70bcde7f6 889 {
the_sz 5:13c70bcde7f6 890 uiCurrent->handler(UR_CLICK,-1,uiCurrent);
the_sz 5:13c70bcde7f6 891 return;
the_sz 5:13c70bcde7f6 892 }
the_sz 5:13c70bcde7f6 893 }
the_sz 5:13c70bcde7f6 894 }
the_sz 5:13c70bcde7f6 895
the_sz 5:13c70bcde7f6 896 typeFlag=uiCurrent->flags & ~(UI_FLAG_NEEDS_CHROME | UI_FLAG_HAS_BACK_BUTTON);
the_sz 3:ecf7f1f8d749 897 if ((typeFlag & UI_FLAG_TYPE_BOX_LIST)!=0)
the_sz 2:80026d18fcf3 898 UI_ClickBoxList(x,y);
the_sz 3:ecf7f1f8d749 899 else if ((typeFlag & UI_FLAG_TYPE_CLOCK)!=0)
the_sz 2:80026d18fcf3 900 UI_ClickClock(x,y);
the_sz 3:ecf7f1f8d749 901 else if ((typeFlag & UI_FLAG_TYPE_CLOCK_IN_WORDS)!=0)
the_sz 2:80026d18fcf3 902 UI_ClickClockInWords(x,y);
the_sz 9:fe2c9b3a312b 903 else if ((typeFlag & UI_FLAG_TYPE_SLIDESHOW)!=0)
the_sz 9:fe2c9b3a312b 904 UI_ClickSlideshow(x,y);
the_sz 5:13c70bcde7f6 905 else if ((typeFlag & UI_FLAG_TYPE_VALUE_ADJUST)!=0)
the_sz 5:13c70bcde7f6 906 UI_ClickValueAdjust(x,y);
the_sz 2:80026d18fcf3 907 }
the_sz 2:80026d18fcf3 908
the_sz 2:80026d18fcf3 909 void UI_Poll(void)
the_sz 2:80026d18fcf3 910 {
the_sz 2:80026d18fcf3 911 TS_StateTypeDef tsState;
the_sz 2:80026d18fcf3 912
the_sz 2:80026d18fcf3 913 uiTs.GetState(&tsState);
the_sz 2:80026d18fcf3 914 if (tsState.touchDetected>0)
the_sz 2:80026d18fcf3 915 {
the_sz 3:ecf7f1f8d749 916 if ( (ABS(uiLastTouchX-tsState.touchX[0])>4)
the_sz 3:ecf7f1f8d749 917 ||
the_sz 3:ecf7f1f8d749 918 (ABS(uiLastTouchY-tsState.touchY[0])>4)
the_sz 3:ecf7f1f8d749 919 )
the_sz 3:ecf7f1f8d749 920 {
the_sz 5:13c70bcde7f6 921 DPrintf_("UI_Poll: #%u - %ux%u.\r\n",tsState.touchDetected,tsState.touchX[0],tsState.touchY[0]);
the_sz 3:ecf7f1f8d749 922
the_sz 3:ecf7f1f8d749 923 uiLastTouchX=tsState.touchX[0];
the_sz 3:ecf7f1f8d749 924 uiLastTouchY=tsState.touchY[0];
the_sz 3:ecf7f1f8d749 925
the_sz 3:ecf7f1f8d749 926 if (uiCurrent!=NULL)
the_sz 3:ecf7f1f8d749 927 UI_Click(tsState.touchX[0],tsState.touchY[0]);
the_sz 3:ecf7f1f8d749 928 }
the_sz 2:80026d18fcf3 929 }
the_sz 5:13c70bcde7f6 930 else
the_sz 5:13c70bcde7f6 931 {
the_sz 5:13c70bcde7f6 932 uiLastTouchX=0;
the_sz 5:13c70bcde7f6 933 uiLastTouchY=0;
the_sz 5:13c70bcde7f6 934 }
the_sz 2:80026d18fcf3 935
the_sz 2:80026d18fcf3 936 if (uiCurrent!=NULL)
the_sz 3:ecf7f1f8d749 937 {
the_sz 3:ecf7f1f8d749 938 if (uiCurrent->handler!=NULL)
the_sz 3:ecf7f1f8d749 939 uiCurrent->handler(UR_TIMER,0,uiCurrent);
the_sz 3:ecf7f1f8d749 940
the_sz 2:80026d18fcf3 941 UI_Update(false);
the_sz 3:ecf7f1f8d749 942 }
the_sz 2:80026d18fcf3 943 }