diff --git a/Firmware/ATC_Paper.bin b/Firmware/ATC_Paper.bin index 3157964..4a47c7b 100644 Binary files a/Firmware/ATC_Paper.bin and b/Firmware/ATC_Paper.bin differ diff --git a/Firmware/src/app.c b/Firmware/src/app.c index 224f770..879c826 100644 --- a/Firmware/src/app.c +++ b/Firmware/src/app.c @@ -11,7 +11,7 @@ #include "flash.h" #include "ota.h" #include "epd.h" -#include "time.h" +#include "etime.h" #include "bart_tif.h" RAM uint8_t battery_level; diff --git a/Firmware/src/cmd_parser.c b/Firmware/src/cmd_parser.c index cca3da6..c0222a5 100644 --- a/Firmware/src/cmd_parser.c +++ b/Firmware/src/cmd_parser.c @@ -5,7 +5,7 @@ #include "stack/ble/ble.h" #include "vendor/common/blt_common.h" -#include "time.h" +#include "etime.h" #include "flash.h" extern settings_struct settings; diff --git a/Firmware/src/epd.c b/Firmware/src/epd.c index c66f57c..ecad65c 100755 --- a/Firmware/src/epd.c +++ b/Firmware/src/epd.c @@ -1,4 +1,5 @@ #include +#include "etime.h" #include "tl_common.h" #include "main.h" #include "epd.h" @@ -25,7 +26,8 @@ RAM uint8_t epd_model = 0; // 0 = Undetected, 1 = BW213, 2 = BWR213, 3 = BWR154, const char *epd_model_string[] = {"NC", "BW213", "BWR213", "BWR154", "213ICE", "BWR296"}; RAM uint8_t epd_update_state = 0; -RAM uint8_t epd_scene = 1; +RAM uint8_t epd_scene = 2; +RAM uint8_t epd_wait_update = 0; RAM uint8_t hour_refresh = 100; RAM uint8_t minute_refresh = 100; @@ -49,9 +51,11 @@ void set_EPD_model(uint8_t model_nr) void set_EPD_scene(uint8_t scene) { epd_scene = scene; + epd_wait_update = 1; } + // Here we detect what E-Paper display is connected _attribute_ram_code_ void EPD_detect_model(void) { @@ -250,7 +254,7 @@ _attribute_ram_code_ void epd_display_tiff(uint8_t *pData, int iSize) } extern uint8_t mac_public[6]; -_attribute_ram_code_ void epd_display(uint32_t time_is, uint16_t battery_mv, int16_t temperature, uint8_t full_or_partial) +_attribute_ram_code_ void epd_display(uint32_t _time, uint16_t battery_mv, int16_t temperature, uint8_t full_or_partial) { uint8_t battery_level; @@ -298,7 +302,7 @@ _attribute_ram_code_ void epd_display(uint32_t time_is, uint16_t battery_mv, int obdWriteStringCustom(&obd, (GFXfont *)&Dialog_plain_16, 1, 17, (char *)buff, 1); sprintf(buff, "%s", BLE_conn_string[ble_get_connected()]); obdWriteStringCustom(&obd, (GFXfont *)&Dialog_plain_16, 232, 20, (char *)buff, 1); - sprintf(buff, "%02d:%02d", ((time_is / 60) / 60) % 24, (time_is / 60) % 60); + sprintf(buff, "%02d:%02d", ((_time / 60) / 60) % 24, (_time / 60) % 60); obdWriteStringCustom(&obd, (GFXfont *)&DSEG14_Classic_Mini_Regular_40, 75, 65, (char *)buff, 1); sprintf(buff, "-----%d'C-----", EPD_read_temp()); obdWriteStringCustom(&obd, (GFXfont *)&Special_Elite_Regular_30, 10, 95, (char *)buff, 1); @@ -322,26 +326,87 @@ _attribute_ram_code_ void epd_clear(void) { memset(epd_buffer, 0x00, epd_buffer_size); } +void update_time_scene(uint32_t _time, uint16_t battery_mv, int16_t temperature, void (*scene)(uint32_t, uint16_t, int16_t, uint8_t)) { + // default scene: show default time, battery, ble address, temperature + uint8_t current_minute = (_time / 60) % 60; -void epd_update(uint32_t time_is, uint16_t battery_mv, int16_t temperature) { - if (epd_scene == 1) { - // default scene: show default time, battery, ble address, temperature - uint8_t current_minute = (get_time() / 60) % 60; - if (current_minute != minute_refresh) + if (epd_update_state) + return; + + if (!epd_model) + { + EPD_detect_model(); + } + + if (epd_wait_update) { + scene(_time, battery_mv, temperature, 1); + epd_wait_update = 0; + } + + else if (current_minute != minute_refresh) + { + minute_refresh = current_minute; + uint8_t current_hour = ((_time / 60) / 60) % 24; + if (current_hour != hour_refresh) { - minute_refresh = current_minute; - uint8_t current_hour = ((get_time() / 60) / 60) % 24; - if (current_hour != hour_refresh) - { - hour_refresh = current_hour; - epd_display(get_time(), battery_mv, temperature, 1); - } - else - { - epd_display(get_time(), battery_mv, temperature, 0); - } + hour_refresh = current_hour; + scene(_time, battery_mv, temperature, 1); + } + else + { + scene(_time, battery_mv, temperature, 0); } - } else if (epd_scene == 0) { - // nothing to do. } } + +void epd_update(uint32_t _time, uint16_t battery_mv, int16_t temperature) { + switch(epd_scene) { + case 1: + update_time_scene(_time, battery_mv, temperature, epd_display); + break; + case 2: + update_time_scene(_time, battery_mv, temperature, epd_display_time_with_date); + break; + default: + break; + } +} + +void epd_display_time_with_date(uint32_t _time, uint16_t battery_mv, int16_t temperature, uint8_t full_or_partial) { + uint16_t battery_level; + + obdCreateVirtualDisplay(&obd, epd_width, epd_height, epd_temp); + obdFill(&obd, 0, 0); // fill with white + + char buff[100]; + battery_level = get_battery_level(battery_mv); + + sprintf(buff, "S24_%02X%02X%02X %s", mac_public[2], mac_public[1], mac_public[0], BLE_conn_string[ble_get_connected()]); + obdWriteStringCustom(&obd, (GFXfont *)&Dialog_plain_16, 1, 17, (char *)buff, 1); + + sprintf(buff, " %d%%", battery_level); + obdWriteStringCustom(&obd, (GFXfont *)&Dialog_plain_16, 216, 20, (char *)buff, 1); + + obdRectangle(&obd, 0, 25, 295, 27, 1, 1); + + sprintf(buff, "%02d:%02d", ((_time / 60) / 60) % 24, (_time / 60) % 60); + obdWriteStringCustom(&obd, (GFXfont *)&DSEG14_Classic_Mini_Regular_40, 35, 85, (char *)buff, 1); + + sprintf(buff, " %d'C", EPD_read_temp()); + obdWriteStringCustom(&obd, (GFXfont *)&Dialog_plain_16, 216, 50, (char *)buff, 1); + + obdRectangle(&obd, 216, 60, 295, 62, 1, 1); + + sprintf(buff, " %dmV", battery_mv); + obdWriteStringCustom(&obd, (GFXfont *)&Dialog_plain_16, 216, 84, (char *)buff, 1); + + obdRectangle(&obd, 214, 27, 216, 99, 1, 1); + obdRectangle(&obd, 0, 97, 295, 99, 1, 1); + + sprintf(buff, "%d-%02d-%02d", 2022, 6, 24); + obdWriteStringCustom(&obd, (GFXfont *)&Dialog_plain_16, 10, 120, (char *)buff, 1); + + + FixBuffer(epd_temp, epd_buffer, epd_width, epd_height); + EPD_Display(epd_buffer, epd_width * epd_height / 8, full_or_partial); +} \ No newline at end of file diff --git a/Firmware/src/epd.h b/Firmware/src/epd.h index dfb0163..164fc07 100644 --- a/Firmware/src/epd.h +++ b/Firmware/src/epd.h @@ -11,10 +11,13 @@ void init_epd(void); uint8_t EPD_read_temp(void); void EPD_Display(unsigned char *image, int size, uint8_t full_or_partial); void epd_display_tiff(uint8_t *pData, int iSize); -void epd_display(uint32_t time_is, uint16_t battery_mv, int16_t temperature, uint8_t full_or_partial); void epd_set_sleep(void); uint8_t epd_state_handler(void); void epd_display_char(uint8_t data); void epd_clear(void); -void epd_update(uint32_t time_is, uint16_t battery_mv, int16_t temperature); +void update_time_scene(uint32_t _time, uint16_t battery_mv, int16_t temperature, void (*scene)(uint32_t, uint16_t, int16_t, uint8_t)); +void epd_update(uint32_t _time, uint16_t battery_mv, int16_t temperature); + +void epd_display(uint32_t _time, uint16_t battery_mv, int16_t temperature, uint8_t full_or_partial); +void epd_display_time_with_date(uint32_t _time, uint16_t battery_mv, int16_t temperature, uint8_t full_or_partial); diff --git a/Firmware/src/time.c b/Firmware/src/etime.c similarity index 98% rename from Firmware/src/time.c rename to Firmware/src/etime.c index 1e44f00..93a35ee 100644 --- a/Firmware/src/time.c +++ b/Firmware/src/etime.c @@ -3,7 +3,7 @@ #include "drivers.h" #include "stack/ble/ble.h" #include "drivers/8258/flash.h" -#include "time.h" +#include "etime.h" #include "main.h" RAM uint16_t time_trime = 5000;// The higher the number the slower the time runs!, -32,768 to 32,767 @@ -51,4 +51,4 @@ _attribute_ram_code_ void set_time(uint32_t time_now) _attribute_ram_code_ uint32_t get_time(void) { return current_unix_time; -} +} \ No newline at end of file diff --git a/Firmware/src/time.h b/Firmware/src/etime.h similarity index 100% rename from Firmware/src/time.h rename to Firmware/src/etime.h diff --git a/Firmware/src/project.mk b/Firmware/src/project.mk index 65a96ce..a336bfc 100755 --- a/Firmware/src/project.mk +++ b/Firmware/src/project.mk @@ -7,7 +7,7 @@ $(OUT_PATH)/epd_ble_service.o \ $(OUT_PATH)/i2c.o \ $(OUT_PATH)/cmd_parser.o \ $(OUT_PATH)/flash.o \ -$(OUT_PATH)/time.o \ +$(OUT_PATH)/etime.o \ $(OUT_PATH)/epd_spi.o \ $(OUT_PATH)/epd.o \ $(OUT_PATH)/epd_bw_213.o \ diff --git a/readme.md b/readme.md index d8ba330..630d0cd 100644 --- a/readme.md +++ b/readme.md @@ -64,6 +64,8 @@ Firmware CRC32: 0xe62d501e - [x] 添加场景且支持切换 - [x] 图片模式 - [ ] web 支持图片切换 +- [x] 添加新的时间场景 +- [ ] 获取真实年月日 ### 计划新增 - [ ] 安卓端控制器 diff --git a/web_tools/index.html b/web_tools/index.html index cb40290..b550b37 100644 --- a/web_tools/index.html +++ b/web_tools/index.html @@ -264,6 +264,7 @@
+