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