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
Diff: UI.cpp
- Revision:
- 9:fe2c9b3a312b
- Parent:
- 7:dc29f6647486
- Child:
- 11:3c6366ea1021
--- a/UI.cpp Thu Nov 12 22:01:17 2015 +0000 +++ b/UI.cpp Sat Nov 14 02:43:33 2015 +0000 @@ -14,6 +14,9 @@ #define CLOCK_COLOR_BG ((uint32_t)0xFF000000) #define CLOCK_COLOR_FG ((uint32_t)0xFF707070) +#define SLIDESHOW_COLOR_BG ((uint32_t)0xFF000000) +#define SLIDESHOW_COLOR_FG ((uint32_t)0xFF707070) + #define BUTTON_WIDTH 100 #define BUTTON_HEIGHT 60 #define BUTTON_SMALL_WIDTH 50 @@ -39,15 +42,17 @@ TS_DISCO_F746NG uiTs; uint16_t uiLastTouchX; uint16_t uiLastTouchY; +int lastSlideshowTick=0; UI_STRUCT *uiCurrent=NULL; UI_STRUCT uiClock; UI_STRUCT uiClockInWords; UI_STRUCT uiColorTest; UI_STRUCT uiWakeup; +UI_STRUCT uiSlideshow; UI_STRUCT uiMain; static UI_BOX_LIST_ITEM_STRUCT uiMainItems[]= { - { "Clock", ic_query_builder_white_48dp_1x }, { "Clock\nWith Words", ic_query_builder_white_48dp_1x }, { "Adjust\nTimers", ic_notifications_none_white_48dp_1x }, { "Lights On", NULL }, { "Lights Off", NULL }, { "Color Test", NULL } + { "Clock", ic_query_builder_white_48dp_1x }, { "Clock\nWith Words", ic_query_builder_white_48dp_1x }, { "Slideshow", NULL }, { "Adjust\nTimers", ic_notifications_none_white_48dp_1x }, { "Lights On", NULL }, { "Lights Off", NULL }, { "Color Test", NULL } }; // @@ -325,28 +330,6 @@ } // -// message box -// -void UI_ShowMessageBox(bool initial) -{ - if (initial==true) - { - // fill background - UI_ShowClearClientRect(); - } -} - -void UI_ClickMessageBox(uint16_t x,uint16_t y) -{ - uint32_t index; - - // detect at which button was clicked - index=0; - - uiCurrent->handler(UR_CLICK,index,uiCurrent); -} - -// // clock // void UI_ShowClock(bool initial) @@ -416,6 +399,44 @@ } // +// slideshow +// +void UI_ShowSlideshow(bool initial) +{ + char buffer[100]; + struct tm *tmStruct; + time_t timeValue; + + timeValue=time(NULL); + tmStruct=localtime(&timeValue); + + if (((tmStruct->tm_sec / 15)!=lastSlideshowTick) || (initial==true)) + { + lastSlideshowTick=(tmStruct->tm_sec / 15); + + // fill background + uiLcd.SetTextColor(SLIDESHOW_COLOR_BG); + uiLcd.FillRect(0,0,uiLcd.GetXSize(),uiLcd.GetYSize()); + + // show picture + SD_ShowRandomPicture(); + + // show clock + uiLcd.SetFont(&display_font_12x22); + uiLcd.SetBackColor(0x00000000); + uiLcd.SetTextColor(SLIDESHOW_COLOR_FG); + snprintf(buffer,sizeof(buffer),"%u:%02u",tmStruct->tm_hour,tmStruct->tm_min); + uiLcd.DisplayStringAt(30,220,(uint8_t *)buffer,RIGHT_MODE); + } +} + +void UI_ClickSlideshow(uint16_t x,uint16_t y) +{ + // exit view + UI_Show(&uiMain); +} + +// // value adjust // void UI_ShowValueAdjust(bool initial) @@ -631,6 +652,8 @@ uiMain.data.boxList.items=uiMainItems; uiMain.data.boxList.count=COUNT_OF(uiMainItems); + uiSlideshow.flags=UI_FLAG_TYPE_SLIDESHOW; + UI_Show(&uiMain); } @@ -676,12 +699,12 @@ typeFlag=uiCurrent->flags & ~(UI_FLAG_NEEDS_CHROME | UI_FLAG_HAS_BACK_BUTTON); if ((typeFlag & UI_FLAG_TYPE_BOX_LIST)!=0) UI_ShowBoxList(initial); - else if ((typeFlag & UI_FLAG_TYPE_MESSAGE_BOX)!=0) - UI_ShowMessageBox(initial); else if ((typeFlag & UI_FLAG_TYPE_CLOCK)!=0) UI_ShowClock(initial); else if ((typeFlag & UI_FLAG_TYPE_CLOCK_IN_WORDS)!=0) UI_ShowClockInWords(initial); + else if ((typeFlag & UI_FLAG_TYPE_SLIDESHOW)!=0) + UI_ShowSlideshow(initial); else if ((typeFlag & UI_FLAG_TYPE_VALUE_ADJUST)!=0) UI_ShowValueAdjust(initial); } @@ -719,12 +742,12 @@ typeFlag=uiCurrent->flags & ~(UI_FLAG_NEEDS_CHROME | UI_FLAG_HAS_BACK_BUTTON); if ((typeFlag & UI_FLAG_TYPE_BOX_LIST)!=0) UI_ClickBoxList(x,y); - else if ((typeFlag & UI_FLAG_TYPE_MESSAGE_BOX)!=0) - UI_ClickMessageBox(x,y); else if ((typeFlag & UI_FLAG_TYPE_CLOCK)!=0) UI_ClickClock(x,y); else if ((typeFlag & UI_FLAG_TYPE_CLOCK_IN_WORDS)!=0) UI_ClickClockInWords(x,y); + else if ((typeFlag & UI_FLAG_TYPE_SLIDESHOW)!=0) + UI_ClickSlideshow(x,y); else if ((typeFlag & UI_FLAG_TYPE_VALUE_ADJUST)!=0) UI_ClickValueAdjust(x,y); }