mirror of
https://github.com/RoCry/blozi-etag.git
synced 2026-05-12 03:44:46 +08:00
feat: add scripts/web tools
This commit is contained in:
Binary file not shown.
@@ -91,6 +91,7 @@ static const u8 my_EPD_BLEUUID[16] = { EPD_BLE_CHAR_UUID };
|
||||
#define EPD_BLE_SERVICE_UUID 0x38, 0x9a, 0x7d, 0x21, 0xd3, 0x83, 0x4e, 0x04, 0xba, 0xa3, 0xa9, 0xeb, 0x10, 0x7b, 0x18, 0x13
|
||||
static const u8 my_EPD_BLE_ServiceUUID[16] = { EPD_BLE_SERVICE_UUID };
|
||||
static u8 my_EPD_BLE_Data = 0x00;
|
||||
static u8 my_EPD_BLEInCCC[2];
|
||||
|
||||
// Include attribute (Battery service)
|
||||
static const u16 include[3] = {BATT_PS_H, BATT_LEVEL_INPUT_CCB_H, SERVICE_UUID_BATTERY};
|
||||
@@ -150,7 +151,7 @@ static const u8 my_RxTxCharVal[5] = {
|
||||
|
||||
//// EPD_BLE attribute values
|
||||
static const u8 my_EPD_BLECharVal[19] = {
|
||||
CHAR_PROP_READ | CHAR_PROP_WRITE,
|
||||
CHAR_PROP_NOTIFY | CHAR_PROP_WRITE,
|
||||
U16_LO(EPD_BLE_CMD_OUT_DP_H), U16_HI(EPD_BLE_CMD_OUT_DP_H),
|
||||
EPD_BLE_CHAR_UUID,
|
||||
};
|
||||
@@ -196,9 +197,10 @@ static const attribute_t my_Attributes[] = {
|
||||
{0,ATT_PERMISSIONS_WRITE, 2,sizeof(my_RxTx_Data),(u8*)(&my_RxTxUUID), (&my_RxTx_Data), &RxTxWrite}, //value
|
||||
{0,ATT_PERMISSIONS_RDWR,2,sizeof(RxTxValueInCCC),(u8*)(&clientCharacterCfgUUID), (u8*)(RxTxValueInCCC), 0}, //value
|
||||
////////////////////////////////////// EPD_BLE ////////////////////////////////////////////////////
|
||||
{3,ATT_PERMISSIONS_READ, 2, 16,(u8*)(&my_primaryServiceUUID), (u8*)(&my_EPD_BLE_ServiceUUID), 0},
|
||||
{4,ATT_PERMISSIONS_READ, 2, 16,(u8*)(&my_primaryServiceUUID), (u8*)(&my_EPD_BLE_ServiceUUID), 0},
|
||||
{0,ATT_PERMISSIONS_READ, 2, sizeof(my_EPD_BLECharVal), (u8*)(&my_characterUUID), (u8*)(my_EPD_BLECharVal), 0},
|
||||
{0,ATT_PERMISSIONS_WRITE, 16, sizeof(my_EPD_BLE_Data), (u8*)(&my_EPD_BLEUUID), (&my_EPD_BLE_Data), (att_readwrite_callback_t) &epd_ble_handle_write},
|
||||
{0,ATT_PERMISSIONS_RDWR, 2, sizeof(my_EPD_BLEInCCC),(u8*)(&clientCharacterCfgUUID), (u8*)(my_EPD_BLEInCCC), 0}, //value
|
||||
};
|
||||
|
||||
void my_att_init(void)
|
||||
|
||||
@@ -240,6 +240,8 @@ _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)
|
||||
{
|
||||
uint8_t battery_level;
|
||||
|
||||
if (epd_update_state)
|
||||
return;
|
||||
|
||||
@@ -279,6 +281,7 @@ _attribute_ram_code_ void epd_display(uint32_t time_is, uint16_t battery_mv, int
|
||||
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], epd_model_string[epd_model]);
|
||||
obdWriteStringCustom(&obd, (GFXfont *)&Dialog_plain_16, 1, 17, (char *)buff, 1);
|
||||
sprintf(buff, "%s", BLE_conn_string[ble_get_connected()]);
|
||||
@@ -287,7 +290,7 @@ _attribute_ram_code_ void epd_display(uint32_t time_is, uint16_t battery_mv, int
|
||||
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);
|
||||
sprintf(buff, "Battery %dmV", battery_mv);
|
||||
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);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#define epd_height 200
|
||||
#define epd_width 200
|
||||
#define epd_height 128
|
||||
#define epd_width 296
|
||||
#define epd_buffer_size ((epd_height/8) * epd_width)
|
||||
|
||||
void set_EPD_model(uint8_t model_nr);
|
||||
|
||||
@@ -23,6 +23,7 @@ int epd_ble_handle_write(void *p)
|
||||
rf_packet_att_write_t *req = (rf_packet_att_write_t *)p;
|
||||
uint8_t *payload = &req->value;
|
||||
unsigned int payload_len = req->l2capLen - 3;
|
||||
uint8_t out_buffer[20] = {0};
|
||||
|
||||
ASSERT_MIN_LEN(payload_len, 1);
|
||||
|
||||
@@ -46,12 +47,20 @@ int epd_ble_handle_write(void *p)
|
||||
return 0;
|
||||
// Write data to image buffer.
|
||||
case 0x03:
|
||||
if (byte_pos + payload_len - 1 >= sizeof(epd_buffer) + 1)
|
||||
if (byte_pos + payload_len - 1 >= 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 + byte_pos, payload + 1, payload_len - 1);
|
||||
|
||||
byte_pos += payload_len - 1;
|
||||
|
||||
out_buffer[0] = payload_len >> 8;
|
||||
out_buffer[1] = payload_len & 0xff;
|
||||
bls_att_pushNotifyData(EPD_BLE_CMD_OUT_DP_H, out_buffer, 2);
|
||||
return 0;
|
||||
case 0x04: // decode & display a TIFF image
|
||||
epd_display_tiff(epd_buffer, byte_pos);
|
||||
|
||||
@@ -60,7 +60,7 @@ _attribute_ram_code_ uint8_t EPD_BWR_296_detect(void)
|
||||
_attribute_ram_code_ uint8_t EPD_BWR_296_read_temp(void)
|
||||
{
|
||||
uint8_t epd_temperature = 0 ;
|
||||
|
||||
|
||||
// SW Reset
|
||||
EPD_WriteCmd(0x12);
|
||||
|
||||
@@ -118,7 +118,7 @@ _attribute_ram_code_ uint8_t EPD_BWR_296_read_temp(void)
|
||||
// Display update control
|
||||
EPD_WriteCmd(0x22);
|
||||
EPD_WriteData(0xB1);
|
||||
|
||||
|
||||
// Master Activation
|
||||
EPD_WriteCmd(0x20);
|
||||
|
||||
@@ -126,11 +126,11 @@ _attribute_ram_code_ uint8_t EPD_BWR_296_read_temp(void)
|
||||
|
||||
// Temperature sensor read from register
|
||||
EPD_WriteCmd(0x1B);
|
||||
epd_temperature = EPD_SPI_read();
|
||||
epd_temperature = EPD_SPI_read();
|
||||
EPD_SPI_read();
|
||||
|
||||
WaitMs(5);
|
||||
|
||||
|
||||
// deep sleep
|
||||
EPD_WriteCmd(0x10);
|
||||
EPD_WriteData(0x01);
|
||||
@@ -138,10 +138,9 @@ _attribute_ram_code_ uint8_t EPD_BWR_296_read_temp(void)
|
||||
return epd_temperature;
|
||||
}
|
||||
|
||||
_attribute_ram_code_ uint8_t EPD_BWR_296_Display(unsigned char *image, int size, uint8_t full_or_partial)
|
||||
{
|
||||
_attribute_ram_code_ uint8_t EPD_BWR_296_Display(unsigned char *image, int size, uint8_t full_or_partial) {
|
||||
uint8_t epd_temperature = 0 ;
|
||||
|
||||
|
||||
// SW Reset
|
||||
EPD_WriteCmd(0x12);
|
||||
|
||||
@@ -178,7 +177,7 @@ _attribute_ram_code_ uint8_t EPD_BWR_296_Display(unsigned char *image, int size,
|
||||
|
||||
// Set RAM Y- Address Start/End
|
||||
EPD_WriteCmd(0x45);
|
||||
EPD_WriteData(0x27); //0x0127-->(295+1)=296
|
||||
EPD_WriteData(0x28); //0x0127-->(295+1)=296
|
||||
EPD_WriteData(0x01);
|
||||
EPD_WriteData(0x00);
|
||||
EPD_WriteData(0x00);
|
||||
@@ -199,7 +198,7 @@ _attribute_ram_code_ uint8_t EPD_BWR_296_Display(unsigned char *image, int size,
|
||||
// Display update control
|
||||
EPD_WriteCmd(0x22);
|
||||
EPD_WriteData(0xB1);
|
||||
|
||||
|
||||
// Master Activation
|
||||
EPD_WriteCmd(0x20);
|
||||
|
||||
@@ -207,7 +206,7 @@ _attribute_ram_code_ uint8_t EPD_BWR_296_Display(unsigned char *image, int size,
|
||||
|
||||
// Temperature sensor read from register
|
||||
EPD_WriteCmd(0x1B);
|
||||
epd_temperature = EPD_SPI_read();
|
||||
epd_temperature = EPD_SPI_read();
|
||||
EPD_SPI_read();
|
||||
|
||||
WaitMs(5);
|
||||
@@ -232,7 +231,7 @@ _attribute_ram_code_ uint8_t EPD_BWR_296_Display(unsigned char *image, int size,
|
||||
EPD_WriteData(0x28);
|
||||
EPD_WriteData(0x01);
|
||||
|
||||
EPD_WriteCmd(0x26);// RED Color TODO make something out of it :)
|
||||
EPD_WriteCmd(0x26);
|
||||
int i;
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
@@ -247,11 +246,11 @@ _attribute_ram_code_ uint8_t EPD_BWR_296_Display(unsigned char *image, int size,
|
||||
EPD_WriteData(LUT_bwr_296_part[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Display update control
|
||||
EPD_WriteCmd(0x22);
|
||||
EPD_WriteData(0xC7);
|
||||
|
||||
|
||||
// Master Activation
|
||||
EPD_WriteCmd(0x20);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user