mirror of
https://github.com/RoCry/blozi-etag.git
synced 2026-05-12 03:44:46 +08:00
feat: add support for render BWR
This commit is contained in:
Binary file not shown.
@@ -7,7 +7,7 @@
|
||||
#include "epd_bw_213.h"
|
||||
#include "epd_bwr_213.h"
|
||||
#include "epd_bw_213_ice.h"
|
||||
#include "epd_bwr_154.h"
|
||||
//#include "epd_bwr_154.h"
|
||||
#include "epd_bwr_296.h"
|
||||
#include "drivers.h"
|
||||
#include "stack/ble/ble.h"
|
||||
@@ -82,10 +82,10 @@ _attribute_ram_code_ void EPD_detect_model(void)
|
||||
{
|
||||
epd_model = 2;
|
||||
}
|
||||
else if (EPD_BWR_154_detect())// Right now this will never trigger, the 154 is same to 213BWR right now.
|
||||
{
|
||||
epd_model = 3;
|
||||
}
|
||||
// else if (EPD_BWR_154_detect())// Right now this will never trigger, the 154 is same to 213BWR right now.
|
||||
// {
|
||||
// epd_model = 3;
|
||||
// }
|
||||
else if (EPD_BW_213_ice_detect())
|
||||
{
|
||||
epd_model = 4;
|
||||
@@ -120,8 +120,8 @@ _attribute_ram_code_ uint8_t EPD_read_temp(void)
|
||||
epd_temperature = EPD_BW_213_read_temp();
|
||||
else if (epd_model == 2)
|
||||
epd_temperature = EPD_BWR_213_read_temp();
|
||||
else if (epd_model == 3)
|
||||
epd_temperature = EPD_BWR_154_read_temp();
|
||||
// else if (epd_model == 3)
|
||||
// epd_temperature = EPD_BWR_154_read_temp();
|
||||
else if (epd_model == 4 || epd_model == 5)
|
||||
epd_temperature = EPD_BW_213_ice_read_temp();
|
||||
|
||||
@@ -132,7 +132,7 @@ _attribute_ram_code_ uint8_t EPD_read_temp(void)
|
||||
return epd_temperature;
|
||||
}
|
||||
|
||||
_attribute_ram_code_ void EPD_Display(unsigned char *image, int size, uint8_t full_or_partial)
|
||||
_attribute_ram_code_ void EPD_Display(unsigned char *image, unsigned char *red_image, int size, uint8_t full_or_partial)
|
||||
{
|
||||
if (!epd_model)
|
||||
EPD_detect_model();
|
||||
@@ -151,12 +151,13 @@ _attribute_ram_code_ void EPD_Display(unsigned char *image, int size, uint8_t fu
|
||||
epd_temperature = EPD_BW_213_Display(image, size, full_or_partial);
|
||||
else if (epd_model == 2)
|
||||
epd_temperature = EPD_BWR_213_Display(image, size, full_or_partial);
|
||||
else if (epd_model == 3)
|
||||
epd_temperature = EPD_BWR_154_Display(image, size, full_or_partial);
|
||||
// else if (epd_model == 3)
|
||||
// epd_temperature = EPD_BWR_154_Display(image, size, full_or_partial);
|
||||
else if (epd_model == 4)
|
||||
epd_temperature = EPD_BW_213_ice_Display(image, size, full_or_partial);
|
||||
else if (epd_model == 5)
|
||||
epd_temperature = EPD_BWR_296_Display(image, size, full_or_partial);
|
||||
epd_temperature = EPD_BWR_296_Display_BWR(image, red_image, size, full_or_partial);
|
||||
//epd_temperature = EPD_BWR_296_Display(image, size, full_or_partial);
|
||||
|
||||
epd_temperature_is_read = 1;
|
||||
epd_update_state = 1;
|
||||
@@ -171,8 +172,8 @@ _attribute_ram_code_ void epd_set_sleep(void)
|
||||
EPD_BW_213_set_sleep();
|
||||
else if (epd_model == 2)
|
||||
EPD_BWR_213_set_sleep();
|
||||
else if (epd_model == 3)
|
||||
EPD_BWR_154_set_sleep();
|
||||
// else if (epd_model == 3)
|
||||
// EPD_BWR_154_set_sleep();
|
||||
else if (epd_model == 4 || epd_model == 5)
|
||||
EPD_BW_213_ice_set_sleep();
|
||||
|
||||
@@ -248,12 +249,12 @@ _attribute_ram_code_ void TIFFDraw(TIFFDRAW *pDraw)
|
||||
_attribute_ram_code_ void epd_display_tiff(uint8_t *pData, int iSize)
|
||||
{
|
||||
// test G4 decoder
|
||||
memset(epd_buffer, 0xff, epd_buffer_size); // clear to white
|
||||
epd_clear();
|
||||
TIFF_openRAW(&tiff, 250, 122, BITDIR_MSB_FIRST, pData, iSize, TIFFDraw);
|
||||
TIFF_setDrawParameters(&tiff, 65536, TIFF_PIXEL_1BPP, 0, 0, 250, 122, NULL);
|
||||
TIFF_decode(&tiff);
|
||||
TIFF_close(&tiff);
|
||||
EPD_Display(epd_buffer, epd_buffer_size, 1);
|
||||
EPD_Display(epd_buffer, NULL, epd_buffer_size, 1);
|
||||
}
|
||||
|
||||
extern uint8_t mac_public[6];
|
||||
@@ -296,6 +297,8 @@ _attribute_ram_code_ void epd_display(struct date_time _time, uint16_t battery_m
|
||||
resolution_h = 128;
|
||||
}
|
||||
|
||||
epd_clear();
|
||||
|
||||
obdCreateVirtualDisplay(&obd, resolution_w, resolution_h, epd_temp);
|
||||
obdFill(&obd, 0, 0); // fill with white
|
||||
|
||||
@@ -312,7 +315,7 @@ _attribute_ram_code_ void epd_display(struct date_time _time, uint16_t battery_m
|
||||
sprintf(buff, "Battery %dmV %d%%", battery_mv, battery_level);
|
||||
obdWriteStringCustom(&obd, (GFXfont *)&Dialog_plain_16, 10, 120, (char *)buff, 1);
|
||||
FixBuffer(epd_temp, epd_buffer, resolution_w, resolution_h);
|
||||
EPD_Display(epd_buffer, resolution_w * resolution_h / 8, full_or_partial);
|
||||
EPD_Display(epd_buffer, NULL, resolution_w * resolution_h / 8, full_or_partial);
|
||||
}
|
||||
|
||||
_attribute_ram_code_ void epd_display_char(uint8_t data)
|
||||
@@ -322,12 +325,13 @@ _attribute_ram_code_ void epd_display_char(uint8_t data)
|
||||
{
|
||||
epd_buffer[i] = data;
|
||||
}
|
||||
EPD_Display(epd_buffer, epd_buffer_size, 1);
|
||||
EPD_Display(epd_buffer, NULL, epd_buffer_size, 1);
|
||||
}
|
||||
|
||||
_attribute_ram_code_ void epd_clear(void)
|
||||
{
|
||||
memset(epd_buffer, 0x00, epd_buffer_size);
|
||||
memset(epd_temp, 0x00, epd_buffer_size);
|
||||
}
|
||||
void update_time_scene(struct date_time _time, uint16_t battery_mv, int16_t temperature, void (*scene)(struct date_time, uint16_t, int16_t, uint8_t)) {
|
||||
// default scene: show default time, battery, ble address, temperature
|
||||
@@ -375,6 +379,8 @@ void epd_update(struct date_time _time, uint16_t battery_mv, int16_t temperature
|
||||
void epd_display_time_with_date(struct date_time _time, uint16_t battery_mv, int16_t temperature, uint8_t full_or_partial) {
|
||||
uint16_t battery_level;
|
||||
|
||||
epd_clear();
|
||||
|
||||
obdCreateVirtualDisplay(&obd, epd_width, epd_height, epd_temp);
|
||||
obdFill(&obd, 0, 0); // fill with white
|
||||
|
||||
@@ -408,5 +414,6 @@ void epd_display_time_with_date(struct date_time _time, uint16_t battery_mv, int
|
||||
|
||||
|
||||
FixBuffer(epd_temp, epd_buffer, epd_width, epd_height);
|
||||
EPD_Display(epd_buffer, epd_width * epd_height / 8, full_or_partial);
|
||||
|
||||
EPD_Display(epd_buffer, NULL, epd_width * epd_height / 8, full_or_partial);
|
||||
}
|
||||
@@ -10,7 +10,7 @@ void set_EPD_wait_flush();
|
||||
|
||||
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(unsigned char *image, unsigned char * red_image, int size, uint8_t full_or_partial);
|
||||
void epd_display_tiff(uint8_t *pData, int iSize);
|
||||
void epd_set_sleep(void);
|
||||
uint8_t epd_state_handler(void);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "epd.h"
|
||||
#include "ble.h"
|
||||
|
||||
extern uint8_t *epd_temp;
|
||||
extern uint8_t epd_temp[epd_buffer_size];
|
||||
|
||||
#define ASSERT_MIN_LEN(val, min_len) \
|
||||
if (val < min_len) \
|
||||
@@ -31,14 +31,15 @@ int epd_ble_handle_write(void *p)
|
||||
{
|
||||
// Clear EPD display.
|
||||
case 0x00:
|
||||
ASSERT_MIN_LEN(payload_len, 2);
|
||||
memset(epd_buffer, payload[1], sizeof(epd_buffer));
|
||||
ASSERT_MIN_LEN(payload_len, 2);
|
||||
memset(epd_buffer, payload[1], epd_buffer_size);
|
||||
memset(epd_temp, payload[1], epd_buffer_size);
|
||||
ble_set_connection_speed(40);
|
||||
return 0;
|
||||
// Push buffer to display.
|
||||
case 0x01:
|
||||
ble_set_connection_speed(200);
|
||||
EPD_Display(epd_buffer, epd_buffer_size, 1);
|
||||
EPD_Display(epd_buffer, epd_temp, epd_buffer_size, payload[1]);
|
||||
return 0;
|
||||
// Set byte_pos.
|
||||
case 0x02:
|
||||
@@ -47,14 +48,18 @@ int epd_ble_handle_write(void *p)
|
||||
return 0;
|
||||
// Write data to image buffer.
|
||||
case 0x03:
|
||||
if ((payload[1] << 8 | payload[2]) + payload_len - 3 >= epd_buffer_size + 1)
|
||||
if ((payload[2] << 8 | payload[3]) + payload_len - 4 >= epd_buffer_size + 1)
|
||||
{
|
||||
out_buffer[0] = 0x00;
|
||||
out_buffer[1] = 0x00;
|
||||
bls_att_pushNotifyData(EPD_BLE_CMD_OUT_DP_H, out_buffer, 2);
|
||||
return 0;
|
||||
}
|
||||
memcpy(epd_buffer + (payload[1] << 8 | payload[2]), payload + 3, payload_len - 3);
|
||||
if (payload[1] == 0xff) {
|
||||
memcpy(epd_buffer + (payload[2] << 8 | payload[3]), payload + 4, payload_len - 4);
|
||||
} else {
|
||||
memcpy(epd_temp + (payload[2] << 8 | payload[3]), payload + 4, payload_len - 4);
|
||||
}
|
||||
|
||||
out_buffer[0] = payload_len >> 8;
|
||||
out_buffer[1] = payload_len & 0xff;
|
||||
|
||||
@@ -257,6 +257,125 @@ _attribute_ram_code_ uint8_t EPD_BWR_296_Display(unsigned char *image, int size,
|
||||
return epd_temperature;
|
||||
}
|
||||
|
||||
_attribute_ram_code_ uint8_t EPD_BWR_296_Display_BWR(unsigned char *image, unsigned char *red_image, int size, uint8_t full_or_partial) {
|
||||
if (red_image == NULL) {
|
||||
return EPD_BWR_296_Display(image, size, full_or_partial);
|
||||
}
|
||||
|
||||
uint8_t epd_temperature = 0 ;
|
||||
|
||||
// SW Reset
|
||||
EPD_WriteCmd(0x12);
|
||||
|
||||
EPD_CheckStatus_inverted(100);
|
||||
|
||||
// Set Analog Block control
|
||||
EPD_WriteCmd(0x74);
|
||||
EPD_WriteData(0x54);
|
||||
// Set Digital Block control
|
||||
EPD_WriteCmd(0x7E);
|
||||
EPD_WriteData(0x3B);
|
||||
|
||||
// Booster soft start
|
||||
EPD_WriteCmd(0x0C);
|
||||
EPD_WriteData(0x8B);
|
||||
EPD_WriteData(0x9C);
|
||||
EPD_WriteData(0x96);
|
||||
EPD_WriteData(0x0F);
|
||||
|
||||
// Driver output control
|
||||
EPD_WriteCmd(0x01);
|
||||
EPD_WriteData(0x28);
|
||||
EPD_WriteData(0x01);
|
||||
EPD_WriteData(0x01);
|
||||
|
||||
// Data entry mode setting
|
||||
EPD_WriteCmd(0x11);
|
||||
EPD_WriteData(0x01);
|
||||
|
||||
// Set RAM X- Address Start/End
|
||||
EPD_WriteCmd(0x44);
|
||||
EPD_WriteData(0x00);
|
||||
EPD_WriteData(0x0F);
|
||||
|
||||
// Set RAM Y- Address Start/End
|
||||
EPD_WriteCmd(0x45);
|
||||
EPD_WriteData(0x28); //0x0127-->(295+1)=296
|
||||
EPD_WriteData(0x01);
|
||||
EPD_WriteData(0x00);
|
||||
EPD_WriteData(0x00);
|
||||
|
||||
// Border waveform control
|
||||
EPD_WriteCmd(0x3C);
|
||||
EPD_WriteData(0x05);
|
||||
|
||||
// Display update control
|
||||
EPD_WriteCmd(0x21);
|
||||
EPD_WriteData(0x00);
|
||||
EPD_WriteData(0x80);
|
||||
|
||||
// Temperature sensor control
|
||||
EPD_WriteCmd(0x18);
|
||||
EPD_WriteData(0x80);
|
||||
|
||||
// Display update control
|
||||
EPD_WriteCmd(0x22);
|
||||
EPD_WriteData(0xB1);
|
||||
|
||||
// Master Activation
|
||||
EPD_WriteCmd(0x20);
|
||||
|
||||
EPD_CheckStatus_inverted(100);
|
||||
|
||||
// Temperature sensor read from register
|
||||
EPD_WriteCmd(0x1B);
|
||||
epd_temperature = EPD_SPI_read();
|
||||
EPD_SPI_read();
|
||||
|
||||
WaitMs(5);
|
||||
|
||||
// Set RAM X address
|
||||
EPD_WriteCmd(0x4E);
|
||||
EPD_WriteData(0x00);
|
||||
|
||||
// Set RAM Y address
|
||||
EPD_WriteCmd(0x4F);
|
||||
EPD_WriteData(0x28);
|
||||
EPD_WriteData(0x01);
|
||||
|
||||
EPD_LoadImage(image, size, 0x24);
|
||||
|
||||
// Set RAM X address
|
||||
EPD_WriteCmd(0x4E);
|
||||
EPD_WriteData(0x00);
|
||||
|
||||
// Set RAM Y address
|
||||
EPD_WriteCmd(0x4F);
|
||||
EPD_WriteData(0x28);
|
||||
EPD_WriteData(0x01);
|
||||
|
||||
EPD_LoadImage(red_image, size, 0x26);
|
||||
|
||||
int i;
|
||||
if (!full_or_partial)
|
||||
{
|
||||
EPD_WriteCmd(0x32);
|
||||
for (i = 0; i < sizeof(LUT_bwr_296_part); i++)
|
||||
{
|
||||
EPD_WriteData(LUT_bwr_296_part[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Display update control
|
||||
EPD_WriteCmd(0x22);
|
||||
EPD_WriteData(0xC7);
|
||||
|
||||
// Master Activation
|
||||
EPD_WriteCmd(0x20);
|
||||
|
||||
return epd_temperature;
|
||||
}
|
||||
|
||||
_attribute_ram_code_ void EPD_BWR_296_set_sleep(void)
|
||||
{
|
||||
// deep sleep
|
||||
|
||||
@@ -3,4 +3,5 @@
|
||||
uint8_t EPD_BWR_296_detect(void);
|
||||
uint8_t EPD_BWR_296_read_temp(void);
|
||||
uint8_t EPD_BWR_296_Display(unsigned char *image, int size, uint8_t full_or_partial);
|
||||
uint8_t EPD_BWR_296_Display_BWR(unsigned char *image, unsigned char *red_image, int size, uint8_t full_or_partial);
|
||||
void EPD_BWR_296_set_sleep(void);
|
||||
@@ -14,7 +14,6 @@ $(OUT_PATH)/epd_bw_213.o \
|
||||
$(OUT_PATH)/epd_bwr_296.o \
|
||||
$(OUT_PATH)/epd_bwr_213.o \
|
||||
$(OUT_PATH)/epd_bw_213_ice.o \
|
||||
$(OUT_PATH)/epd_bwr_154.o \
|
||||
$(OUT_PATH)/ota.o \
|
||||
$(OUT_PATH)/led.o \
|
||||
$(OUT_PATH)/uart.o \
|
||||
|
||||
Reference in New Issue
Block a user