feat: add new date scene

This commit is contained in:
reece
2022-06-24 03:30:31 +08:00
parent c7f460b131
commit 9c93d157a5
10 changed files with 99 additions and 28 deletions

Binary file not shown.

View File

@@ -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;

View File

@@ -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;

View File

@@ -1,4 +1,5 @@
#include <stdint.h>
#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);
}

View File

@@ -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);

View File

@@ -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;
}
}

View File

@@ -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 \

View File

@@ -64,6 +64,8 @@ Firmware CRC32: 0xe62d501e
- [x] 添加场景且支持切换
- [x] 图片模式
- [ ] web 支持图片切换
- [x] 添加新的时间场景
- [ ] 获取真实年月日
### 计划新增
- [ ] 安卓端控制器

View File

@@ -264,6 +264,7 @@
<br>
<button type="button" onclick="triggerRxTxCmd('e100')" title="点击该按钮,然后上传图片。图片将永久显示到屏幕上">设置为图片模式</button>
<button type="button" onclick="triggerRxTxCmd('e101')" title="点击该按钮, 切换为时钟模式">设置为时钟模式1</button>
<button type="button" onclick="triggerRxTxCmd('e102')" title="点击该按钮, 切换为时钟模式">设置为时钟模式2</button>
<button type="button" onclick="clearScreen('00')">清屏全黑</button>
<button type="button" onclick="clearScreen('ff')">清屏全白</button>
<br><br>