From 390793928cdb5620ef885c21f8e7b54c1e56054f Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Tue, 1 Jul 2025 17:15:44 +0800 Subject: [PATCH] update calendar title bar --- EPD/EPD_service.c | 7 +++++++ GUI/GUI.c | 36 ++++++++++++++++++------------------ GUI/GUI.h | 1 + emulator.c | 1 + 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/EPD/EPD_service.c b/EPD/EPD_service.c index 63a8992..8621190 100644 --- a/EPD/EPD_service.c +++ b/EPD/EPD_service.c @@ -47,6 +47,13 @@ static void epd_gui_update(void * p_event_data, uint16_t event_size) .temperature = epd->drv->read_temp(), .voltage = EPD_ReadVoltage(), }; + + char dev_name[20]; + uint16_t dev_name_len = sizeof(dev_name); + uint32_t err_code = sd_ble_gap_device_name_get((uint8_t *)dev_name, &dev_name_len); + if (err_code == NRF_SUCCESS && dev_name_len > 0) + memcpy(data.ssid, dev_name, sizeof(data.ssid) - 1); + DrawGUI(&data, epd->drv->write_image, (display_mode_t)p_epd->config.display_mode); epd->drv->refresh(); EPD_GPIO_Uninit(); diff --git a/GUI/GUI.c b/GUI/GUI.c index 0b8053a..db99ac3 100644 --- a/GUI/GUI.c +++ b/GUI/GUI.c @@ -145,7 +145,7 @@ static void DrawTimeSyncTip(Adafruit_GFX *gfx) static void DrawBattery(Adafruit_GFX *gfx, int16_t x, int16_t y, float voltage) { - uint8_t level = (uint8_t)(voltage * 100 / 4.2); + uint8_t level = (uint8_t)(voltage * 100 / 3.6f); GFX_setCursor(gfx, x - 26, y + 9); GFX_setFont(gfx, u8g2_font_wqy9_t_lunar); GFX_printf(gfx, "%.1fV", voltage); @@ -162,33 +162,26 @@ static void DrawTemperature(Adafruit_GFX *gfx, int16_t x, int16_t y, int8_t temp GFX_printf(gfx, "%d℃", temp); } -static void DrawDate(Adafruit_GFX *gfx, int16_t x, int16_t y, tm_t *tm) +static void DrawDateHeader(Adafruit_GFX *gfx, int16_t x, int16_t y, tm_t *tm, struct Lunar_Date *Lunar, gui_data_t *data) { GFX_setCursor(gfx, x, y); GFX_printf_styled(gfx, GFX_RED, GFX_WHITE, u8g2_font_helvB18_tn, "%d", tm->tm_year + YEAR0); GFX_printf_styled(gfx, GFX_BLACK, GFX_WHITE, u8g2_font_wqy12_t_lunar, "年"); - GFX_printf_styled(gfx, GFX_RED, GFX_WHITE, u8g2_font_helvB18_tn, "%02d", tm->tm_mon + 1); + GFX_printf_styled(gfx, GFX_RED, GFX_WHITE, u8g2_font_helvB18_tn, "%d", tm->tm_mon + 1); GFX_printf_styled(gfx, GFX_BLACK, GFX_WHITE, u8g2_font_wqy12_t_lunar, "月"); - GFX_printf_styled(gfx, GFX_RED, GFX_WHITE, u8g2_font_helvB18_tn, "%02d", tm->tm_mday); - GFX_printf_styled(gfx, GFX_BLACK, GFX_WHITE, u8g2_font_wqy12_t_lunar, "日 "); -} -static void DrawDateHeader(Adafruit_GFX *gfx, int16_t x, int16_t y, tm_t *tm, struct Lunar_Date *Lunar, gui_data_t *data) -{ - DrawDate(gfx, x, y, tm); GFX_setFont(gfx, u8g2_font_wqy9_t_lunar); - GFX_printf(gfx, "星期%s", Lunar_DayString[tm->tm_wday]); - - DrawBattery(gfx, 366, 6, data->voltage); - - GFX_setCursor(gfx, x + (Lunar->IsLeap ? 266 : 272), y); - GFX_printf(gfx, "%s%s%s %s%s", Lunar_MonthLeapString[Lunar->IsLeap], Lunar_MonthString[Lunar->Month], + if (Lunar->IsLeap) GFX_printf(gfx, " "); + GFX_printf(gfx, "%s%s%s %s%s年", Lunar_MonthLeapString[Lunar->IsLeap], Lunar_MonthString[Lunar->Month], Lunar_DateString[Lunar->Date], Lunar_StemStrig[LUNAR_GetStem(Lunar)], Lunar_BranchStrig[LUNAR_GetBranch(Lunar)]); GFX_setTextColor(gfx, GFX_RED, GFX_WHITE); - GFX_printf(gfx, "%s", Lunar_ZodiacString[LUNAR_GetZodiac(Lunar)]); + GFX_printf(gfx, "[%s]", Lunar_ZodiacString[LUNAR_GetZodiac(Lunar)]); + GFX_setTextColor(gfx, GFX_BLACK, GFX_WHITE); - GFX_printf(gfx, "年"); + DrawBattery(gfx, 366, 6, data->voltage); + GFX_setCursor(gfx, 310, y); + GFX_printf(gfx, "%s", data->ssid); } static void DrawWeekHeader(Adafruit_GFX *gfx, int16_t x, int16_t y) @@ -308,7 +301,14 @@ static void DrawTime(Adafruit_GFX *gfx, tm_t *tm, int16_t x, int16_t y, uint16_t static void DrawClock(Adafruit_GFX *gfx, tm_t *tm, struct Lunar_Date *Lunar, gui_data_t *data) { - DrawDate(gfx, 40, 36, tm); + GFX_setCursor(gfx, 40, 36); + GFX_printf_styled(gfx, GFX_RED, GFX_WHITE, u8g2_font_helvB18_tn, "%d", tm->tm_year + YEAR0); + GFX_printf_styled(gfx, GFX_BLACK, GFX_WHITE, u8g2_font_wqy12_t_lunar, "年"); + GFX_printf_styled(gfx, GFX_RED, GFX_WHITE, u8g2_font_helvB18_tn, "%02d", tm->tm_mon + 1); + GFX_printf_styled(gfx, GFX_BLACK, GFX_WHITE, u8g2_font_wqy12_t_lunar, "月"); + GFX_printf_styled(gfx, GFX_RED, GFX_WHITE, u8g2_font_helvB18_tn, "%02d", tm->tm_mday); + GFX_printf_styled(gfx, GFX_BLACK, GFX_WHITE, u8g2_font_wqy12_t_lunar, "日 "); + GFX_setCursor(gfx, 40, 58); GFX_setFont(gfx, u8g2_font_wqy9_t_lunar); GFX_printf(gfx, "星期%s", Lunar_DayString[tm->tm_wday]); diff --git a/GUI/GUI.h b/GUI/GUI.h index 906e7e3..e93d926 100644 --- a/GUI/GUI.h +++ b/GUI/GUI.h @@ -20,6 +20,7 @@ typedef struct { uint32_t timestamp; int8_t temperature; float voltage; + char ssid[13]; } gui_data_t; void DrawGUI(gui_data_t *data, buffer_callback draw, display_mode_t mode); diff --git a/emulator.c b/emulator.c index c713c1a..b0f806e 100644 --- a/emulator.c +++ b/emulator.c @@ -188,6 +188,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) .timestamp = g_display_time, .temperature = 25, .voltage = 3.2f, + .ssid = "NRF_EPD_84AC", }; // Call DrawGUI to render the interface