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@14:2044ad5cd3fe, 2016-02-21 (annotated)
- Committer:
- the_sz
- Date:
- Sun Feb 21 04:26:17 2016 +0000
- Revision:
- 14:2044ad5cd3fe
- Parent:
- 13:811a5c5b3fd6
all fonts are working
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 | 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 | 14:2044ad5cd3fe | 12 | #define DEFAULT_FONT &calibri_36ptFontInfo |
the_sz | 14:2044ad5cd3fe | 13 | |
the_sz | 14:2044ad5cd3fe | 14 | #define CLIENT_COLOR_BG ((uint32_t)0xFF000000) |
the_sz | 14:2044ad5cd3fe | 15 | #define CLIENT_COLOR_FG ((uint32_t)0xFFD0D0D0) |
the_sz | 14:2044ad5cd3fe | 16 | #define CLIENT_FONT DEFAULT_FONT |
the_sz | 13:811a5c5b3fd6 | 17 | |
the_sz | 14:2044ad5cd3fe | 18 | #define HEADER_HEIGHT 26 |
the_sz | 14:2044ad5cd3fe | 19 | #define HEADER_COLOR_BG ((uint32_t)0xFF000000) |
the_sz | 14:2044ad5cd3fe | 20 | #define HEADER_LINE ((uint32_t)0xFF008ED8) |
the_sz | 14:2044ad5cd3fe | 21 | #define HEADER_COLOR_FG ((uint32_t)0xFFD3D3D3) |
the_sz | 14:2044ad5cd3fe | 22 | #define HEADER_FONT DEFAULT_FONT |
the_sz | 2:80026d18fcf3 | 23 | |
the_sz | 14:2044ad5cd3fe | 24 | #define CLOCK_COLOR_BG ((uint32_t)0xFF000000) |
the_sz | 14:2044ad5cd3fe | 25 | #define CLOCK_COLOR_FG ((uint32_t)0xFF7070A0) |
the_sz | 14:2044ad5cd3fe | 26 | #define CLOCK_FONT &trebuchetMS_270ptFontInfo |
the_sz | 14:2044ad5cd3fe | 27 | |
the_sz | 14:2044ad5cd3fe | 28 | #define CLOCK_IN_WORDS_CELL_WIDTH 22 |
the_sz | 14:2044ad5cd3fe | 29 | #define CLOCK_IN_WORDS_CELL_HEIGHT 22 |
the_sz | 14:2044ad5cd3fe | 30 | #define CLOCK_IN_WORDS_COLOR_FG_ACTIVE HEADER_COLOR_FG |
the_sz | 14:2044ad5cd3fe | 31 | #define CLOCK_IN_WORDS_COLOR_FG_INACTIVE ((uint32_t)0xFF202020) |
the_sz | 7:dc29f6647486 | 32 | |
the_sz | 14:2044ad5cd3fe | 33 | #define CLOCK_IN_WORDS_TYPE_ES 0x000001 |
the_sz | 14:2044ad5cd3fe | 34 | #define CLOCK_IN_WORDS_TYPE_IST 0x000002 |
the_sz | 14:2044ad5cd3fe | 35 | #define CLOCK_IN_WORDS_TYPE_FUENF_1 0x000004 |
the_sz | 14:2044ad5cd3fe | 36 | #define CLOCK_IN_WORDS_TYPE_ZEHN_1 0x000008 |
the_sz | 14:2044ad5cd3fe | 37 | #define CLOCK_IN_WORDS_TYPE_ZWANZIG 0x000010 |
the_sz | 14:2044ad5cd3fe | 38 | #define CLOCK_IN_WORDS_TYPE_DREI_1 0x000020 |
the_sz | 14:2044ad5cd3fe | 39 | #define CLOCK_IN_WORDS_TYPE_VIERTEL 0x000040 |
the_sz | 14:2044ad5cd3fe | 40 | #define CLOCK_IN_WORDS_TYPE_VOR 0x000080 |
the_sz | 14:2044ad5cd3fe | 41 | #define CLOCK_IN_WORDS_TYPE_NACH 0x000100 |
the_sz | 14:2044ad5cd3fe | 42 | #define CLOCK_IN_WORDS_TYPE_HALB 0x000200 |
the_sz | 14:2044ad5cd3fe | 43 | #define CLOCK_IN_WORDS_TYPE_ELF 0x000400 |
the_sz | 14:2044ad5cd3fe | 44 | #define CLOCK_IN_WORDS_TYPE_FUENF_2 0x000800 |
the_sz | 14:2044ad5cd3fe | 45 | #define CLOCK_IN_WORDS_TYPE_EINS 0x001000 |
the_sz | 14:2044ad5cd3fe | 46 | #define CLOCK_IN_WORDS_TYPE_ZWEI 0x002000 |
the_sz | 14:2044ad5cd3fe | 47 | #define CLOCK_IN_WORDS_TYPE_DREI_2 0x004000 |
the_sz | 14:2044ad5cd3fe | 48 | #define CLOCK_IN_WORDS_TYPE_VIER 0x008000 |
the_sz | 14:2044ad5cd3fe | 49 | #define CLOCK_IN_WORDS_TYPE_SECHS 0x010000 |
the_sz | 14:2044ad5cd3fe | 50 | #define CLOCK_IN_WORDS_TYPE_ACHT 0x020000 |
the_sz | 14:2044ad5cd3fe | 51 | #define CLOCK_IN_WORDS_TYPE_SIEBEN 0x040000 |
the_sz | 14:2044ad5cd3fe | 52 | #define CLOCK_IN_WORDS_TYPE_ZWOELF 0x080000 |
the_sz | 14:2044ad5cd3fe | 53 | #define CLOCK_IN_WORDS_TYPE_ZEHN_2 0x100000 |
the_sz | 14:2044ad5cd3fe | 54 | #define CLOCK_IN_WORDS_TYPE_NEUN 0x200000 |
the_sz | 14:2044ad5cd3fe | 55 | #define CLOCK_IN_WORDS_TYPE_UHR 0x400000 |
the_sz | 9:fe2c9b3a312b | 56 | |
the_sz | 14:2044ad5cd3fe | 57 | #define SLIDESHOW_COLOR_BG ((uint32_t)0xFF000000) |
the_sz | 14:2044ad5cd3fe | 58 | #define SLIDESHOW_COLOR_FG ((uint32_t)0xFFAFAFAF) |
the_sz | 14:2044ad5cd3fe | 59 | #define SLIDESHOW_TRANSPARENCY 128 |
the_sz | 14:2044ad5cd3fe | 60 | #define SLIDESHOW_FADE_STEP 5 |
the_sz | 14:2044ad5cd3fe | 61 | #define SLIDESHOW_TIMEOUT 15 |
the_sz | 14:2044ad5cd3fe | 62 | #define SLIDESHOW_FONT &trebuchetMS_135ptFontInfo |
the_sz | 2:80026d18fcf3 | 63 | |
the_sz | 14:2044ad5cd3fe | 64 | #define BUTTON_WIDTH 100 |
the_sz | 14:2044ad5cd3fe | 65 | #define BUTTON_HEIGHT 60 |
the_sz | 14:2044ad5cd3fe | 66 | #define BUTTON_SMALL_WIDTH 50 |
the_sz | 14:2044ad5cd3fe | 67 | #define BUTTON_SMALL_HEIGHT 40 |
the_sz | 14:2044ad5cd3fe | 68 | #define BUTTON_COLOR_BG ((uint32_t)0x00000000) |
the_sz | 14:2044ad5cd3fe | 69 | #define BUTTON_COLOR_FG CLIENT_COLOR_FG |
the_sz | 14:2044ad5cd3fe | 70 | #define BUTTON_COLOR_BG_START 0x008ED8 // 0x0C2696 |
the_sz | 14:2044ad5cd3fe | 71 | #define BUTTON_COLOR_BG_END 0x004366 // 0x07185E |
the_sz | 14:2044ad5cd3fe | 72 | #define BUTTON_COLOR_BG_START_INACTIVE 0x515151 |
the_sz | 14:2044ad5cd3fe | 73 | #define BUTTON_COLOR_BG_END_INACTIVE 0x333333 |
the_sz | 14:2044ad5cd3fe | 74 | #define BUTTON_FONT DEFAULT_FONT |
the_sz | 14:2044ad5cd3fe | 75 | |
the_sz | 14:2044ad5cd3fe | 76 | #define COLOR_BG ((uint32_t)0xFF000000) |
the_sz | 7:dc29f6647486 | 77 | |
the_sz | 14:2044ad5cd3fe | 78 | #define MAX_BOXES_PER_LINE 3 |
the_sz | 14:2044ad5cd3fe | 79 | #define BOX_SPACING 10 |
the_sz | 14:2044ad5cd3fe | 80 | #define BOX_TEXT_SPACING 10 |
the_sz | 14:2044ad5cd3fe | 81 | #define BOX_COLOR_BG BUTTON_COLOR_BG |
the_sz | 14:2044ad5cd3fe | 82 | #define BOX_COLOR_FG CLIENT_COLOR_FG |
the_sz | 14:2044ad5cd3fe | 83 | #define BOX_COLOR_BG_START BUTTON_COLOR_BG_START |
the_sz | 14:2044ad5cd3fe | 84 | #define BOX_COLOR_BG_END BUTTON_COLOR_BG_END |
the_sz | 14:2044ad5cd3fe | 85 | #define BOX_FONT DEFAULT_FONT |
the_sz | 3:ecf7f1f8d749 | 86 | |
the_sz | 14:2044ad5cd3fe | 87 | LCD_DISCO_F746NG uiLcd; |
the_sz | 14:2044ad5cd3fe | 88 | TS_DISCO_F746NG uiTs; |
the_sz | 14:2044ad5cd3fe | 89 | uint16_t uiLastTouchX; |
the_sz | 14:2044ad5cd3fe | 90 | uint16_t uiLastTouchY; |
the_sz | 14:2044ad5cd3fe | 91 | int lastSlideshowTick=0; |
the_sz | 14:2044ad5cd3fe | 92 | struct tm lastClockUpdateTime; |
the_sz | 14:2044ad5cd3fe | 93 | UI_STRUCT *uiCurrent=NULL; |
the_sz | 14:2044ad5cd3fe | 94 | UI_STRUCT uiClock; |
the_sz | 14:2044ad5cd3fe | 95 | UI_STRUCT uiClockInWords; |
the_sz | 14:2044ad5cd3fe | 96 | UI_STRUCT uiColorTest; |
the_sz | 14:2044ad5cd3fe | 97 | UI_STRUCT uiWakeup; |
the_sz | 14:2044ad5cd3fe | 98 | UI_STRUCT uiSlideshow; |
the_sz | 14:2044ad5cd3fe | 99 | UI_STRUCT uiMain; |
the_sz | 14:2044ad5cd3fe | 100 | static UI_BOX_LIST_ITEM_STRUCT uiMainItems[]= |
the_sz | 3:ecf7f1f8d749 | 101 | { |
the_sz | 14:2044ad5cd3fe | 102 | { "Clock", ic_query_builder_white_48dp_1x }, { "Clock\nIn Words", ic_query_builder_white_48dp_1x }, { "Slideshow", ic_slideshow_white_48dp_1x }, { "Adjust\nTimers", ic_notifications_none_white_48dp_1x }, { "Settings", 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 | 103 | }; |
the_sz | 2:80026d18fcf3 | 104 | |
the_sz | 2:80026d18fcf3 | 105 | // |
the_sz | 2:80026d18fcf3 | 106 | // helper function |
the_sz | 2:80026d18fcf3 | 107 | // |
the_sz | 2:80026d18fcf3 | 108 | void UI_ShowClearClientRect(void) |
the_sz | 2:80026d18fcf3 | 109 | { |
the_sz | 2:80026d18fcf3 | 110 | uiLcd.SetTextColor(CLIENT_COLOR_BG); |
the_sz | 5:13c70bcde7f6 | 111 | uiLcd.FillRect(0,HEADER_HEIGHT,uiLcd.GetXSize(),uiLcd.GetYSize()-HEADER_HEIGHT); |
the_sz | 2:80026d18fcf3 | 112 | } |
the_sz | 2:80026d18fcf3 | 113 | |
the_sz | 13:811a5c5b3fd6 | 114 | void UI_ShowDisplayText(int16_t x,int16_t y,char *text,const FONT_INFO *pFont,uint32_t colorText,uint32_t colorBack) |
the_sz | 3:ecf7f1f8d749 | 115 | { |
the_sz | 3:ecf7f1f8d749 | 116 | int16_t xStart; |
the_sz | 3:ecf7f1f8d749 | 117 | |
the_sz | 3:ecf7f1f8d749 | 118 | xStart=x; |
the_sz | 13:811a5c5b3fd6 | 119 | |
the_sz | 3:ecf7f1f8d749 | 120 | while ((*text)!='\0') |
the_sz | 3:ecf7f1f8d749 | 121 | { |
the_sz | 3:ecf7f1f8d749 | 122 | if ((*text)=='\n') |
the_sz | 3:ecf7f1f8d749 | 123 | { |
the_sz | 13:811a5c5b3fd6 | 124 | y+=FontX_GetHeight(pFont); |
the_sz | 3:ecf7f1f8d749 | 125 | x=xStart; |
the_sz | 3:ecf7f1f8d749 | 126 | } |
the_sz | 3:ecf7f1f8d749 | 127 | else |
the_sz | 3:ecf7f1f8d749 | 128 | { |
the_sz | 13:811a5c5b3fd6 | 129 | x+=FontX_DisplayChar(x,y,*text,pFont,colorText,colorBack); |
the_sz | 3:ecf7f1f8d749 | 130 | } |
the_sz | 3:ecf7f1f8d749 | 131 | |
the_sz | 3:ecf7f1f8d749 | 132 | text++; |
the_sz | 3:ecf7f1f8d749 | 133 | } |
the_sz | 3:ecf7f1f8d749 | 134 | } |
the_sz | 5:13c70bcde7f6 | 135 | |
the_sz | 13:811a5c5b3fd6 | 136 | void UI_ShowDisplayTextCenter(int16_t x,int16_t y,int16_t width,int16_t height,char *text,const FONT_INFO *pFont,uint32_t colorText,uint32_t colorBack) |
the_sz | 5:13c70bcde7f6 | 137 | { |
the_sz | 13:811a5c5b3fd6 | 138 | if (height!=-1) |
the_sz | 13:811a5c5b3fd6 | 139 | y+=(height-FontX_GetHeight(pFont))/2; |
the_sz | 5:13c70bcde7f6 | 140 | |
the_sz | 13:811a5c5b3fd6 | 141 | FontX_DisplayStringAt(x,y,width,text,ALIGN_CENTER,pFont,colorText,colorBack); |
the_sz | 5:13c70bcde7f6 | 142 | } |
the_sz | 5:13c70bcde7f6 | 143 | |
the_sz | 5:13c70bcde7f6 | 144 | 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 | 145 | { |
the_sz | 5:13c70bcde7f6 | 146 | float deltaRed; |
the_sz | 5:13c70bcde7f6 | 147 | float deltaGreen; |
the_sz | 5:13c70bcde7f6 | 148 | float deltaBlue; |
the_sz | 5:13c70bcde7f6 | 149 | float red; |
the_sz | 5:13c70bcde7f6 | 150 | float green; |
the_sz | 5:13c70bcde7f6 | 151 | float blue; |
the_sz | 5:13c70bcde7f6 | 152 | uint16_t offset; |
the_sz | 5:13c70bcde7f6 | 153 | uint32_t color; |
the_sz | 5:13c70bcde7f6 | 154 | |
the_sz | 5:13c70bcde7f6 | 155 | deltaRed=(float)((int32_t)(colorEnd & 0xFF) - (int32_t)(colorStart & 0xFF))/height; |
the_sz | 5:13c70bcde7f6 | 156 | deltaGreen=(float)((int32_t)((colorEnd >> 8) & 0xFF) - (int32_t)((colorStart >> 8)& 0xFF))/height; |
the_sz | 5:13c70bcde7f6 | 157 | deltaBlue=(float)((int32_t)((colorEnd >> 16) & 0xFF) - (int32_t)((colorStart >> 16)& 0xFF))/height; |
the_sz | 5:13c70bcde7f6 | 158 | |
the_sz | 5:13c70bcde7f6 | 159 | red=colorStart & 0xFF; |
the_sz | 5:13c70bcde7f6 | 160 | green=((colorStart >> 8)& 0xFF); |
the_sz | 5:13c70bcde7f6 | 161 | blue=((colorStart >> 16)& 0xFF); |
the_sz | 5:13c70bcde7f6 | 162 | |
the_sz | 5:13c70bcde7f6 | 163 | for (offset=0;offset<height;offset++) |
the_sz | 5:13c70bcde7f6 | 164 | { |
the_sz | 5:13c70bcde7f6 | 165 | color=(uint8_t)red | (((uint8_t)green)<<8) | (((uint8_t)blue)<<16) | (((uint32_t)0xFF)<<24); |
the_sz | 5:13c70bcde7f6 | 166 | uiLcd.SetTextColor(color); |
the_sz | 5:13c70bcde7f6 | 167 | |
the_sz | 5:13c70bcde7f6 | 168 | if ((offset==0) || (offset==(height-1))) |
the_sz | 5:13c70bcde7f6 | 169 | uiLcd.DrawHLine(x+1,y+offset,width-2); |
the_sz | 5:13c70bcde7f6 | 170 | else |
the_sz | 5:13c70bcde7f6 | 171 | uiLcd.DrawHLine(x,y+offset,width); |
the_sz | 5:13c70bcde7f6 | 172 | |
the_sz | 5:13c70bcde7f6 | 173 | red+=deltaRed; |
the_sz | 5:13c70bcde7f6 | 174 | green+=deltaGreen; |
the_sz | 5:13c70bcde7f6 | 175 | blue+=deltaBlue; |
the_sz | 5:13c70bcde7f6 | 176 | } |
the_sz | 5:13c70bcde7f6 | 177 | } |
the_sz | 5:13c70bcde7f6 | 178 | |
the_sz | 7:dc29f6647486 | 179 | void UI_ShowDrawButtonEx(uint16_t x,uint16_t y,uint16_t width,uint16_t height,char *text,bool active) |
the_sz | 5:13c70bcde7f6 | 180 | { |
the_sz | 5:13c70bcde7f6 | 181 | // paint button background |
the_sz | 7:dc29f6647486 | 182 | if (active==true) |
the_sz | 7:dc29f6647486 | 183 | UI_ShowDrawGradientButton(x,y,width,height,BUTTON_COLOR_BG_START,BUTTON_COLOR_BG_END); |
the_sz | 7:dc29f6647486 | 184 | else |
the_sz | 7:dc29f6647486 | 185 | UI_ShowDrawGradientButton(x,y,width,height,BUTTON_COLOR_BG_START_INACTIVE,BUTTON_COLOR_BG_END_INACTIVE); |
the_sz | 5:13c70bcde7f6 | 186 | |
the_sz | 5:13c70bcde7f6 | 187 | // paint button text |
the_sz | 13:811a5c5b3fd6 | 188 | UI_ShowDisplayTextCenter(x,y,width,height,text,BUTTON_FONT,BUTTON_COLOR_FG,BUTTON_COLOR_BG); |
the_sz | 7:dc29f6647486 | 189 | } |
the_sz | 7:dc29f6647486 | 190 | |
the_sz | 7:dc29f6647486 | 191 | void UI_ShowDrawButton(uint16_t x,uint16_t y,uint16_t width,uint16_t height,char *text) |
the_sz | 7:dc29f6647486 | 192 | { |
the_sz | 7:dc29f6647486 | 193 | UI_ShowDrawButtonEx(x,y,width,height,text,true); |
the_sz | 5:13c70bcde7f6 | 194 | } |
the_sz | 5:13c70bcde7f6 | 195 | |
the_sz | 6:aa51cc3b9f90 | 196 | void UI_DrawBitmapWithAlpha(uint32_t Xpos,uint32_t Ypos,uint8_t *pbmp) |
the_sz | 6:aa51cc3b9f90 | 197 | { |
the_sz | 6:aa51cc3b9f90 | 198 | uint32_t index = 0, width = 0, height = 0, bit_pixel = 0; |
the_sz | 6:aa51cc3b9f90 | 199 | uint32_t x; |
the_sz | 6:aa51cc3b9f90 | 200 | uint32_t part; |
the_sz | 6:aa51cc3b9f90 | 201 | uint32_t color[3]; |
the_sz | 6:aa51cc3b9f90 | 202 | uint32_t value; |
the_sz | 6:aa51cc3b9f90 | 203 | |
the_sz | 6:aa51cc3b9f90 | 204 | /* Get bitmap data address offset */ |
the_sz | 6:aa51cc3b9f90 | 205 | index = *(__IO uint16_t *) (pbmp + 10); |
the_sz | 6:aa51cc3b9f90 | 206 | index |= (*(__IO uint16_t *) (pbmp + 12)) << 16; |
the_sz | 6:aa51cc3b9f90 | 207 | |
the_sz | 6:aa51cc3b9f90 | 208 | /* Read bitmap width */ |
the_sz | 6:aa51cc3b9f90 | 209 | width = *(uint16_t *) (pbmp + 18); |
the_sz | 6:aa51cc3b9f90 | 210 | width |= (*(uint16_t *) (pbmp + 20)) << 16; |
the_sz | 6:aa51cc3b9f90 | 211 | |
the_sz | 6:aa51cc3b9f90 | 212 | /* Read bitmap height */ |
the_sz | 6:aa51cc3b9f90 | 213 | height = *(uint16_t *) (pbmp + 22); |
the_sz | 6:aa51cc3b9f90 | 214 | height |= (*(uint16_t *) (pbmp + 24)) << 16; |
the_sz | 6:aa51cc3b9f90 | 215 | |
the_sz | 6:aa51cc3b9f90 | 216 | /* Read bit/pixel */ |
the_sz | 6:aa51cc3b9f90 | 217 | bit_pixel = *(uint16_t *) (pbmp + 28); |
the_sz | 6:aa51cc3b9f90 | 218 | |
the_sz | 6:aa51cc3b9f90 | 219 | /* Get the layer pixel format */ |
the_sz | 6:aa51cc3b9f90 | 220 | if ((bit_pixel/8) != 4) |
the_sz | 6:aa51cc3b9f90 | 221 | { |
the_sz | 6:aa51cc3b9f90 | 222 | DPrintf("UI_DrawBitmapWithAlpha: This is no alpha picture.\r\n"); |
the_sz | 6:aa51cc3b9f90 | 223 | return; |
the_sz | 6:aa51cc3b9f90 | 224 | } |
the_sz | 6:aa51cc3b9f90 | 225 | |
the_sz | 6:aa51cc3b9f90 | 226 | /* Bypass the bitmap header */ |
the_sz | 6:aa51cc3b9f90 | 227 | pbmp += (index + (width * (height - 1) * (bit_pixel/8))); |
the_sz | 6:aa51cc3b9f90 | 228 | |
the_sz | 6:aa51cc3b9f90 | 229 | for(index=0; index < height; index++) |
the_sz | 6:aa51cc3b9f90 | 230 | { |
the_sz | 6:aa51cc3b9f90 | 231 | for (x=0;x<width;x++) |
the_sz | 6:aa51cc3b9f90 | 232 | { |
the_sz | 6:aa51cc3b9f90 | 233 | value=uiLcd.ReadPixel(Xpos+x,Ypos+index); |
the_sz | 6:aa51cc3b9f90 | 234 | |
the_sz | 6:aa51cc3b9f90 | 235 | color[0]=value & 0xFF; |
the_sz | 6:aa51cc3b9f90 | 236 | color[1]=(value >> 8) & 0xFF; |
the_sz | 6:aa51cc3b9f90 | 237 | color[2]=(value >> 16) & 0xFF; |
the_sz | 6:aa51cc3b9f90 | 238 | |
the_sz | 6:aa51cc3b9f90 | 239 | if (pbmp[3]>0) |
the_sz | 6:aa51cc3b9f90 | 240 | { |
the_sz | 6:aa51cc3b9f90 | 241 | // add red |
the_sz | 6:aa51cc3b9f90 | 242 | part=(color[0]+(pbmp[0]*pbmp[3]/255)); |
the_sz | 6:aa51cc3b9f90 | 243 | if (part>255) |
the_sz | 6:aa51cc3b9f90 | 244 | part=255; |
the_sz | 6:aa51cc3b9f90 | 245 | color[0]=part; |
the_sz | 6:aa51cc3b9f90 | 246 | |
the_sz | 6:aa51cc3b9f90 | 247 | // add green |
the_sz | 6:aa51cc3b9f90 | 248 | part=(color[1]+(pbmp[1]*pbmp[3]/255)); |
the_sz | 6:aa51cc3b9f90 | 249 | if (part>255) |
the_sz | 6:aa51cc3b9f90 | 250 | part=255; |
the_sz | 6:aa51cc3b9f90 | 251 | color[1]=part; |
the_sz | 6:aa51cc3b9f90 | 252 | |
the_sz | 6:aa51cc3b9f90 | 253 | // add blue |
the_sz | 6:aa51cc3b9f90 | 254 | part=(color[2]+(pbmp[2]*pbmp[3]/255)); |
the_sz | 6:aa51cc3b9f90 | 255 | if (part>255) |
the_sz | 6:aa51cc3b9f90 | 256 | part=255; |
the_sz | 6:aa51cc3b9f90 | 257 | color[2]=part; |
the_sz | 6:aa51cc3b9f90 | 258 | |
the_sz | 6:aa51cc3b9f90 | 259 | // draw pixel |
the_sz | 6:aa51cc3b9f90 | 260 | uiLcd.DrawPixel(Xpos+x,Ypos+index,color[0] | (color[1] << 8) | (color[2] << 16) | ((uint32_t)0xFF << 24)); |
the_sz | 6:aa51cc3b9f90 | 261 | } |
the_sz | 6:aa51cc3b9f90 | 262 | |
the_sz | 6:aa51cc3b9f90 | 263 | pbmp+=4; |
the_sz | 6:aa51cc3b9f90 | 264 | } |
the_sz | 6:aa51cc3b9f90 | 265 | |
the_sz | 6:aa51cc3b9f90 | 266 | /* Increment the source and destination buffers */ |
the_sz | 6:aa51cc3b9f90 | 267 | pbmp -= 2*(width*(bit_pixel/8)); |
the_sz | 6:aa51cc3b9f90 | 268 | } |
the_sz | 6:aa51cc3b9f90 | 269 | } |
the_sz | 6:aa51cc3b9f90 | 270 | |
the_sz | 2:80026d18fcf3 | 271 | // |
the_sz | 2:80026d18fcf3 | 272 | // box list |
the_sz | 2:80026d18fcf3 | 273 | // |
the_sz | 2:80026d18fcf3 | 274 | void UI_ShowBoxList(bool initial) |
the_sz | 2:80026d18fcf3 | 275 | { |
the_sz | 2:80026d18fcf3 | 276 | if (initial==true) |
the_sz | 2:80026d18fcf3 | 277 | { |
the_sz | 3:ecf7f1f8d749 | 278 | int8_t lines; |
the_sz | 3:ecf7f1f8d749 | 279 | int8_t columns; |
the_sz | 3:ecf7f1f8d749 | 280 | int8_t box; |
the_sz | 3:ecf7f1f8d749 | 281 | int16_t width; |
the_sz | 3:ecf7f1f8d749 | 282 | int16_t height; |
the_sz | 3:ecf7f1f8d749 | 283 | int16_t startX; |
the_sz | 3:ecf7f1f8d749 | 284 | int16_t startY; |
the_sz | 3:ecf7f1f8d749 | 285 | |
the_sz | 2:80026d18fcf3 | 286 | // fill background |
the_sz | 2:80026d18fcf3 | 287 | UI_ShowClearClientRect(); |
the_sz | 3:ecf7f1f8d749 | 288 | |
the_sz | 3:ecf7f1f8d749 | 289 | // paint boxes |
the_sz | 3:ecf7f1f8d749 | 290 | if (uiCurrent->data.boxList.count<=MAX_BOXES_PER_LINE) |
the_sz | 3:ecf7f1f8d749 | 291 | lines=1; |
the_sz | 3:ecf7f1f8d749 | 292 | else |
the_sz | 3:ecf7f1f8d749 | 293 | lines=2; |
the_sz | 3:ecf7f1f8d749 | 294 | |
the_sz | 3:ecf7f1f8d749 | 295 | columns=((uiCurrent->data.boxList.count + (lines-1)) / lines); |
the_sz | 3:ecf7f1f8d749 | 296 | |
the_sz | 3:ecf7f1f8d749 | 297 | width=(uiLcd.GetXSize() - BOX_SPACING) / columns; |
the_sz | 3:ecf7f1f8d749 | 298 | height=(uiLcd.GetYSize() - HEADER_HEIGHT - BOX_SPACING) / lines; |
the_sz | 3:ecf7f1f8d749 | 299 | |
the_sz | 3:ecf7f1f8d749 | 300 | for (box=0;box<uiCurrent->data.boxList.count;box++) |
the_sz | 3:ecf7f1f8d749 | 301 | { |
the_sz | 3:ecf7f1f8d749 | 302 | startX=BOX_SPACING+(width*(box % columns)); |
the_sz | 3:ecf7f1f8d749 | 303 | startY=HEADER_HEIGHT+BOX_SPACING+(height*(box/columns)); |
the_sz | 3:ecf7f1f8d749 | 304 | |
the_sz | 3:ecf7f1f8d749 | 305 | // paint box background |
the_sz | 5:13c70bcde7f6 | 306 | UI_ShowDrawGradientButton(startX,startY,width-BOX_SPACING,height-BOX_SPACING,BOX_COLOR_BG_START,BOX_COLOR_BG_END); |
the_sz | 5:13c70bcde7f6 | 307 | |
the_sz | 3:ecf7f1f8d749 | 308 | // paint box text |
the_sz | 13:811a5c5b3fd6 | 309 | UI_ShowDisplayText(startX+BOX_TEXT_SPACING,startY+BOX_TEXT_SPACING,uiCurrent->data.boxList.items[box].name,BOX_FONT,BOX_COLOR_FG,BOX_COLOR_BG); |
the_sz | 13:811a5c5b3fd6 | 310 | |
the_sz | 6:aa51cc3b9f90 | 311 | // draw icon |
the_sz | 6:aa51cc3b9f90 | 312 | if (uiCurrent->data.boxList.items[box].image!=NULL) |
the_sz | 6:aa51cc3b9f90 | 313 | UI_DrawBitmapWithAlpha(startX+width-BOX_SPACING-48,startY+height-BOX_SPACING-48,uiCurrent->data.boxList.items[box].image); |
the_sz | 3:ecf7f1f8d749 | 314 | } |
the_sz | 5:13c70bcde7f6 | 315 | } |
the_sz | 2:80026d18fcf3 | 316 | } |
the_sz | 2:80026d18fcf3 | 317 | |
the_sz | 2:80026d18fcf3 | 318 | void UI_ClickBoxList(uint16_t x,uint16_t y) |
the_sz | 2:80026d18fcf3 | 319 | { |
the_sz | 3:ecf7f1f8d749 | 320 | int8_t lines; |
the_sz | 3:ecf7f1f8d749 | 321 | int8_t columns; |
the_sz | 3:ecf7f1f8d749 | 322 | int8_t box; |
the_sz | 3:ecf7f1f8d749 | 323 | int16_t width; |
the_sz | 3:ecf7f1f8d749 | 324 | int16_t height; |
the_sz | 3:ecf7f1f8d749 | 325 | int16_t startX; |
the_sz | 3:ecf7f1f8d749 | 326 | int16_t startY; |
the_sz | 3:ecf7f1f8d749 | 327 | |
the_sz | 3:ecf7f1f8d749 | 328 | // detect at which box was clicked |
the_sz | 3:ecf7f1f8d749 | 329 | if (uiCurrent->data.boxList.count<=MAX_BOXES_PER_LINE) |
the_sz | 3:ecf7f1f8d749 | 330 | lines=1; |
the_sz | 3:ecf7f1f8d749 | 331 | else |
the_sz | 3:ecf7f1f8d749 | 332 | lines=2; |
the_sz | 3:ecf7f1f8d749 | 333 | |
the_sz | 3:ecf7f1f8d749 | 334 | columns=((uiCurrent->data.boxList.count + (lines-1)) / lines); |
the_sz | 3:ecf7f1f8d749 | 335 | |
the_sz | 3:ecf7f1f8d749 | 336 | width=(uiLcd.GetXSize() - BOX_SPACING) / columns; |
the_sz | 3:ecf7f1f8d749 | 337 | height=(uiLcd.GetYSize() - HEADER_HEIGHT - BOX_SPACING) / lines; |
the_sz | 3:ecf7f1f8d749 | 338 | |
the_sz | 3:ecf7f1f8d749 | 339 | for (box=0;box<uiCurrent->data.boxList.count;box++) |
the_sz | 3:ecf7f1f8d749 | 340 | { |
the_sz | 3:ecf7f1f8d749 | 341 | startX=BOX_SPACING+(width*(box % columns)); |
the_sz | 3:ecf7f1f8d749 | 342 | startY=HEADER_HEIGHT+BOX_SPACING+(height*(box/columns)); |
the_sz | 3:ecf7f1f8d749 | 343 | |
the_sz | 3:ecf7f1f8d749 | 344 | if ( (x>=startX) && (x<(startX+width-BOX_SPACING)) |
the_sz | 3:ecf7f1f8d749 | 345 | && |
the_sz | 3:ecf7f1f8d749 | 346 | (y>=startY) && (y<(startY+height-BOX_SPACING)) |
the_sz | 3:ecf7f1f8d749 | 347 | ) |
the_sz | 3:ecf7f1f8d749 | 348 | { |
the_sz | 3:ecf7f1f8d749 | 349 | uiCurrent->handler(UR_CLICK,box,uiCurrent); |
the_sz | 3:ecf7f1f8d749 | 350 | break; |
the_sz | 3:ecf7f1f8d749 | 351 | } |
the_sz | 3:ecf7f1f8d749 | 352 | } |
the_sz | 2:80026d18fcf3 | 353 | } |
the_sz | 2:80026d18fcf3 | 354 | |
the_sz | 2:80026d18fcf3 | 355 | // |
the_sz | 2:80026d18fcf3 | 356 | // clock |
the_sz | 2:80026d18fcf3 | 357 | // |
the_sz | 2:80026d18fcf3 | 358 | void UI_ShowClock(bool initial) |
the_sz | 2:80026d18fcf3 | 359 | { |
the_sz | 2:80026d18fcf3 | 360 | char buffer[100]; |
the_sz | 3:ecf7f1f8d749 | 361 | struct tm *tmStruct; |
the_sz | 2:80026d18fcf3 | 362 | |
the_sz | 14:2044ad5cd3fe | 363 | RTC_Get(&tmStruct); |
the_sz | 14:2044ad5cd3fe | 364 | |
the_sz | 14:2044ad5cd3fe | 365 | if ((initial==true) || (tmStruct->tm_hour!=lastClockUpdateTime.tm_hour) || (tmStruct->tm_min!=lastClockUpdateTime.tm_min)) |
the_sz | 2:80026d18fcf3 | 366 | { |
the_sz | 2:80026d18fcf3 | 367 | // fill background |
the_sz | 2:80026d18fcf3 | 368 | uiLcd.SetTextColor(CLOCK_COLOR_BG); |
the_sz | 5:13c70bcde7f6 | 369 | uiLcd.FillRect(0,0,uiLcd.GetXSize(),uiLcd.GetYSize()); |
the_sz | 14:2044ad5cd3fe | 370 | |
the_sz | 14:2044ad5cd3fe | 371 | // show clock |
the_sz | 14:2044ad5cd3fe | 372 | if (tmStruct->tm_hour>=10) |
the_sz | 14:2044ad5cd3fe | 373 | snprintf(buffer,sizeof(buffer),"%u %u : %u %u",tmStruct->tm_hour / 10,tmStruct->tm_hour % 10,tmStruct->tm_min / 10,tmStruct->tm_min % 10); |
the_sz | 14:2044ad5cd3fe | 374 | else |
the_sz | 14:2044ad5cd3fe | 375 | snprintf(buffer,sizeof(buffer),"%u : %u %u",tmStruct->tm_hour,tmStruct->tm_min / 10,tmStruct->tm_min % 10); |
the_sz | 14:2044ad5cd3fe | 376 | |
the_sz | 14:2044ad5cd3fe | 377 | UI_ShowDisplayTextCenter(0,0,uiLcd.GetXSize(),uiLcd.GetYSize(),buffer,CLOCK_FONT,CLOCK_COLOR_FG,CLOCK_COLOR_BG); |
the_sz | 2:80026d18fcf3 | 378 | |
the_sz | 14:2044ad5cd3fe | 379 | lastClockUpdateTime=*tmStruct; |
the_sz | 14:2044ad5cd3fe | 380 | } |
the_sz | 2:80026d18fcf3 | 381 | } |
the_sz | 2:80026d18fcf3 | 382 | |
the_sz | 2:80026d18fcf3 | 383 | void UI_ClickClock(uint16_t x,uint16_t y) |
the_sz | 2:80026d18fcf3 | 384 | { |
the_sz | 2:80026d18fcf3 | 385 | // exit view |
the_sz | 3:ecf7f1f8d749 | 386 | UI_Show(&uiMain); |
the_sz | 2:80026d18fcf3 | 387 | } |
the_sz | 2:80026d18fcf3 | 388 | |
the_sz | 2:80026d18fcf3 | 389 | // |
the_sz | 2:80026d18fcf3 | 390 | // clock in words |
the_sz | 2:80026d18fcf3 | 391 | // |
the_sz | 14:2044ad5cd3fe | 392 | void UI_ShowClockInWordsText(int16_t x,int16_t y,char *text,uint32_t type,uint32_t flags) |
the_sz | 14:2044ad5cd3fe | 393 | { |
the_sz | 14:2044ad5cd3fe | 394 | char buffer[2]; |
the_sz | 14:2044ad5cd3fe | 395 | uint32_t colorText; |
the_sz | 14:2044ad5cd3fe | 396 | |
the_sz | 14:2044ad5cd3fe | 397 | if ((flags & type)!=0) |
the_sz | 14:2044ad5cd3fe | 398 | colorText=CLOCK_IN_WORDS_COLOR_FG_ACTIVE; |
the_sz | 14:2044ad5cd3fe | 399 | else |
the_sz | 14:2044ad5cd3fe | 400 | colorText=CLOCK_IN_WORDS_COLOR_FG_INACTIVE; |
the_sz | 14:2044ad5cd3fe | 401 | |
the_sz | 14:2044ad5cd3fe | 402 | while ((*text)!='\0') |
the_sz | 14:2044ad5cd3fe | 403 | { |
the_sz | 14:2044ad5cd3fe | 404 | buffer[0]=*text; |
the_sz | 14:2044ad5cd3fe | 405 | buffer[1]='\0'; |
the_sz | 14:2044ad5cd3fe | 406 | |
the_sz | 14:2044ad5cd3fe | 407 | UI_ShowDisplayTextCenter(x+119,y+43,CLOCK_IN_WORDS_CELL_WIDTH,CLOCK_IN_WORDS_CELL_HEIGHT,buffer,CLIENT_FONT,colorText,CLOCK_COLOR_BG); |
the_sz | 14:2044ad5cd3fe | 408 | |
the_sz | 14:2044ad5cd3fe | 409 | text++; |
the_sz | 14:2044ad5cd3fe | 410 | x+=CLOCK_IN_WORDS_CELL_WIDTH; |
the_sz | 14:2044ad5cd3fe | 411 | } |
the_sz | 14:2044ad5cd3fe | 412 | } |
the_sz | 14:2044ad5cd3fe | 413 | |
the_sz | 2:80026d18fcf3 | 414 | void UI_ShowClockInWords(bool initial) |
the_sz | 2:80026d18fcf3 | 415 | { |
the_sz | 14:2044ad5cd3fe | 416 | struct tm *tmStruct; |
the_sz | 14:2044ad5cd3fe | 417 | uint32_t flags; |
the_sz | 14:2044ad5cd3fe | 418 | int8_t minutes; |
the_sz | 14:2044ad5cd3fe | 419 | int8_t hour; |
the_sz | 14:2044ad5cd3fe | 420 | |
the_sz | 14:2044ad5cd3fe | 421 | RTC_Get(&tmStruct); |
the_sz | 14:2044ad5cd3fe | 422 | |
the_sz | 14:2044ad5cd3fe | 423 | if ((initial==true) || (tmStruct->tm_hour!=lastClockUpdateTime.tm_hour) || (tmStruct->tm_min!=lastClockUpdateTime.tm_min)) |
the_sz | 2:80026d18fcf3 | 424 | { |
the_sz | 2:80026d18fcf3 | 425 | // fill background |
the_sz | 2:80026d18fcf3 | 426 | UI_ShowClearClientRect(); |
the_sz | 14:2044ad5cd3fe | 427 | |
the_sz | 14:2044ad5cd3fe | 428 | // show clock |
the_sz | 14:2044ad5cd3fe | 429 | |
the_sz | 14:2044ad5cd3fe | 430 | /* |
the_sz | 14:2044ad5cd3fe | 431 | ES K IST A FÜNF |
the_sz | 14:2044ad5cd3fe | 432 | ZEHN ZWANZIG |
the_sz | 14:2044ad5cd3fe | 433 | DREI VIERTEL |
the_sz | 14:2044ad5cd3fe | 434 | VOR FUNK NACH |
the_sz | 14:2044ad5cd3fe | 435 | HALB A ELFÜNF |
the_sz | 14:2044ad5cd3fe | 436 | EINS XAM ZWEI |
the_sz | 14:2044ad5cd3fe | 437 | DREI PMJ VIER |
the_sz | 14:2044ad5cd3fe | 438 | SECHS NL ACHT |
the_sz | 14:2044ad5cd3fe | 439 | SIEBEN ZWÖLF |
the_sz | 14:2044ad5cd3fe | 440 | ZEHNEUN K UHR |
the_sz | 14:2044ad5cd3fe | 441 | */ |
the_sz | 14:2044ad5cd3fe | 442 | |
the_sz | 14:2044ad5cd3fe | 443 | flags=0; |
the_sz | 14:2044ad5cd3fe | 444 | |
the_sz | 14:2044ad5cd3fe | 445 | minutes=tmStruct->tm_min; |
the_sz | 14:2044ad5cd3fe | 446 | hour=tmStruct->tm_hour; |
the_sz | 14:2044ad5cd3fe | 447 | |
the_sz | 14:2044ad5cd3fe | 448 | minutes=((minutes+2)/5)*5; |
the_sz | 14:2044ad5cd3fe | 449 | if (minutes==5) |
the_sz | 14:2044ad5cd3fe | 450 | flags|=CLOCK_IN_WORDS_TYPE_FUENF_1 | CLOCK_IN_WORDS_TYPE_NACH; |
the_sz | 14:2044ad5cd3fe | 451 | else if (minutes==10) |
the_sz | 14:2044ad5cd3fe | 452 | flags|=CLOCK_IN_WORDS_TYPE_ZEHN_1 | CLOCK_IN_WORDS_TYPE_NACH; |
the_sz | 14:2044ad5cd3fe | 453 | else if (minutes==15) |
the_sz | 14:2044ad5cd3fe | 454 | flags|=CLOCK_IN_WORDS_TYPE_VIERTEL | CLOCK_IN_WORDS_TYPE_NACH; |
the_sz | 14:2044ad5cd3fe | 455 | else if (minutes==20) |
the_sz | 14:2044ad5cd3fe | 456 | flags|=CLOCK_IN_WORDS_TYPE_ZWANZIG | CLOCK_IN_WORDS_TYPE_NACH; |
the_sz | 14:2044ad5cd3fe | 457 | else if (minutes==25) |
the_sz | 14:2044ad5cd3fe | 458 | flags|=CLOCK_IN_WORDS_TYPE_ZWANZIG | CLOCK_IN_WORDS_TYPE_NACH; |
the_sz | 14:2044ad5cd3fe | 459 | else if (minutes==30) |
the_sz | 14:2044ad5cd3fe | 460 | flags|=CLOCK_IN_WORDS_TYPE_HALB; |
the_sz | 14:2044ad5cd3fe | 461 | else if (minutes==35) |
the_sz | 14:2044ad5cd3fe | 462 | flags|=CLOCK_IN_WORDS_TYPE_HALB; |
the_sz | 14:2044ad5cd3fe | 463 | else if (minutes==40) |
the_sz | 14:2044ad5cd3fe | 464 | { |
the_sz | 14:2044ad5cd3fe | 465 | flags|=CLOCK_IN_WORDS_TYPE_ZWANZIG | CLOCK_IN_WORDS_TYPE_VOR; |
the_sz | 14:2044ad5cd3fe | 466 | hour++; |
the_sz | 14:2044ad5cd3fe | 467 | } |
the_sz | 14:2044ad5cd3fe | 468 | else if (minutes==45) |
the_sz | 14:2044ad5cd3fe | 469 | { |
the_sz | 14:2044ad5cd3fe | 470 | flags|=CLOCK_IN_WORDS_TYPE_VIERTEL | CLOCK_IN_WORDS_TYPE_VOR; |
the_sz | 14:2044ad5cd3fe | 471 | hour++; |
the_sz | 14:2044ad5cd3fe | 472 | } |
the_sz | 14:2044ad5cd3fe | 473 | else if (minutes==50) |
the_sz | 14:2044ad5cd3fe | 474 | { |
the_sz | 14:2044ad5cd3fe | 475 | flags|=CLOCK_IN_WORDS_TYPE_ZEHN_1 | CLOCK_IN_WORDS_TYPE_VOR; |
the_sz | 14:2044ad5cd3fe | 476 | hour++; |
the_sz | 14:2044ad5cd3fe | 477 | } |
the_sz | 14:2044ad5cd3fe | 478 | else if (minutes==55) |
the_sz | 14:2044ad5cd3fe | 479 | { |
the_sz | 14:2044ad5cd3fe | 480 | flags|=CLOCK_IN_WORDS_TYPE_FUENF_1 | CLOCK_IN_WORDS_TYPE_VOR; |
the_sz | 14:2044ad5cd3fe | 481 | hour++; |
the_sz | 14:2044ad5cd3fe | 482 | } |
the_sz | 2:80026d18fcf3 | 483 | |
the_sz | 14:2044ad5cd3fe | 484 | hour=hour%12; |
the_sz | 14:2044ad5cd3fe | 485 | if (hour==0) |
the_sz | 14:2044ad5cd3fe | 486 | flags|=CLOCK_IN_WORDS_TYPE_ZWOELF; |
the_sz | 14:2044ad5cd3fe | 487 | else if (hour==1) |
the_sz | 14:2044ad5cd3fe | 488 | flags|=CLOCK_IN_WORDS_TYPE_EINS; |
the_sz | 14:2044ad5cd3fe | 489 | else if (hour==2) |
the_sz | 14:2044ad5cd3fe | 490 | flags|=CLOCK_IN_WORDS_TYPE_ZWEI; |
the_sz | 14:2044ad5cd3fe | 491 | else if (hour==3) |
the_sz | 14:2044ad5cd3fe | 492 | flags|=CLOCK_IN_WORDS_TYPE_DREI_2; |
the_sz | 14:2044ad5cd3fe | 493 | else if (hour==4) |
the_sz | 14:2044ad5cd3fe | 494 | flags|=CLOCK_IN_WORDS_TYPE_VIER; |
the_sz | 14:2044ad5cd3fe | 495 | else if (hour==5) |
the_sz | 14:2044ad5cd3fe | 496 | flags|=CLOCK_IN_WORDS_TYPE_FUENF_2; |
the_sz | 14:2044ad5cd3fe | 497 | else if (hour==6) |
the_sz | 14:2044ad5cd3fe | 498 | flags|=CLOCK_IN_WORDS_TYPE_SECHS; |
the_sz | 14:2044ad5cd3fe | 499 | else if (hour==7) |
the_sz | 14:2044ad5cd3fe | 500 | flags|=CLOCK_IN_WORDS_TYPE_SIEBEN; |
the_sz | 14:2044ad5cd3fe | 501 | else if (hour==8) |
the_sz | 14:2044ad5cd3fe | 502 | flags|=CLOCK_IN_WORDS_TYPE_ACHT; |
the_sz | 14:2044ad5cd3fe | 503 | else if (hour==9) |
the_sz | 14:2044ad5cd3fe | 504 | flags|=CLOCK_IN_WORDS_TYPE_NEUN; |
the_sz | 14:2044ad5cd3fe | 505 | else if (hour==10) |
the_sz | 14:2044ad5cd3fe | 506 | flags|=CLOCK_IN_WORDS_TYPE_ZEHN_2; |
the_sz | 14:2044ad5cd3fe | 507 | else if (hour==11) |
the_sz | 14:2044ad5cd3fe | 508 | flags|=CLOCK_IN_WORDS_TYPE_ELF; |
the_sz | 14:2044ad5cd3fe | 509 | |
the_sz | 14:2044ad5cd3fe | 510 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*0,CLOCK_IN_WORDS_CELL_HEIGHT*0,"ES",1,1); |
the_sz | 14:2044ad5cd3fe | 511 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*2,CLOCK_IN_WORDS_CELL_HEIGHT*0,"K",0,1); |
the_sz | 14:2044ad5cd3fe | 512 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*3,CLOCK_IN_WORDS_CELL_HEIGHT*0,"IST",1,1); |
the_sz | 14:2044ad5cd3fe | 513 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*6,CLOCK_IN_WORDS_CELL_HEIGHT*0,"A",0,1); |
the_sz | 14:2044ad5cd3fe | 514 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*7,CLOCK_IN_WORDS_CELL_HEIGHT*0,"F\xDCNF",CLOCK_IN_WORDS_TYPE_FUENF_1,flags); |
the_sz | 14:2044ad5cd3fe | 515 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*0,CLOCK_IN_WORDS_CELL_HEIGHT*1,"ZEHN",CLOCK_IN_WORDS_TYPE_ZEHN_1,flags); |
the_sz | 14:2044ad5cd3fe | 516 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*4,CLOCK_IN_WORDS_CELL_HEIGHT*1,"ZWANZIG",CLOCK_IN_WORDS_TYPE_ZWANZIG,flags); |
the_sz | 14:2044ad5cd3fe | 517 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*0,CLOCK_IN_WORDS_CELL_HEIGHT*2,"DREI",CLOCK_IN_WORDS_TYPE_DREI_1,flags); |
the_sz | 14:2044ad5cd3fe | 518 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*4,CLOCK_IN_WORDS_CELL_HEIGHT*2,"VIERTEL",CLOCK_IN_WORDS_TYPE_VIERTEL,flags); |
the_sz | 14:2044ad5cd3fe | 519 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*0,CLOCK_IN_WORDS_CELL_HEIGHT*3,"VOR",CLOCK_IN_WORDS_TYPE_VOR,flags); |
the_sz | 14:2044ad5cd3fe | 520 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*3,CLOCK_IN_WORDS_CELL_HEIGHT*3,"FUNK",0,1); |
the_sz | 14:2044ad5cd3fe | 521 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*7,CLOCK_IN_WORDS_CELL_HEIGHT*3,"NACH",CLOCK_IN_WORDS_TYPE_NACH,flags); |
the_sz | 14:2044ad5cd3fe | 522 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*0,CLOCK_IN_WORDS_CELL_HEIGHT*4,"HALB",CLOCK_IN_WORDS_TYPE_HALB,flags); |
the_sz | 14:2044ad5cd3fe | 523 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*4,CLOCK_IN_WORDS_CELL_HEIGHT*4,"A",0,1); |
the_sz | 14:2044ad5cd3fe | 524 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*5,CLOCK_IN_WORDS_CELL_HEIGHT*4,"EL",CLOCK_IN_WORDS_TYPE_ELF,flags); |
the_sz | 14:2044ad5cd3fe | 525 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*7,CLOCK_IN_WORDS_CELL_HEIGHT*4,"F",CLOCK_IN_WORDS_TYPE_ELF | CLOCK_IN_WORDS_TYPE_FUENF_2,flags); |
the_sz | 14:2044ad5cd3fe | 526 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*8,CLOCK_IN_WORDS_CELL_HEIGHT*4,"\xDCNF",CLOCK_IN_WORDS_TYPE_FUENF_2,flags); |
the_sz | 14:2044ad5cd3fe | 527 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*0,CLOCK_IN_WORDS_CELL_HEIGHT*5,"EINS",CLOCK_IN_WORDS_TYPE_EINS,flags); |
the_sz | 14:2044ad5cd3fe | 528 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*4,CLOCK_IN_WORDS_CELL_HEIGHT*5,"XAM",0,1); |
the_sz | 14:2044ad5cd3fe | 529 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*7,CLOCK_IN_WORDS_CELL_HEIGHT*5,"ZWEI",CLOCK_IN_WORDS_TYPE_ZWEI,flags); |
the_sz | 14:2044ad5cd3fe | 530 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*0,CLOCK_IN_WORDS_CELL_HEIGHT*6,"DREI",CLOCK_IN_WORDS_TYPE_DREI_2,flags); |
the_sz | 14:2044ad5cd3fe | 531 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*4,CLOCK_IN_WORDS_CELL_HEIGHT*6,"PMJ",0,1); |
the_sz | 14:2044ad5cd3fe | 532 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*7,CLOCK_IN_WORDS_CELL_HEIGHT*6,"VIER",CLOCK_IN_WORDS_TYPE_VIER,flags); |
the_sz | 14:2044ad5cd3fe | 533 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*0,CLOCK_IN_WORDS_CELL_HEIGHT*7,"SECHS",CLOCK_IN_WORDS_TYPE_SECHS,flags); |
the_sz | 14:2044ad5cd3fe | 534 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*5,CLOCK_IN_WORDS_CELL_HEIGHT*7,"NL",0,1); |
the_sz | 14:2044ad5cd3fe | 535 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*7,CLOCK_IN_WORDS_CELL_HEIGHT*7,"ACHT",CLOCK_IN_WORDS_TYPE_ACHT,flags); |
the_sz | 14:2044ad5cd3fe | 536 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*0,CLOCK_IN_WORDS_CELL_HEIGHT*8,"SIEBEN",CLOCK_IN_WORDS_TYPE_SIEBEN,flags); |
the_sz | 14:2044ad5cd3fe | 537 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*6,CLOCK_IN_WORDS_CELL_HEIGHT*8,"ZW\xD6LF",CLOCK_IN_WORDS_TYPE_ZWOELF,flags); |
the_sz | 14:2044ad5cd3fe | 538 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*0,CLOCK_IN_WORDS_CELL_HEIGHT*9,"ZEH",CLOCK_IN_WORDS_TYPE_ZEHN_2,flags); |
the_sz | 14:2044ad5cd3fe | 539 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*3,CLOCK_IN_WORDS_CELL_HEIGHT*9,"N",CLOCK_IN_WORDS_TYPE_ZEHN_2 | CLOCK_IN_WORDS_TYPE_NEUN,flags); |
the_sz | 14:2044ad5cd3fe | 540 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*4,CLOCK_IN_WORDS_CELL_HEIGHT*9,"EUN",CLOCK_IN_WORDS_TYPE_NEUN,flags); |
the_sz | 14:2044ad5cd3fe | 541 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*7,CLOCK_IN_WORDS_CELL_HEIGHT*9,"K",0,1); |
the_sz | 14:2044ad5cd3fe | 542 | UI_ShowClockInWordsText(CLOCK_IN_WORDS_CELL_WIDTH*8,CLOCK_IN_WORDS_CELL_HEIGHT*9,"UHR",1,1); |
the_sz | 14:2044ad5cd3fe | 543 | |
the_sz | 14:2044ad5cd3fe | 544 | lastClockUpdateTime=*tmStruct; |
the_sz | 14:2044ad5cd3fe | 545 | } |
the_sz | 2:80026d18fcf3 | 546 | |
the_sz | 13:811a5c5b3fd6 | 547 | /* |
the_sz | 2:80026d18fcf3 | 548 | // draw charset |
the_sz | 2:80026d18fcf3 | 549 | int x; |
the_sz | 14:2044ad5cd3fe | 550 | for (x=0x80;x<=0xff;x++) |
the_sz | 2:80026d18fcf3 | 551 | { |
the_sz | 14:2044ad5cd3fe | 552 | FontX_DisplayChar( 1+(((x-0x80) % 16)*14), |
the_sz | 14:2044ad5cd3fe | 553 | 30+(((x-0x80)/16)*20), |
the_sz | 14:2044ad5cd3fe | 554 | x, |
the_sz | 14:2044ad5cd3fe | 555 | CLIENT_FONT, |
the_sz | 14:2044ad5cd3fe | 556 | CLIENT_COLOR_FG, |
the_sz | 14:2044ad5cd3fe | 557 | CLIENT_COLOR_BG); |
the_sz | 2:80026d18fcf3 | 558 | } |
the_sz | 2:80026d18fcf3 | 559 | */ |
the_sz | 2:80026d18fcf3 | 560 | } |
the_sz | 2:80026d18fcf3 | 561 | |
the_sz | 2:80026d18fcf3 | 562 | void UI_ClickClockInWords(uint16_t x,uint16_t y) |
the_sz | 2:80026d18fcf3 | 563 | { |
the_sz | 2:80026d18fcf3 | 564 | // exit view |
the_sz | 3:ecf7f1f8d749 | 565 | UI_Show(&uiMain); |
the_sz | 2:80026d18fcf3 | 566 | } |
the_sz | 2:80026d18fcf3 | 567 | |
the_sz | 2:80026d18fcf3 | 568 | // |
the_sz | 9:fe2c9b3a312b | 569 | // slideshow |
the_sz | 9:fe2c9b3a312b | 570 | // |
the_sz | 12:a89096944f20 | 571 | void UI_ShowSlideshowFade(uint8_t from,uint8_t to) |
the_sz | 12:a89096944f20 | 572 | { |
the_sz | 12:a89096944f20 | 573 | if (from<to) |
the_sz | 12:a89096944f20 | 574 | { |
the_sz | 12:a89096944f20 | 575 | while (from<to) |
the_sz | 12:a89096944f20 | 576 | { |
the_sz | 12:a89096944f20 | 577 | uiLcd.SetTransparency(0,from); |
the_sz | 12:a89096944f20 | 578 | |
the_sz | 12:a89096944f20 | 579 | wait_ms(30); |
the_sz | 12:a89096944f20 | 580 | |
the_sz | 12:a89096944f20 | 581 | if ((to-from)<SLIDESHOW_FADE_STEP) |
the_sz | 12:a89096944f20 | 582 | break; |
the_sz | 12:a89096944f20 | 583 | |
the_sz | 12:a89096944f20 | 584 | from+=SLIDESHOW_FADE_STEP; |
the_sz | 12:a89096944f20 | 585 | } |
the_sz | 12:a89096944f20 | 586 | } |
the_sz | 12:a89096944f20 | 587 | else |
the_sz | 12:a89096944f20 | 588 | { |
the_sz | 12:a89096944f20 | 589 | while (from>to) |
the_sz | 12:a89096944f20 | 590 | { |
the_sz | 12:a89096944f20 | 591 | uiLcd.SetTransparency(0,from); |
the_sz | 12:a89096944f20 | 592 | |
the_sz | 12:a89096944f20 | 593 | wait_ms(30); |
the_sz | 12:a89096944f20 | 594 | |
the_sz | 12:a89096944f20 | 595 | if ((from-to)<SLIDESHOW_FADE_STEP) |
the_sz | 12:a89096944f20 | 596 | break; |
the_sz | 12:a89096944f20 | 597 | |
the_sz | 12:a89096944f20 | 598 | from-=SLIDESHOW_FADE_STEP; |
the_sz | 12:a89096944f20 | 599 | } |
the_sz | 12:a89096944f20 | 600 | } |
the_sz | 12:a89096944f20 | 601 | |
the_sz | 12:a89096944f20 | 602 | uiLcd.SetTransparency(0,to); |
the_sz | 12:a89096944f20 | 603 | } |
the_sz | 12:a89096944f20 | 604 | |
the_sz | 9:fe2c9b3a312b | 605 | void UI_ShowSlideshow(bool initial) |
the_sz | 9:fe2c9b3a312b | 606 | { |
the_sz | 9:fe2c9b3a312b | 607 | char buffer[100]; |
the_sz | 9:fe2c9b3a312b | 608 | struct tm *tmStruct; |
the_sz | 9:fe2c9b3a312b | 609 | |
the_sz | 12:a89096944f20 | 610 | RTC_Get(&tmStruct); |
the_sz | 9:fe2c9b3a312b | 611 | |
the_sz | 12:a89096944f20 | 612 | if (((tmStruct->tm_sec / SLIDESHOW_TIMEOUT)!=lastSlideshowTick) || (initial==true)) |
the_sz | 9:fe2c9b3a312b | 613 | { |
the_sz | 12:a89096944f20 | 614 | lastSlideshowTick=(tmStruct->tm_sec / SLIDESHOW_TIMEOUT); |
the_sz | 9:fe2c9b3a312b | 615 | |
the_sz | 12:a89096944f20 | 616 | // fill background with transparent color |
the_sz | 12:a89096944f20 | 617 | uiLcd.SetTextColor(0x00000000); |
the_sz | 9:fe2c9b3a312b | 618 | uiLcd.FillRect(0,0,uiLcd.GetXSize(),uiLcd.GetYSize()); |
the_sz | 12:a89096944f20 | 619 | |
the_sz | 9:fe2c9b3a312b | 620 | // show clock |
the_sz | 14:2044ad5cd3fe | 621 | if (tmStruct->tm_hour>=10) |
the_sz | 14:2044ad5cd3fe | 622 | snprintf(buffer,sizeof(buffer),"%u %u : %u %u",tmStruct->tm_hour / 10,tmStruct->tm_hour % 10,tmStruct->tm_min / 10,tmStruct->tm_min % 10); |
the_sz | 14:2044ad5cd3fe | 623 | else |
the_sz | 14:2044ad5cd3fe | 624 | snprintf(buffer,sizeof(buffer),"%u : %u %u",tmStruct->tm_hour,tmStruct->tm_min / 10,tmStruct->tm_min % 10); |
the_sz | 14:2044ad5cd3fe | 625 | FontX_DisplayStringAt(30,180,uiLcd.GetXSize(),buffer,ALIGN_RIGHT,SLIDESHOW_FONT,SLIDESHOW_COLOR_FG,0x00000001); |
the_sz | 12:a89096944f20 | 626 | |
the_sz | 12:a89096944f20 | 627 | // hide picture layer |
the_sz | 12:a89096944f20 | 628 | if (initial==true) |
the_sz | 12:a89096944f20 | 629 | uiLcd.SetTransparency(0,0); |
the_sz | 12:a89096944f20 | 630 | else |
the_sz | 12:a89096944f20 | 631 | UI_ShowSlideshowFade(SLIDESHOW_TRANSPARENCY,0); |
the_sz | 12:a89096944f20 | 632 | uiLcd.SelectLayer(0); |
the_sz | 12:a89096944f20 | 633 | // clear old picture |
the_sz | 12:a89096944f20 | 634 | uiLcd.Clear(LCD_COLOR_BLACK); |
the_sz | 12:a89096944f20 | 635 | |
the_sz | 12:a89096944f20 | 636 | // load picture |
the_sz | 12:a89096944f20 | 637 | SD_ShowRandomPicture(); |
the_sz | 12:a89096944f20 | 638 | |
the_sz | 12:a89096944f20 | 639 | // show new picture |
the_sz | 12:a89096944f20 | 640 | if (initial==true) |
the_sz | 12:a89096944f20 | 641 | uiLcd.SetLayerVisible(0,ENABLE); |
the_sz | 12:a89096944f20 | 642 | UI_ShowSlideshowFade(0,SLIDESHOW_TRANSPARENCY); |
the_sz | 12:a89096944f20 | 643 | uiLcd.SelectLayer(1); |
the_sz | 9:fe2c9b3a312b | 644 | } |
the_sz | 9:fe2c9b3a312b | 645 | } |
the_sz | 9:fe2c9b3a312b | 646 | |
the_sz | 9:fe2c9b3a312b | 647 | void UI_ClickSlideshow(uint16_t x,uint16_t y) |
the_sz | 9:fe2c9b3a312b | 648 | { |
the_sz | 9:fe2c9b3a312b | 649 | // exit view |
the_sz | 12:a89096944f20 | 650 | uiLcd.SetLayerVisible(0,DISABLE); |
the_sz | 9:fe2c9b3a312b | 651 | UI_Show(&uiMain); |
the_sz | 9:fe2c9b3a312b | 652 | } |
the_sz | 9:fe2c9b3a312b | 653 | |
the_sz | 9:fe2c9b3a312b | 654 | // |
the_sz | 5:13c70bcde7f6 | 655 | // value adjust |
the_sz | 2:80026d18fcf3 | 656 | // |
the_sz | 5:13c70bcde7f6 | 657 | void UI_ShowValueAdjust(bool initial) |
the_sz | 2:80026d18fcf3 | 658 | { |
the_sz | 5:13c70bcde7f6 | 659 | char buffer[20]; |
the_sz | 5:13c70bcde7f6 | 660 | |
the_sz | 2:80026d18fcf3 | 661 | if (initial==true) |
the_sz | 2:80026d18fcf3 | 662 | { |
the_sz | 2:80026d18fcf3 | 663 | // fill background |
the_sz | 2:80026d18fcf3 | 664 | UI_ShowClearClientRect(); |
the_sz | 5:13c70bcde7f6 | 665 | |
the_sz | 7:dc29f6647486 | 666 | if (uiCurrent->data.valueAdjust.count==10) |
the_sz | 5:13c70bcde7f6 | 667 | { |
the_sz | 7:dc29f6647486 | 668 | UI_ShowDrawButton(60+(0*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+"); |
the_sz | 7:dc29f6647486 | 669 | UI_ShowDrawButton(205+(0*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+"); |
the_sz | 7:dc29f6647486 | 670 | UI_ShowDrawButton(205+(1*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+"); |
the_sz | 7:dc29f6647486 | 671 | |
the_sz | 12:a89096944f20 | 672 | if (uiCurrent->data.valueAdjust.isTime==true) |
the_sz | 13:811a5c5b3fd6 | 673 | UI_ShowDisplayTextCenter(132,92,BUTTON_WIDTH,BUTTON_HEIGHT,":",CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 5:13c70bcde7f6 | 674 | |
the_sz | 7:dc29f6647486 | 675 | UI_ShowDrawButton(60+(0*(BUTTON_WIDTH+15)),140,BUTTON_WIDTH,BUTTON_HEIGHT,"-"); |
the_sz | 7:dc29f6647486 | 676 | UI_ShowDrawButton(205+(0*(BUTTON_WIDTH+15)),140,BUTTON_WIDTH,BUTTON_HEIGHT,"-"); |
the_sz | 7:dc29f6647486 | 677 | UI_ShowDrawButton(205+(1*(BUTTON_WIDTH+15)),140,BUTTON_WIDTH,BUTTON_HEIGHT,"-"); |
the_sz | 7:dc29f6647486 | 678 | } |
the_sz | 7:dc29f6647486 | 679 | else if (uiCurrent->data.valueAdjust.count==4) |
the_sz | 7:dc29f6647486 | 680 | { |
the_sz | 7:dc29f6647486 | 681 | UI_ShowDrawButton(17+(0*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+"); |
the_sz | 7:dc29f6647486 | 682 | UI_ShowDrawButton(17+(1*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+"); |
the_sz | 7:dc29f6647486 | 683 | UI_ShowDrawButton(17+(2*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+"); |
the_sz | 7:dc29f6647486 | 684 | UI_ShowDrawButton(17+(3*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+"); |
the_sz | 7:dc29f6647486 | 685 | |
the_sz | 7:dc29f6647486 | 686 | UI_ShowDrawButton(17+(0*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-"); |
the_sz | 7:dc29f6647486 | 687 | UI_ShowDrawButton(17+(1*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-"); |
the_sz | 7:dc29f6647486 | 688 | UI_ShowDrawButton(17+(2*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-"); |
the_sz | 7:dc29f6647486 | 689 | UI_ShowDrawButton(17+(3*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-"); |
the_sz | 5:13c70bcde7f6 | 690 | } |
the_sz | 12:a89096944f20 | 691 | else if (uiCurrent->data.valueAdjust.count==3) |
the_sz | 12:a89096944f20 | 692 | { |
the_sz | 12:a89096944f20 | 693 | if (uiCurrent->data.valueAdjust.isTime==true) |
the_sz | 12:a89096944f20 | 694 | { |
the_sz | 12:a89096944f20 | 695 | UI_ShowDrawButton(60+(0*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+"); |
the_sz | 12:a89096944f20 | 696 | UI_ShowDrawButton(205+(0*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+"); |
the_sz | 12:a89096944f20 | 697 | UI_ShowDrawButton(205+(1*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+"); |
the_sz | 12:a89096944f20 | 698 | |
the_sz | 13:811a5c5b3fd6 | 699 | UI_ShowDisplayTextCenter(132,125,BUTTON_WIDTH,BUTTON_HEIGHT,":",CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 12:a89096944f20 | 700 | |
the_sz | 12:a89096944f20 | 701 | UI_ShowDrawButton(60+(0*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-"); |
the_sz | 12:a89096944f20 | 702 | UI_ShowDrawButton(205+(0*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-"); |
the_sz | 12:a89096944f20 | 703 | UI_ShowDrawButton(205+(1*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-"); |
the_sz | 12:a89096944f20 | 704 | } |
the_sz | 12:a89096944f20 | 705 | else |
the_sz | 12:a89096944f20 | 706 | { |
the_sz | 12:a89096944f20 | 707 | UI_ShowDrawButton(74+(0*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+"); |
the_sz | 12:a89096944f20 | 708 | UI_ShowDrawButton(74+(1*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+"); |
the_sz | 12:a89096944f20 | 709 | UI_ShowDrawButton(74+(2*(BUTTON_WIDTH+15)),40,BUTTON_WIDTH,BUTTON_HEIGHT,"+"); |
the_sz | 12:a89096944f20 | 710 | |
the_sz | 13:811a5c5b3fd6 | 711 | UI_ShowDisplayTextCenter(130,125,BUTTON_WIDTH,BUTTON_HEIGHT,".",CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 13:811a5c5b3fd6 | 712 | UI_ShowDisplayTextCenter(246,125,BUTTON_WIDTH,BUTTON_HEIGHT,".",CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 12:a89096944f20 | 713 | |
the_sz | 12:a89096944f20 | 714 | UI_ShowDrawButton(74+(0*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-"); |
the_sz | 12:a89096944f20 | 715 | UI_ShowDrawButton(74+(1*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-"); |
the_sz | 12:a89096944f20 | 716 | UI_ShowDrawButton(74+(2*(BUTTON_WIDTH+15)),205,BUTTON_WIDTH,BUTTON_HEIGHT,"-"); |
the_sz | 12:a89096944f20 | 717 | } |
the_sz | 12:a89096944f20 | 718 | } |
the_sz | 5:13c70bcde7f6 | 719 | } |
the_sz | 5:13c70bcde7f6 | 720 | |
the_sz | 7:dc29f6647486 | 721 | if (uiCurrent->data.valueAdjust.count==10) |
the_sz | 7:dc29f6647486 | 722 | { |
the_sz | 13:811a5c5b3fd6 | 723 | snprintf(buffer,sizeof(buffer)," % 2u ",uiCurrent->data.valueAdjust.values[0]); |
the_sz | 13:811a5c5b3fd6 | 724 | UI_ShowDisplayTextCenter(60+(0*(BUTTON_WIDTH+15)),92,BUTTON_WIDTH,BUTTON_HEIGHT,buffer,CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 7:dc29f6647486 | 725 | |
the_sz | 13:811a5c5b3fd6 | 726 | snprintf(buffer,sizeof(buffer)," %u ",uiCurrent->data.valueAdjust.values[1]); |
the_sz | 13:811a5c5b3fd6 | 727 | UI_ShowDisplayTextCenter(205+(0*(BUTTON_WIDTH+15)),92,BUTTON_WIDTH,BUTTON_HEIGHT,buffer,CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 7:dc29f6647486 | 728 | |
the_sz | 13:811a5c5b3fd6 | 729 | snprintf(buffer,sizeof(buffer)," %u ",uiCurrent->data.valueAdjust.values[2]); |
the_sz | 13:811a5c5b3fd6 | 730 | UI_ShowDisplayTextCenter(205+(1*(BUTTON_WIDTH+15)),92,BUTTON_WIDTH,BUTTON_HEIGHT,buffer,CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 7:dc29f6647486 | 731 | |
the_sz | 7:dc29f6647486 | 732 | if (uiCurrent->data.valueAdjust.values[3]==1) |
the_sz | 7:dc29f6647486 | 733 | UI_ShowDrawButton(17+(0*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Mo"); |
the_sz | 7:dc29f6647486 | 734 | else |
the_sz | 7:dc29f6647486 | 735 | UI_ShowDrawButtonEx(17+(0*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Mo",false); |
the_sz | 7:dc29f6647486 | 736 | |
the_sz | 7:dc29f6647486 | 737 | if (uiCurrent->data.valueAdjust.values[4]==1) |
the_sz | 7:dc29f6647486 | 738 | UI_ShowDrawButton(17+(1*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Di"); |
the_sz | 7:dc29f6647486 | 739 | else |
the_sz | 7:dc29f6647486 | 740 | UI_ShowDrawButtonEx(17+(1*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Di",false); |
the_sz | 7:dc29f6647486 | 741 | |
the_sz | 7:dc29f6647486 | 742 | if (uiCurrent->data.valueAdjust.values[5]==1) |
the_sz | 7:dc29f6647486 | 743 | UI_ShowDrawButton(17+(2*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Mi"); |
the_sz | 7:dc29f6647486 | 744 | else |
the_sz | 7:dc29f6647486 | 745 | UI_ShowDrawButtonEx(17+(2*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Mi",false); |
the_sz | 7:dc29f6647486 | 746 | |
the_sz | 7:dc29f6647486 | 747 | if (uiCurrent->data.valueAdjust.values[6]==1) |
the_sz | 7:dc29f6647486 | 748 | UI_ShowDrawButton(17+(3*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Do"); |
the_sz | 7:dc29f6647486 | 749 | else |
the_sz | 7:dc29f6647486 | 750 | UI_ShowDrawButtonEx(17+(3*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Do",false); |
the_sz | 7:dc29f6647486 | 751 | |
the_sz | 7:dc29f6647486 | 752 | if (uiCurrent->data.valueAdjust.values[7]==1) |
the_sz | 7:dc29f6647486 | 753 | UI_ShowDrawButton(17+(4*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Fr"); |
the_sz | 7:dc29f6647486 | 754 | else |
the_sz | 7:dc29f6647486 | 755 | UI_ShowDrawButtonEx(17+(4*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Fr",false); |
the_sz | 7:dc29f6647486 | 756 | |
the_sz | 7:dc29f6647486 | 757 | if (uiCurrent->data.valueAdjust.values[8]==1) |
the_sz | 7:dc29f6647486 | 758 | UI_ShowDrawButton(17+(5*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Sa"); |
the_sz | 7:dc29f6647486 | 759 | else |
the_sz | 7:dc29f6647486 | 760 | UI_ShowDrawButtonEx(17+(5*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"Sa",false); |
the_sz | 7:dc29f6647486 | 761 | |
the_sz | 7:dc29f6647486 | 762 | if (uiCurrent->data.valueAdjust.values[9]==1) |
the_sz | 7:dc29f6647486 | 763 | UI_ShowDrawButton(17+(6*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"So"); |
the_sz | 7:dc29f6647486 | 764 | else |
the_sz | 7:dc29f6647486 | 765 | UI_ShowDrawButtonEx(17+(6*(BUTTON_SMALL_WIDTH+15)),215,BUTTON_SMALL_WIDTH,BUTTON_SMALL_HEIGHT,"So",false); |
the_sz | 7:dc29f6647486 | 766 | } |
the_sz | 7:dc29f6647486 | 767 | else if (uiCurrent->data.valueAdjust.count==4) |
the_sz | 5:13c70bcde7f6 | 768 | { |
the_sz | 13:811a5c5b3fd6 | 769 | snprintf(buffer,sizeof(buffer)," 0x%02X ",uiCurrent->data.valueAdjust.values[0]); |
the_sz | 13:811a5c5b3fd6 | 770 | UI_ShowDisplayTextCenter(17+(0*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer,CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 5:13c70bcde7f6 | 771 | |
the_sz | 13:811a5c5b3fd6 | 772 | snprintf(buffer,sizeof(buffer)," 0x%02X ",uiCurrent->data.valueAdjust.values[1]); |
the_sz | 13:811a5c5b3fd6 | 773 | UI_ShowDisplayTextCenter(17+(1*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer,CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 5:13c70bcde7f6 | 774 | |
the_sz | 13:811a5c5b3fd6 | 775 | snprintf(buffer,sizeof(buffer)," 0x%02X ",uiCurrent->data.valueAdjust.values[2]); |
the_sz | 13:811a5c5b3fd6 | 776 | UI_ShowDisplayTextCenter(17+(2*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer,CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 5:13c70bcde7f6 | 777 | |
the_sz | 13:811a5c5b3fd6 | 778 | snprintf(buffer,sizeof(buffer)," 0x%02X ",uiCurrent->data.valueAdjust.values[3]); |
the_sz | 13:811a5c5b3fd6 | 779 | UI_ShowDisplayTextCenter(17+(3*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer,CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 2:80026d18fcf3 | 780 | } |
the_sz | 12:a89096944f20 | 781 | else if (uiCurrent->data.valueAdjust.count==3) |
the_sz | 12:a89096944f20 | 782 | { |
the_sz | 12:a89096944f20 | 783 | if (uiCurrent->data.valueAdjust.isTime==true) |
the_sz | 12:a89096944f20 | 784 | { |
the_sz | 13:811a5c5b3fd6 | 785 | snprintf(buffer,sizeof(buffer)," % 2u ",uiCurrent->data.valueAdjust.values[0]); |
the_sz | 13:811a5c5b3fd6 | 786 | UI_ShowDisplayTextCenter(60+(0*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer,CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 12:a89096944f20 | 787 | |
the_sz | 13:811a5c5b3fd6 | 788 | snprintf(buffer,sizeof(buffer)," % 2u ",uiCurrent->data.valueAdjust.values[1]); |
the_sz | 13:811a5c5b3fd6 | 789 | UI_ShowDisplayTextCenter(205+(0*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer,CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 12:a89096944f20 | 790 | |
the_sz | 13:811a5c5b3fd6 | 791 | snprintf(buffer,sizeof(buffer)," % 2u ",uiCurrent->data.valueAdjust.values[2]); |
the_sz | 13:811a5c5b3fd6 | 792 | UI_ShowDisplayTextCenter(205+(1*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer,CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 12:a89096944f20 | 793 | } |
the_sz | 12:a89096944f20 | 794 | else |
the_sz | 12:a89096944f20 | 795 | { |
the_sz | 13:811a5c5b3fd6 | 796 | snprintf(buffer,sizeof(buffer)," % 2u ",uiCurrent->data.valueAdjust.values[0]); |
the_sz | 13:811a5c5b3fd6 | 797 | UI_ShowDisplayTextCenter(74+(0*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer,CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 12:a89096944f20 | 798 | |
the_sz | 13:811a5c5b3fd6 | 799 | snprintf(buffer,sizeof(buffer)," % 2u ",uiCurrent->data.valueAdjust.values[1]); |
the_sz | 13:811a5c5b3fd6 | 800 | UI_ShowDisplayTextCenter(74+(1*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer,CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 12:a89096944f20 | 801 | |
the_sz | 13:811a5c5b3fd6 | 802 | snprintf(buffer,sizeof(buffer)," %02u ",uiCurrent->data.valueAdjust.values[2]); |
the_sz | 13:811a5c5b3fd6 | 803 | UI_ShowDisplayTextCenter(74+(2*(BUTTON_WIDTH+15)),125,BUTTON_WIDTH,BUTTON_HEIGHT,buffer,CLIENT_FONT,CLIENT_COLOR_FG,CLIENT_COLOR_BG); |
the_sz | 12:a89096944f20 | 804 | } |
the_sz | 12:a89096944f20 | 805 | } |
the_sz | 2:80026d18fcf3 | 806 | } |
the_sz | 2:80026d18fcf3 | 807 | |
the_sz | 5:13c70bcde7f6 | 808 | void UI_ClickValueAdjust(uint16_t x,uint16_t y) |
the_sz | 2:80026d18fcf3 | 809 | { |
the_sz | 5:13c70bcde7f6 | 810 | int32_t index; |
the_sz | 3:ecf7f1f8d749 | 811 | |
the_sz | 2:80026d18fcf3 | 812 | // detect at which button was clicked |
the_sz | 5:13c70bcde7f6 | 813 | index=-1; |
the_sz | 3:ecf7f1f8d749 | 814 | |
the_sz | 7:dc29f6647486 | 815 | if (uiCurrent->data.valueAdjust.count==10) |
the_sz | 7:dc29f6647486 | 816 | { |
the_sz | 7:dc29f6647486 | 817 | if ((y>=40) && (y<(40+BUTTON_HEIGHT))) |
the_sz | 7:dc29f6647486 | 818 | { |
the_sz | 12:a89096944f20 | 819 | if ((x>=(60+(0*(BUTTON_WIDTH+15)))) && (x<(60+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 7:dc29f6647486 | 820 | index=0; |
the_sz | 7:dc29f6647486 | 821 | else if ((x>=(205+(0*(BUTTON_WIDTH+15)))) && (x<(205+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 7:dc29f6647486 | 822 | index=1; |
the_sz | 7:dc29f6647486 | 823 | else if ((x>=(205+(1*(BUTTON_WIDTH+15)))) && (x<(205+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 7:dc29f6647486 | 824 | index=2; |
the_sz | 7:dc29f6647486 | 825 | } |
the_sz | 7:dc29f6647486 | 826 | else if ((y>=140) && (y<(140+BUTTON_HEIGHT))) |
the_sz | 7:dc29f6647486 | 827 | { |
the_sz | 7:dc29f6647486 | 828 | if ((x>=(60+(0*(BUTTON_WIDTH+15)))) && (x<(60+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 7:dc29f6647486 | 829 | index=3; |
the_sz | 7:dc29f6647486 | 830 | else if ((x>=(205+(0*(BUTTON_WIDTH+15)))) && (x<(205+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 7:dc29f6647486 | 831 | index=4; |
the_sz | 7:dc29f6647486 | 832 | else if ((x>=(205+(1*(BUTTON_WIDTH+15)))) && (x<(205+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 7:dc29f6647486 | 833 | index=5; |
the_sz | 7:dc29f6647486 | 834 | } |
the_sz | 7:dc29f6647486 | 835 | else if ((y>=215) && (y<(215+BUTTON_SMALL_HEIGHT))) |
the_sz | 7:dc29f6647486 | 836 | { |
the_sz | 7:dc29f6647486 | 837 | if ((x>=(17+(0*(BUTTON_SMALL_WIDTH+15)))) && (x<(17+(0*(BUTTON_SMALL_WIDTH+15))+BUTTON_SMALL_WIDTH))) |
the_sz | 7:dc29f6647486 | 838 | index=6; |
the_sz | 7:dc29f6647486 | 839 | else if ((x>=(17+(1*(BUTTON_SMALL_WIDTH+15)))) && (x<(17+(1*(BUTTON_SMALL_WIDTH+15))+BUTTON_SMALL_WIDTH))) |
the_sz | 7:dc29f6647486 | 840 | index=7; |
the_sz | 7:dc29f6647486 | 841 | else if ((x>=(17+(2*(BUTTON_SMALL_WIDTH+15)))) && (x<(17+(2*(BUTTON_SMALL_WIDTH+15))+BUTTON_SMALL_WIDTH))) |
the_sz | 7:dc29f6647486 | 842 | index=8; |
the_sz | 7:dc29f6647486 | 843 | else if ((x>=(17+(3*(BUTTON_SMALL_WIDTH+15)))) && (x<(17+(3*(BUTTON_SMALL_WIDTH+15))+BUTTON_SMALL_WIDTH))) |
the_sz | 7:dc29f6647486 | 844 | index=9; |
the_sz | 7:dc29f6647486 | 845 | else if ((x>=(17+(4*(BUTTON_SMALL_WIDTH+15)))) && (x<(17+(4*(BUTTON_SMALL_WIDTH+15))+BUTTON_SMALL_WIDTH))) |
the_sz | 7:dc29f6647486 | 846 | index=10; |
the_sz | 7:dc29f6647486 | 847 | else if ((x>=(17+(5*(BUTTON_SMALL_WIDTH+15)))) && (x<(17+(5*(BUTTON_SMALL_WIDTH+15))+BUTTON_SMALL_WIDTH))) |
the_sz | 7:dc29f6647486 | 848 | index=11; |
the_sz | 7:dc29f6647486 | 849 | else if ((x>=(17+(6*(BUTTON_SMALL_WIDTH+15)))) && (x<(17+(6*(BUTTON_SMALL_WIDTH+15))+BUTTON_SMALL_WIDTH))) |
the_sz | 7:dc29f6647486 | 850 | index=12; |
the_sz | 7:dc29f6647486 | 851 | } |
the_sz | 7:dc29f6647486 | 852 | } |
the_sz | 7:dc29f6647486 | 853 | else if (uiCurrent->data.valueAdjust.count==4) |
the_sz | 5:13c70bcde7f6 | 854 | { |
the_sz | 5:13c70bcde7f6 | 855 | if ((y>=40) && (y<(40+BUTTON_HEIGHT))) |
the_sz | 5:13c70bcde7f6 | 856 | { |
the_sz | 5:13c70bcde7f6 | 857 | if ((x>=(17+(0*(BUTTON_WIDTH+15)))) && (x<(17+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 5:13c70bcde7f6 | 858 | index=0; |
the_sz | 5:13c70bcde7f6 | 859 | else if ((x>=(17+(1*(BUTTON_WIDTH+15)))) && (x<(17+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 5:13c70bcde7f6 | 860 | index=1; |
the_sz | 5:13c70bcde7f6 | 861 | else if ((x>=(17+(2*(BUTTON_WIDTH+15)))) && (x<(17+(2*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 5:13c70bcde7f6 | 862 | index=2; |
the_sz | 5:13c70bcde7f6 | 863 | else if ((x>=(17+(3*(BUTTON_WIDTH+15)))) && (x<(17+(3*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 5:13c70bcde7f6 | 864 | index=3; |
the_sz | 5:13c70bcde7f6 | 865 | } |
the_sz | 5:13c70bcde7f6 | 866 | else if ((y>=205) && (y<(205+BUTTON_HEIGHT))) |
the_sz | 5:13c70bcde7f6 | 867 | { |
the_sz | 5:13c70bcde7f6 | 868 | if ((x>=(17+(0*(BUTTON_WIDTH+15)))) && (x<(17+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 5:13c70bcde7f6 | 869 | index=4; |
the_sz | 5:13c70bcde7f6 | 870 | else if ((x>=(17+(1*(BUTTON_WIDTH+15)))) && (x<(17+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 5:13c70bcde7f6 | 871 | index=5; |
the_sz | 5:13c70bcde7f6 | 872 | else if ((x>=(17+(2*(BUTTON_WIDTH+15)))) && (x<(17+(2*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 5:13c70bcde7f6 | 873 | index=6; |
the_sz | 5:13c70bcde7f6 | 874 | else if ((x>=(17+(3*(BUTTON_WIDTH+15)))) && (x<(17+(3*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 5:13c70bcde7f6 | 875 | index=7; |
the_sz | 5:13c70bcde7f6 | 876 | } |
the_sz | 5:13c70bcde7f6 | 877 | } |
the_sz | 12:a89096944f20 | 878 | else if (uiCurrent->data.valueAdjust.count==3) |
the_sz | 12:a89096944f20 | 879 | { |
the_sz | 12:a89096944f20 | 880 | if (uiCurrent->data.valueAdjust.isTime==true) |
the_sz | 12:a89096944f20 | 881 | { |
the_sz | 12:a89096944f20 | 882 | if ((y>=40) && (y<(40+BUTTON_HEIGHT))) |
the_sz | 12:a89096944f20 | 883 | { |
the_sz | 12:a89096944f20 | 884 | if ((x>=(60+(0*(BUTTON_WIDTH+15)))) && (x<(60+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 12:a89096944f20 | 885 | index=0; |
the_sz | 12:a89096944f20 | 886 | else if ((x>=(205+(0*(BUTTON_WIDTH+15)))) && (x<(205+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 12:a89096944f20 | 887 | index=1; |
the_sz | 12:a89096944f20 | 888 | else if ((x>=(205+(1*(BUTTON_WIDTH+15)))) && (x<(205+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 12:a89096944f20 | 889 | index=2; |
the_sz | 12:a89096944f20 | 890 | } |
the_sz | 12:a89096944f20 | 891 | else if ((y>=205) && (y<(205+BUTTON_HEIGHT))) |
the_sz | 12:a89096944f20 | 892 | { |
the_sz | 12:a89096944f20 | 893 | if ((x>=(60+(0*(BUTTON_WIDTH+15)))) && (x<(60+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 12:a89096944f20 | 894 | index=3; |
the_sz | 12:a89096944f20 | 895 | else if ((x>=(205+(0*(BUTTON_WIDTH+15)))) && (x<(205+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 12:a89096944f20 | 896 | index=4; |
the_sz | 12:a89096944f20 | 897 | else if ((x>=(205+(1*(BUTTON_WIDTH+15)))) && (x<(205+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 12:a89096944f20 | 898 | index=5; |
the_sz | 12:a89096944f20 | 899 | } |
the_sz | 12:a89096944f20 | 900 | } |
the_sz | 12:a89096944f20 | 901 | else |
the_sz | 12:a89096944f20 | 902 | { |
the_sz | 12:a89096944f20 | 903 | if ((y>=40) && (y<(40+BUTTON_HEIGHT))) |
the_sz | 12:a89096944f20 | 904 | { |
the_sz | 12:a89096944f20 | 905 | if ((x>=(74+(0*(BUTTON_WIDTH+15)))) && (x<(74+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 12:a89096944f20 | 906 | index=0; |
the_sz | 12:a89096944f20 | 907 | else if ((x>=(74+(1*(BUTTON_WIDTH+15)))) && (x<(74+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 12:a89096944f20 | 908 | index=1; |
the_sz | 12:a89096944f20 | 909 | else if ((x>=(74+(2*(BUTTON_WIDTH+15)))) && (x<(74+(2*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 12:a89096944f20 | 910 | index=2; |
the_sz | 12:a89096944f20 | 911 | } |
the_sz | 12:a89096944f20 | 912 | else if ((y>=205) && (y<(205+BUTTON_HEIGHT))) |
the_sz | 12:a89096944f20 | 913 | { |
the_sz | 12:a89096944f20 | 914 | if ((x>=(74+(0*(BUTTON_WIDTH+15)))) && (x<(74+(0*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 12:a89096944f20 | 915 | index=3; |
the_sz | 12:a89096944f20 | 916 | else if ((x>=(74+(1*(BUTTON_WIDTH+15)))) && (x<(74+(1*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 12:a89096944f20 | 917 | index=4; |
the_sz | 12:a89096944f20 | 918 | else if ((x>=(74+(2*(BUTTON_WIDTH+15)))) && (x<(74+(2*(BUTTON_WIDTH+15))+BUTTON_WIDTH))) |
the_sz | 12:a89096944f20 | 919 | index=5; |
the_sz | 12:a89096944f20 | 920 | } |
the_sz | 12:a89096944f20 | 921 | } |
the_sz | 12:a89096944f20 | 922 | } |
the_sz | 5:13c70bcde7f6 | 923 | |
the_sz | 5:13c70bcde7f6 | 924 | if (index!=-1) |
the_sz | 5:13c70bcde7f6 | 925 | uiCurrent->handler(UR_CLICK,index,uiCurrent); |
the_sz | 2:80026d18fcf3 | 926 | } |
the_sz | 2:80026d18fcf3 | 927 | |
the_sz | 2:80026d18fcf3 | 928 | // |
the_sz | 2:80026d18fcf3 | 929 | // common |
the_sz | 2:80026d18fcf3 | 930 | // |
the_sz | 2:80026d18fcf3 | 931 | void UI_Init(void) |
the_sz | 2:80026d18fcf3 | 932 | { |
the_sz | 2:80026d18fcf3 | 933 | uiCurrent=NULL; |
the_sz | 2:80026d18fcf3 | 934 | |
the_sz | 3:ecf7f1f8d749 | 935 | uiLastTouchX=0; |
the_sz | 3:ecf7f1f8d749 | 936 | uiLastTouchY=0; |
the_sz | 3:ecf7f1f8d749 | 937 | |
the_sz | 2:80026d18fcf3 | 938 | uiLcd.Init(); |
the_sz | 12:a89096944f20 | 939 | // layer 0: slideshow pictures |
the_sz | 12:a89096944f20 | 940 | // layer 1: all other ui |
the_sz | 12:a89096944f20 | 941 | uiLcd.SelectLayer(1); |
the_sz | 2:80026d18fcf3 | 942 | uiLcd.Clear(COLOR_BG); |
the_sz | 2:80026d18fcf3 | 943 | |
the_sz | 2:80026d18fcf3 | 944 | if (uiTs.Init(uiLcd.GetXSize(),uiLcd.GetYSize())==TS_OK) |
the_sz | 2:80026d18fcf3 | 945 | DPrintf("UI_Init: Size: %ux%u.\r\n",uiLcd.GetXSize(),uiLcd.GetYSize()); |
the_sz | 2:80026d18fcf3 | 946 | else |
the_sz | 2:80026d18fcf3 | 947 | DPrintf("UI_Init: Can't init touch screen.\r\n"); |
the_sz | 3:ecf7f1f8d749 | 948 | |
the_sz | 3:ecf7f1f8d749 | 949 | // setup ui structs |
the_sz | 3:ecf7f1f8d749 | 950 | uiClock.flags=UI_FLAG_TYPE_CLOCK; |
the_sz | 3:ecf7f1f8d749 | 951 | uiClock.handler=NULL; |
the_sz | 5:13c70bcde7f6 | 952 | |
the_sz | 3:ecf7f1f8d749 | 953 | uiClockInWords.flags=UI_FLAG_TYPE_CLOCK_IN_WORDS; |
the_sz | 3:ecf7f1f8d749 | 954 | uiClockInWords.handler=NULL; |
the_sz | 5:13c70bcde7f6 | 955 | |
the_sz | 5:13c70bcde7f6 | 956 | uiColorTest.flags=UI_FLAG_TYPE_VALUE_ADJUST; |
the_sz | 5:13c70bcde7f6 | 957 | uiColorTest.handler=UI_ColorTestHandler; |
the_sz | 5:13c70bcde7f6 | 958 | uiColorTest.data.valueAdjust.count=4; |
the_sz | 5:13c70bcde7f6 | 959 | uiColorTest.data.valueAdjust.values[0]=0x80; |
the_sz | 5:13c70bcde7f6 | 960 | uiColorTest.data.valueAdjust.values[1]=0x80; |
the_sz | 5:13c70bcde7f6 | 961 | uiColorTest.data.valueAdjust.values[2]=0x80; |
the_sz | 5:13c70bcde7f6 | 962 | uiColorTest.data.valueAdjust.values[3]=0x80; |
the_sz | 5:13c70bcde7f6 | 963 | |
the_sz | 3:ecf7f1f8d749 | 964 | uiMain.flags=UI_FLAG_TYPE_BOX_LIST; |
the_sz | 3:ecf7f1f8d749 | 965 | uiMain.handler=UI_MainHandler; |
the_sz | 3:ecf7f1f8d749 | 966 | uiMain.data.boxList.items=uiMainItems; |
the_sz | 3:ecf7f1f8d749 | 967 | uiMain.data.boxList.count=COUNT_OF(uiMainItems); |
the_sz | 3:ecf7f1f8d749 | 968 | |
the_sz | 9:fe2c9b3a312b | 969 | uiSlideshow.flags=UI_FLAG_TYPE_SLIDESHOW; |
the_sz | 9:fe2c9b3a312b | 970 | |
the_sz | 3:ecf7f1f8d749 | 971 | UI_Show(&uiMain); |
the_sz | 2:80026d18fcf3 | 972 | } |
the_sz | 2:80026d18fcf3 | 973 | |
the_sz | 2:80026d18fcf3 | 974 | void UI_ShowChrome(bool initial) |
the_sz | 2:80026d18fcf3 | 975 | { |
the_sz | 2:80026d18fcf3 | 976 | char buffer[100]; |
the_sz | 3:ecf7f1f8d749 | 977 | struct tm *tmStruct; |
the_sz | 2:80026d18fcf3 | 978 | |
the_sz | 2:80026d18fcf3 | 979 | if (initial==true) |
the_sz | 2:80026d18fcf3 | 980 | { |
the_sz | 2:80026d18fcf3 | 981 | // fill background |
the_sz | 2:80026d18fcf3 | 982 | uiLcd.SetTextColor(HEADER_COLOR_BG); |
the_sz | 5:13c70bcde7f6 | 983 | uiLcd.FillRect(0,0,uiLcd.GetXSize(),HEADER_HEIGHT); |
the_sz | 5:13c70bcde7f6 | 984 | |
the_sz | 14:2044ad5cd3fe | 985 | // draw line |
the_sz | 14:2044ad5cd3fe | 986 | uiLcd.SetTextColor(HEADER_LINE); |
the_sz | 14:2044ad5cd3fe | 987 | uiLcd.DrawHLine(10,HEADER_HEIGHT-1,uiLcd.GetXSize()-20); |
the_sz | 14:2044ad5cd3fe | 988 | |
the_sz | 5:13c70bcde7f6 | 989 | if ((uiCurrent->flags & UI_FLAG_HAS_BACK_BUTTON)!=0) |
the_sz | 14:2044ad5cd3fe | 990 | UI_DrawBitmapWithAlpha(5,1,ic_navigate_before_white_24dp_1x); |
the_sz | 2:80026d18fcf3 | 991 | } |
the_sz | 2:80026d18fcf3 | 992 | |
the_sz | 2:80026d18fcf3 | 993 | // show clock |
the_sz | 12:a89096944f20 | 994 | RTC_Get(&tmStruct); |
the_sz | 13:811a5c5b3fd6 | 995 | snprintf(buffer,sizeof(buffer)," %u:%02u ",tmStruct->tm_hour,tmStruct->tm_min); |
the_sz | 14:2044ad5cd3fe | 996 | UI_ShowDisplayTextCenter(0,2,uiLcd.GetXSize(),-1,buffer,HEADER_FONT,HEADER_COLOR_FG,HEADER_COLOR_BG); |
the_sz | 2:80026d18fcf3 | 997 | |
the_sz | 2:80026d18fcf3 | 998 | // show next alarm |
the_sz | 3:ecf7f1f8d749 | 999 | //XXX |
the_sz | 2:80026d18fcf3 | 1000 | } |
the_sz | 2:80026d18fcf3 | 1001 | |
the_sz | 2:80026d18fcf3 | 1002 | void UI_Update(bool initial) |
the_sz | 2:80026d18fcf3 | 1003 | { |
the_sz | 3:ecf7f1f8d749 | 1004 | uint8_t typeFlag; |
the_sz | 3:ecf7f1f8d749 | 1005 | |
the_sz | 2:80026d18fcf3 | 1006 | if ((uiCurrent->flags & UI_FLAG_NEEDS_CHROME)!=0) |
the_sz | 2:80026d18fcf3 | 1007 | UI_ShowChrome(initial); |
the_sz | 2:80026d18fcf3 | 1008 | |
the_sz | 5:13c70bcde7f6 | 1009 | typeFlag=uiCurrent->flags & ~(UI_FLAG_NEEDS_CHROME | UI_FLAG_HAS_BACK_BUTTON); |
the_sz | 3:ecf7f1f8d749 | 1010 | if ((typeFlag & UI_FLAG_TYPE_BOX_LIST)!=0) |
the_sz | 2:80026d18fcf3 | 1011 | UI_ShowBoxList(initial); |
the_sz | 3:ecf7f1f8d749 | 1012 | else if ((typeFlag & UI_FLAG_TYPE_CLOCK)!=0) |
the_sz | 2:80026d18fcf3 | 1013 | UI_ShowClock(initial); |
the_sz | 3:ecf7f1f8d749 | 1014 | else if ((typeFlag & UI_FLAG_TYPE_CLOCK_IN_WORDS)!=0) |
the_sz | 2:80026d18fcf3 | 1015 | UI_ShowClockInWords(initial); |
the_sz | 9:fe2c9b3a312b | 1016 | else if ((typeFlag & UI_FLAG_TYPE_SLIDESHOW)!=0) |
the_sz | 9:fe2c9b3a312b | 1017 | UI_ShowSlideshow(initial); |
the_sz | 5:13c70bcde7f6 | 1018 | else if ((typeFlag & UI_FLAG_TYPE_VALUE_ADJUST)!=0) |
the_sz | 5:13c70bcde7f6 | 1019 | UI_ShowValueAdjust(initial); |
the_sz | 2:80026d18fcf3 | 1020 | } |
the_sz | 2:80026d18fcf3 | 1021 | |
the_sz | 2:80026d18fcf3 | 1022 | void UI_Show(UI_STRUCT *ui) |
the_sz | 2:80026d18fcf3 | 1023 | { |
the_sz | 5:13c70bcde7f6 | 1024 | DPrintf_("UI_Show: 0x%X.\r\n",ui->flags); |
the_sz | 3:ecf7f1f8d749 | 1025 | |
the_sz | 2:80026d18fcf3 | 1026 | uiCurrent=ui; |
the_sz | 2:80026d18fcf3 | 1027 | |
the_sz | 3:ecf7f1f8d749 | 1028 | if (uiCurrent->handler!=NULL) |
the_sz | 3:ecf7f1f8d749 | 1029 | uiCurrent->handler(UR_SHOW,0,uiCurrent); |
the_sz | 3:ecf7f1f8d749 | 1030 | |
the_sz | 2:80026d18fcf3 | 1031 | UI_Update(true); |
the_sz | 2:80026d18fcf3 | 1032 | } |
the_sz | 2:80026d18fcf3 | 1033 | |
the_sz | 2:80026d18fcf3 | 1034 | void UI_Click(uint16_t x,uint16_t y) |
the_sz | 2:80026d18fcf3 | 1035 | { |
the_sz | 3:ecf7f1f8d749 | 1036 | uint8_t typeFlag; |
the_sz | 3:ecf7f1f8d749 | 1037 | |
the_sz | 5:13c70bcde7f6 | 1038 | DPrintf_("UI_Click: %u x %u.\r\n",x,y); |
the_sz | 5:13c70bcde7f6 | 1039 | |
the_sz | 5:13c70bcde7f6 | 1040 | if ((uiCurrent->flags & UI_FLAG_HAS_BACK_BUTTON)!=0) |
the_sz | 5:13c70bcde7f6 | 1041 | { |
the_sz | 5:13c70bcde7f6 | 1042 | if ((y<40) && (x<40)) |
the_sz | 5:13c70bcde7f6 | 1043 | { |
the_sz | 5:13c70bcde7f6 | 1044 | if (uiCurrent->handler!=NULL) |
the_sz | 5:13c70bcde7f6 | 1045 | { |
the_sz | 5:13c70bcde7f6 | 1046 | uiCurrent->handler(UR_CLICK,-1,uiCurrent); |
the_sz | 5:13c70bcde7f6 | 1047 | return; |
the_sz | 5:13c70bcde7f6 | 1048 | } |
the_sz | 5:13c70bcde7f6 | 1049 | } |
the_sz | 5:13c70bcde7f6 | 1050 | } |
the_sz | 5:13c70bcde7f6 | 1051 | |
the_sz | 5:13c70bcde7f6 | 1052 | typeFlag=uiCurrent->flags & ~(UI_FLAG_NEEDS_CHROME | UI_FLAG_HAS_BACK_BUTTON); |
the_sz | 3:ecf7f1f8d749 | 1053 | if ((typeFlag & UI_FLAG_TYPE_BOX_LIST)!=0) |
the_sz | 2:80026d18fcf3 | 1054 | UI_ClickBoxList(x,y); |
the_sz | 3:ecf7f1f8d749 | 1055 | else if ((typeFlag & UI_FLAG_TYPE_CLOCK)!=0) |
the_sz | 2:80026d18fcf3 | 1056 | UI_ClickClock(x,y); |
the_sz | 3:ecf7f1f8d749 | 1057 | else if ((typeFlag & UI_FLAG_TYPE_CLOCK_IN_WORDS)!=0) |
the_sz | 2:80026d18fcf3 | 1058 | UI_ClickClockInWords(x,y); |
the_sz | 9:fe2c9b3a312b | 1059 | else if ((typeFlag & UI_FLAG_TYPE_SLIDESHOW)!=0) |
the_sz | 9:fe2c9b3a312b | 1060 | UI_ClickSlideshow(x,y); |
the_sz | 5:13c70bcde7f6 | 1061 | else if ((typeFlag & UI_FLAG_TYPE_VALUE_ADJUST)!=0) |
the_sz | 5:13c70bcde7f6 | 1062 | UI_ClickValueAdjust(x,y); |
the_sz | 2:80026d18fcf3 | 1063 | } |
the_sz | 2:80026d18fcf3 | 1064 | |
the_sz | 2:80026d18fcf3 | 1065 | void UI_Poll(void) |
the_sz | 2:80026d18fcf3 | 1066 | { |
the_sz | 2:80026d18fcf3 | 1067 | TS_StateTypeDef tsState; |
the_sz | 2:80026d18fcf3 | 1068 | |
the_sz | 2:80026d18fcf3 | 1069 | uiTs.GetState(&tsState); |
the_sz | 2:80026d18fcf3 | 1070 | if (tsState.touchDetected>0) |
the_sz | 2:80026d18fcf3 | 1071 | { |
the_sz | 3:ecf7f1f8d749 | 1072 | if ( (ABS(uiLastTouchX-tsState.touchX[0])>4) |
the_sz | 3:ecf7f1f8d749 | 1073 | || |
the_sz | 3:ecf7f1f8d749 | 1074 | (ABS(uiLastTouchY-tsState.touchY[0])>4) |
the_sz | 3:ecf7f1f8d749 | 1075 | ) |
the_sz | 3:ecf7f1f8d749 | 1076 | { |
the_sz | 5:13c70bcde7f6 | 1077 | DPrintf_("UI_Poll: #%u - %ux%u.\r\n",tsState.touchDetected,tsState.touchX[0],tsState.touchY[0]); |
the_sz | 3:ecf7f1f8d749 | 1078 | |
the_sz | 3:ecf7f1f8d749 | 1079 | uiLastTouchX=tsState.touchX[0]; |
the_sz | 3:ecf7f1f8d749 | 1080 | uiLastTouchY=tsState.touchY[0]; |
the_sz | 3:ecf7f1f8d749 | 1081 | |
the_sz | 3:ecf7f1f8d749 | 1082 | if (uiCurrent!=NULL) |
the_sz | 3:ecf7f1f8d749 | 1083 | UI_Click(tsState.touchX[0],tsState.touchY[0]); |
the_sz | 3:ecf7f1f8d749 | 1084 | } |
the_sz | 2:80026d18fcf3 | 1085 | } |
the_sz | 5:13c70bcde7f6 | 1086 | else |
the_sz | 5:13c70bcde7f6 | 1087 | { |
the_sz | 5:13c70bcde7f6 | 1088 | uiLastTouchX=0; |
the_sz | 5:13c70bcde7f6 | 1089 | uiLastTouchY=0; |
the_sz | 5:13c70bcde7f6 | 1090 | } |
the_sz | 2:80026d18fcf3 | 1091 | |
the_sz | 2:80026d18fcf3 | 1092 | if (uiCurrent!=NULL) |
the_sz | 3:ecf7f1f8d749 | 1093 | { |
the_sz | 3:ecf7f1f8d749 | 1094 | if (uiCurrent->handler!=NULL) |
the_sz | 3:ecf7f1f8d749 | 1095 | uiCurrent->handler(UR_TIMER,0,uiCurrent); |
the_sz | 3:ecf7f1f8d749 | 1096 | |
the_sz | 2:80026d18fcf3 | 1097 | UI_Update(false); |
the_sz | 3:ecf7f1f8d749 | 1098 | } |
the_sz | 2:80026d18fcf3 | 1099 | } |