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