remember display mode

This commit is contained in:
Shuanglei Tao
2025-05-31 19:33:52 +08:00
parent 93d62cae05
commit 1f58efac20
6 changed files with 50 additions and 17 deletions

View File

@@ -119,16 +119,30 @@ static bool GetFestival(uint16_t year, uint8_t mon, uint8_t day, uint8_t week,
if (GetJieQi(year, mon, day, &JQdate) && JQdate == day) {
uint8_t JQ = (mon - 1) * 2;
if (day >= 15) JQ++;
strcpy(festival, JieQiStr[JQ]);
if (JQ == 6) // 清明
sprintf(festival, "%s", JieQiStr[JQ]);
else
strcpy(festival, JieQiStr[JQ]);
strcat(festival, "");
return true;
}
return false;
}
static void DrawTimeSyncTip(Adafruit_GFX *gfx)
{
GFX_setFont(gfx, u8g2_font_wqy12_t_lunar);
GFX_fillRect(gfx, gfx->_width / 2 - 100, gfx->_height / 2 - 25, 200, 50, GFX_WHITE);
GFX_drawRoundRect(gfx, gfx->_width / 2 - 100, gfx->_height / 2 - 25, 200, 50, 5, GFX_BLACK);
GFX_setTextColor(gfx, GFX_RED, GFX_WHITE);
GFX_setCursor(gfx, 149, 145);
GFX_printf(gfx, "SYNC TIME!");
GFX_setTextColor(gfx, GFX_BLACK, GFX_WHITE);
GFX_setCursor(gfx, 110, 164);
GFX_setFont(gfx, u8g2_font_wqy9_t_lunar);
GFX_printf(gfx, "https://tsl0922.github.io/EPD-nRF5");
}
static void DrawBattery(Adafruit_GFX *gfx, int16_t x, int16_t y, float voltage)
{
uint8_t level = (uint8_t)(voltage * 100 / 4.2);
@@ -165,7 +179,7 @@ static void DrawDateHeader(Adafruit_GFX *gfx, int16_t x, int16_t y, tm_t *tm, st
GFX_setFont(gfx, u8g2_font_wqy9_t_lunar);
GFX_printf(gfx, "星期%s", Lunar_DayString[tm->tm_wday]);
DrawBattery(gfx, 365, 4, data->voltage);
DrawBattery(gfx, 365, 6, data->voltage);
GFX_setCursor(gfx, x + 270, y);
GFX_printf(gfx, "%s%s%s %s%s", Lunar_MonthLeapString[Lunar->IsLeap], Lunar_MonthString[Lunar->Month],
@@ -357,6 +371,10 @@ void DrawGUI(gui_data_t *data, buffer_callback draw, display_mode_t mode)
default:
break;
}
if ((mode == MODE_CALENDAR || mode == MODE_CLOCK) &&
(tm.tm_year + YEAR0 == 2025 && tm.tm_mon + 1 == 1)) {
DrawTimeSyncTip(&gfx);
}
} while(GFX_nextPage(&gfx, draw));
GFX_end(&gfx);