mirror of
https://github.com/RoCry/blozi-etag.git
synced 2025-12-06 09:02:49 +08:00
feat: add scene switch
This commit is contained in:
Binary file not shown.
@@ -18,9 +18,6 @@ RAM uint8_t battery_level;
|
||||
RAM uint16_t battery_mv;
|
||||
RAM int16_t temperature;
|
||||
|
||||
RAM uint8_t hour_refresh = 100;
|
||||
RAM uint8_t minute_refresh = 100;
|
||||
|
||||
// Settings
|
||||
extern settings_struct settings;
|
||||
|
||||
@@ -58,21 +55,7 @@ _attribute_ram_code_ void main_loop(void)
|
||||
ble_send_temp(EPD_read_temp() * 10);
|
||||
}
|
||||
|
||||
uint8_t current_minute = (get_time() / 60) % 60;
|
||||
if (current_minute != minute_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);
|
||||
}
|
||||
}
|
||||
epd_update(get_time(), battery_mv, temperature);
|
||||
|
||||
if (time_reached_period(Timer_CH_0, 10))
|
||||
{
|
||||
|
||||
@@ -65,4 +65,7 @@ void cmd_parser(void * p){
|
||||
else if(inData == 0xE0){// force set an EPD model, if it wasnt detect automatically correct
|
||||
set_EPD_model(req->dat[1]);
|
||||
}
|
||||
else if(inData == 0xE1){// force set an EPD scene
|
||||
set_EPD_scene(req->dat[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,11 @@ 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 hour_refresh = 100;
|
||||
RAM uint8_t minute_refresh = 100;
|
||||
|
||||
const char *BLE_conn_string[] = {"BLE 0", "BLE 1"};
|
||||
RAM uint8_t epd_temperature_is_read = 0;
|
||||
RAM uint8_t epd_temperature = 0;
|
||||
@@ -40,6 +45,13 @@ void set_EPD_model(uint8_t model_nr)
|
||||
epd_model = model_nr;
|
||||
}
|
||||
|
||||
// With this we can force a display if it wasnt detected correctly
|
||||
void set_EPD_scene(uint8_t scene)
|
||||
{
|
||||
epd_scene = scene;
|
||||
}
|
||||
|
||||
|
||||
// Here we detect what E-Paper display is connected
|
||||
_attribute_ram_code_ void EPD_detect_model(void)
|
||||
{
|
||||
@@ -310,3 +322,26 @@ _attribute_ram_code_ void epd_clear(void)
|
||||
{
|
||||
memset(epd_buffer, 0x00, epd_buffer_size);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
} else if (epd_scene == 0) {
|
||||
// nothing to do.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#define epd_buffer_size ((epd_height/8) * epd_width)
|
||||
|
||||
void set_EPD_model(uint8_t model_nr);
|
||||
void set_EPD_scene(uint8_t scene);
|
||||
|
||||
void init_epd(void);
|
||||
uint8_t EPD_read_temp(void);
|
||||
void EPD_Display(unsigned char *image, int size, uint8_t full_or_partial);
|
||||
@@ -13,4 +15,6 @@ void epd_display(uint32_t time_is, uint16_t battery_mv, int16_t temperature, uin
|
||||
void epd_set_sleep(void);
|
||||
uint8_t epd_state_handler(void);
|
||||
void epd_display_char(uint8_t data);
|
||||
void epd_clear(void);
|
||||
void epd_clear(void);
|
||||
|
||||
void epd_update(uint32_t time_is, uint16_t battery_mv, int16_t temperature);
|
||||
|
||||
5
docs/ch430添加RTS.md
Normal file
5
docs/ch430添加RTS.md
Normal file
@@ -0,0 +1,5 @@
|
||||
### ch430添加rts接口
|
||||
|
||||
- 检查芯片是否为ch430g
|
||||
- 查看ch430g引脚定义图
|
||||
- 将右侧第三个引脚RTS,焊接飞线引出
|
||||
@@ -61,6 +61,9 @@ Firmware CRC32: 0xe62d501e
|
||||
- [x] python 图片生成脚本
|
||||
- [x] 蓝牙发送图片, 显示大小不对问题解决
|
||||
- [x] 添加蓝牙上传图片后notify
|
||||
- [x] 添加场景且支持切换
|
||||
- [x] 图片模式
|
||||
- [ ] web 支持图片切换
|
||||
|
||||
### 计划新增
|
||||
- [ ] 安卓端控制器
|
||||
|
||||
BIN
tools/data/images/mao.bmp
Normal file
BIN
tools/data/images/mao.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 111 KiB |
BIN
tools/data/images/test-02.bmp
Normal file
BIN
tools/data/images/test-02.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 111 KiB |
@@ -5,4 +5,4 @@ from tools.utils import image2hex, load_test_image
|
||||
|
||||
if __name__ == '__main__':
|
||||
# print(image2hex(load_test_image('test-01.bmp')))
|
||||
print(image2hex(load_test_image('mao.bmp'), steinberg=True))
|
||||
print(image2hex(load_test_image('mao.bmp')))
|
||||
|
||||
@@ -29,15 +29,11 @@ def hex2image(hex_string, width, height):
|
||||
image.show('test')
|
||||
|
||||
|
||||
def image2hex(image, width=296, height=128, steinberg=False):
|
||||
def image2hex(image, width=296, height=128):
|
||||
if isinstance(image, str):
|
||||
image = Image.open(image)
|
||||
|
||||
mode = None
|
||||
if steinberg:
|
||||
mode = Image.FLOYDSTEINBERG
|
||||
|
||||
return bytes2hex(image.resize((width, height)).rotate(90, expand=True).resize((height, width)).convert('1', dither=mode).tobytes())
|
||||
return bytes2hex(image.resize((width, height)).rotate(90, expand=True).resize((height, width)).convert('1').tobytes())
|
||||
|
||||
|
||||
def load_test_image(name):
|
||||
|
||||
@@ -260,10 +260,10 @@
|
||||
|
||||
<input type="text" id="cmdTXT" value="0055">
|
||||
<button type="button" onclick="triggerEpdCmd(document.getElementById("cmdTXT").value);">发送指令</button>
|
||||
<button type="button" onclick="triggerRxTxCmd('b0')">不显示电量</button>
|
||||
<button type="button" onclick="triggerRxTxCmd('a0')">xxx</button>
|
||||
<button type="button" onclick="triggerRxTxCmd('de')">恢复默认配置</button>
|
||||
<button type="button" onclick="triggerRxTxCmd('df')">保存配置</button>
|
||||
<br>
|
||||
<br>
|
||||
<button type="button" onclick="triggerRxTxCmd('e100')" title="点击该按钮,然后上传图片。图片将永久显示到屏幕上">设置为图片模式</button>
|
||||
<button type="button" onclick="triggerRxTxCmd('e101')" title="点击该按钮, 切换为时钟模式">设置为时钟模式1</button>
|
||||
<button type="button" onclick="clearScreen('00')">清屏全黑</button>
|
||||
<button type="button" onclick="clearScreen('ff')">清屏全白</button>
|
||||
<br><br>
|
||||
|
||||
Reference in New Issue
Block a user