full DISP

This commit is contained in:
choelzl 2022-10-02 17:30:07 +02:00
parent 0708beb49f
commit c18f64198a
Signed by: sora
GPG Key ID: A362EA0491E2EEA0
3 changed files with 91 additions and 38 deletions

View File

@ -67,6 +67,9 @@ void IRAM_ATTR onSecondTimer() {
if (dt->second == 60) { if (dt->second == 60) {
dt->minute += 1; dt->minute += 1;
dt->second = 0; dt->second = 0;
if(dt->minute % 15 == 0){
view_refresh =true;
}
if (dt->minute == 60) { if (dt->minute == 60) {
dt->hour += 1; dt->hour += 1;
dt->minute = 0; dt->minute = 0;
@ -113,7 +116,7 @@ void setup_TIMER(){
#define REGISTER_TIMEDFUN(name,code) static void name (){code;} #define REGISTER_TIMEDFUN(name,code) static void name (){code;}
#define REGISTER_TIMEDFUN_CALL(name,min) tf->registerFun(name,min) #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(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_LOCAL_TF, iflx->record_local());
REGISTER_TIMEDFUN(RECORD_WEATHER_TF, iflx->record_weather()); REGISTER_TIMEDFUN(RECORD_WEATHER_TF, iflx->record_weather());
@ -172,7 +175,7 @@ void loop(){
void loop_DRAW(void * pvParameters ){ void loop_DRAW(void * pvParameters ){
for(;;){ for(;;){
if(view_refresh) Display::refresh(); if(view_refresh) Display::refresh();
if(view_update) Display::update(); if(view_update) Display::update(&(ntp->dt));
if(time_update) Display::drawTime(&(ntp->dt)); if(time_update) Display::drawTime(&(ntp->dt));
view_refresh = false; view_refresh = false;

View File

@ -1,5 +1,6 @@
#include "display.h" #include "display.h"
#define DISP_FULL
uint8_t *BlackImage = 0; uint8_t *BlackImage = 0;
@ -8,7 +9,6 @@ static int8_t view_count = -1;
static int8_t view_curr = 0; static int8_t view_curr = 0;
static DisplayWrapper** views = 0; static DisplayWrapper** views = 0;
void DrawMain(bool v) { void DrawMain(bool v) {
Paint_DrawIcon(89,36, ICON_LOGO, &FontIcon, BLACK, WHITE); Paint_DrawIcon(89,36, ICON_LOGO, &FontIcon, BLACK, WHITE);
Paint_DrawString_EN(29, 0, "Helcel", &Font45, WHITE, BLACK); 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); Paint_DrawString_EN(2,EPD_2IN13_V2_WIDTH - Font16.Height,"WESP-v0.1", &Font16, WHITE, BLACK);
} }
void Display::setup() { #ifndef DISP_FULL
DEV_Module_Init(); 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; 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); if ((BlackImage = (uint8_t *)calloc(1,Imagesize)) == NULL) exit(1);
Paint_NewImage(BlackImage, EPD_2IN13_V2_WIDTH, EPD_2IN13_V2_HEIGHT, 270, WHITE); Paint_NewImage(BlackImage, EPD_2IN13_V2_WIDTH, EPD_2IN13_V2_HEIGHT, 270, WHITE);
Paint_SetMirroring(MIRROR_HORIZONTAL); Paint_SetMirroring(MIRROR_HORIZONTAL);
Paint_SelectImage(BlackImage);
Paint_Clear(WHITE);
refresh(); EPD_2IN13_V2_Init(EPD_2IN13_V2_FULL);
DrawMain(false); EPD_2IN13_V2_DisplayPartBaseImage(BlackImage);
EPD_2IN13_V2_DisplayPart(BlackImage); EPD_2IN13_V2_Clear();
}
void Display::clearTime() { refresh();
Paint_ClearWindows(170, EPD_2IN13_V2_WIDTH - Font24.Height+2, 170 + Font24.Width * 4.5, EPD_2IN13_V2_WIDTH, WHITE); DrawMain(false);
EPD_2IN13_V2_DisplayPart(BlackImage); EPD_2IN13_V2_DisplayPart(BlackImage);
} }
void Display::drawTime(strDateTime* dt) { void Display::clearTime() {
clearTime(); Paint_ClearWindows(170, EPD_2IN13_V2_WIDTH - Font24.Height+2, 170 + Font24.Width * 4.5, EPD_2IN13_V2_WIDTH, WHITE);
if (!dt->valid) return; EPD_2IN13_V2_DisplayPart(BlackImage);
Paint_DrawTime(170, EPD_2IN13_V2_WIDTH - Font24.Height+2, dt, &Font24, WHITE, BLACK); }
EPD_2IN13_V2_DisplayPart(BlackImage);
};
void Display::refresh() { void Display::drawTime(strDateTime* dt) {
Paint_Clear(WHITE); clearTime();
EPD_2IN13_V2_Init(EPD_2IN13_V2_FULL); if (!dt->valid) return;
EPD_2IN13_V2_DisplayPartBaseImage(BlackImage); Paint_DrawTime(170, EPD_2IN13_V2_WIDTH - Font24.Height+2, dt, &Font24, WHITE, BLACK);
EPD_2IN13_V2_Init(EPD_2IN13_V2_PART); EPD_2IN13_V2_DisplayPart(BlackImage);
Paint_SelectImage(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) { void Display::setViews(DisplayWrapper** view_tab, int8_t size) {
view_count = size; view_count = size;

View File

@ -27,7 +27,7 @@ public:
static void clearTime(); static void clearTime();
static void drawTime(strDateTime* dt); static void drawTime(strDateTime* dt);
static void refresh(); static void refresh();
static void update(); static void update(strDateTime* dt);
static void setViews(DisplayWrapper** views, int8_t size); static void setViews(DisplayWrapper** views, int8_t size);
static void nextView(); static void nextView();