mirror of
https://github.com/jam422470459/EPD-nRF52-hema213.git
synced 2025-12-06 08:32:54 +08:00
update calendar title bar
This commit is contained in:
@@ -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();
|
||||
|
||||
36
GUI/GUI.c
36
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]);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user