diff --git a/metesp.ino b/metesp.ino index f6687ab..7f957b0 100644 --- a/metesp.ino +++ b/metesp.ino @@ -67,6 +67,9 @@ void IRAM_ATTR onSecondTimer() { if (dt->second == 60) { dt->minute += 1; dt->second = 0; + if(dt->minute % 15 == 0){ + view_refresh =true; + } if (dt->minute == 60) { dt->hour += 1; dt->minute = 0; @@ -113,7 +116,7 @@ void setup_TIMER(){ #define REGISTER_TIMEDFUN(name,code) static void name (){code;} #define REGISTER_TIMEDFUN_CALL(name,min) tf->registerFun(name,min) -REGISTER_TIMEDFUN(SENSOR_MEASURE_TF, do{sensor->measure();view_update = true;}while(0)); +REGISTER_TIMEDFUN(SENSOR_MEASURE_TF, do{sensor->measure();}while(0)); REGISTER_TIMEDFUN(OWM_MEASURE_TF, do{uint8_t i = 0;while(owm && owm[i]){owm[i]->update(); ++i;}}while(0)); REGISTER_TIMEDFUN(RECORD_LOCAL_TF, iflx->record_local()); REGISTER_TIMEDFUN(RECORD_WEATHER_TF, iflx->record_weather()); @@ -172,7 +175,7 @@ void loop(){ void loop_DRAW(void * pvParameters ){ for(;;){ if(view_refresh) Display::refresh(); - if(view_update) Display::update(); + if(view_update) Display::update(&(ntp->dt)); if(time_update) Display::drawTime(&(ntp->dt)); view_refresh = false; diff --git a/src/display/display.cpp b/src/display/display.cpp index e7dceea..db63383 100644 --- a/src/display/display.cpp +++ b/src/display/display.cpp @@ -1,5 +1,6 @@ #include "display.h" +#define DISP_FULL uint8_t *BlackImage = 0; @@ -8,7 +9,6 @@ static int8_t view_count = -1; static int8_t view_curr = 0; static DisplayWrapper** views = 0; - void DrawMain(bool v) { Paint_DrawIcon(89,36, ICON_LOGO, &FontIcon, BLACK, WHITE); Paint_DrawString_EN(29, 0, "Helcel", &Font45, WHITE, BLACK); @@ -16,46 +16,96 @@ void DrawMain(bool v) { Paint_DrawString_EN(2,EPD_2IN13_V2_WIDTH - Font16.Height,"WESP-v0.1", &Font16, WHITE, BLACK); } -void Display::setup() { - DEV_Module_Init(); +#ifndef DISP_FULL + void Display::setup() { + DEV_Module_Init(); - uint16_t Imagesize = ((EPD_2IN13_V2_WIDTH % 8 == 0) ? (EPD_2IN13_V2_WIDTH / 8 ) : (EPD_2IN13_V2_WIDTH / 8 + 1)) * EPD_2IN13_V2_HEIGHT; - if ((BlackImage = (uint8_t *)malloc(Imagesize)) == NULL) exit(1); - Paint_NewImage(BlackImage, EPD_2IN13_V2_WIDTH, EPD_2IN13_V2_HEIGHT, 270, WHITE); - Paint_SetMirroring(MIRROR_HORIZONTAL); + uint16_t Imagesize = ((EPD_2IN13_V2_WIDTH % 8 == 0) ? (EPD_2IN13_V2_WIDTH / 8 ) : (EPD_2IN13_V2_WIDTH / 8 + 1)) * EPD_2IN13_V2_HEIGHT; + if ((BlackImage = (uint8_t *)calloc(1,Imagesize)) == NULL) exit(1); + Paint_NewImage(BlackImage, EPD_2IN13_V2_WIDTH, EPD_2IN13_V2_HEIGHT, 270, WHITE); + Paint_SetMirroring(MIRROR_HORIZONTAL); + Paint_SelectImage(BlackImage); + Paint_Clear(WHITE); - refresh(); - DrawMain(false); - EPD_2IN13_V2_DisplayPart(BlackImage); -} + EPD_2IN13_V2_Init(EPD_2IN13_V2_FULL); + EPD_2IN13_V2_DisplayPartBaseImage(BlackImage); + EPD_2IN13_V2_Clear(); -void Display::clearTime() { - Paint_ClearWindows(170, EPD_2IN13_V2_WIDTH - Font24.Height+2, 170 + Font24.Width * 4.5, EPD_2IN13_V2_WIDTH, WHITE); - EPD_2IN13_V2_DisplayPart(BlackImage); -} + refresh(); + DrawMain(false); + EPD_2IN13_V2_DisplayPart(BlackImage); + } -void Display::drawTime(strDateTime* dt) { - clearTime(); - if (!dt->valid) return; - Paint_DrawTime(170, EPD_2IN13_V2_WIDTH - Font24.Height+2, dt, &Font24, WHITE, BLACK); - EPD_2IN13_V2_DisplayPart(BlackImage); -}; + void Display::clearTime() { + Paint_ClearWindows(170, EPD_2IN13_V2_WIDTH - Font24.Height+2, 170 + Font24.Width * 4.5, EPD_2IN13_V2_WIDTH, WHITE); + EPD_2IN13_V2_DisplayPart(BlackImage); + } -void Display::refresh() { - Paint_Clear(WHITE); - EPD_2IN13_V2_Init(EPD_2IN13_V2_FULL); - EPD_2IN13_V2_DisplayPartBaseImage(BlackImage); - EPD_2IN13_V2_Init(EPD_2IN13_V2_PART); - Paint_SelectImage(BlackImage); -}; + void Display::drawTime(strDateTime* dt) { + clearTime(); + if (!dt->valid) return; + Paint_DrawTime(170, EPD_2IN13_V2_WIDTH - Font24.Height+2, dt, &Font24, WHITE, BLACK); + EPD_2IN13_V2_DisplayPart(BlackImage); + }; + + void Display::refresh() { + EPD_2IN13_V2_Init(EPD_2IN13_V2_FULL); + EPD_2IN13_V2_DisplayPartBaseImage(BlackImage); + EPD_2IN13_V2_Init(EPD_2IN13_V2_PART); + Paint_SelectImage(BlackImage); + }; + + void Display::update(strDateTime* dt) { + Paint_Clear(WHITE); + Paint_ClearWindows(0, 0, EPD_2IN13_V2_HEIGHT, EPD_2IN13_V2_WIDTH - Font24.Height, WHITE); + Paint_ClearWindows(0, EPD_2IN13_V2_WIDTH - Font24.Height, 170, EPD_2IN13_V2_WIDTH, WHITE); + if(views && view_curr >=0) + views[view_curr]->drawDisplay(); + EPD_2IN13_V2_DisplayPart(BlackImage); + } +#else + void Display::setup() { + DEV_Module_Init(); + + EPD_2IN13_V2_Init(EPD_2IN13_V2_FULL); + EPD_2IN13_V2_Clear(); + + uint16_t Imagesize = ((EPD_2IN13_V2_WIDTH % 8 == 0) ? (EPD_2IN13_V2_WIDTH / 8 ) : (EPD_2IN13_V2_WIDTH / 8 + 1)) * EPD_2IN13_V2_HEIGHT; + if ((BlackImage = (uint8_t *)calloc(1,Imagesize)) == NULL) exit(1); + Paint_NewImage(BlackImage, EPD_2IN13_V2_WIDTH, EPD_2IN13_V2_HEIGHT, 270, WHITE); + Paint_SetMirroring(MIRROR_HORIZONTAL); + Paint_SelectImage(BlackImage); + Paint_Clear(WHITE); + EPD_2IN13_V2_Display(BlackImage); + + refresh(); + DrawMain(false); + } + + void Display::clearTime() { + return; + } + + void Display::drawTime(strDateTime* dt) { + return; + }; + + void Display::refresh() { + EPD_2IN13_V2_Clear(); + EPD_2IN13_V2_Display(BlackImage); + }; + + void Display::update(strDateTime* dt) { + Paint_Clear(WHITE); + if(views && view_curr >=0) + views[view_curr]->drawDisplay(); + + if (dt && dt->valid) Paint_DrawTime(170, EPD_2IN13_V2_WIDTH - Font24.Height+2, dt, &Font24, WHITE, BLACK); + + refresh(); + } +#endif -void Display::update() { - Paint_ClearWindows(0, 0, EPD_2IN13_V2_HEIGHT, EPD_2IN13_V2_WIDTH - Font24.Height, WHITE); - Paint_ClearWindows(0, EPD_2IN13_V2_WIDTH - Font24.Height, 170, EPD_2IN13_V2_WIDTH, WHITE); - if(views && view_curr >=0) - views[view_curr]->drawDisplay(); - EPD_2IN13_V2_DisplayPart(BlackImage); -} void Display::setViews(DisplayWrapper** view_tab, int8_t size) { view_count = size; diff --git a/src/display/display.h b/src/display/display.h index 492af63..be65492 100644 --- a/src/display/display.h +++ b/src/display/display.h @@ -27,7 +27,7 @@ public: static void clearTime(); static void drawTime(strDateTime* dt); static void refresh(); - static void update(); + static void update(strDateTime* dt); static void setViews(DisplayWrapper** views, int8_t size); static void nextView();