Skip to content

Commit

Permalink
add tl_check_fw2.exe, update makefile, CGG1 beta->release
Browse files Browse the repository at this point in the history
  • Loading branch information
pvvx committed Mar 18, 2021
1 parent 1c29640 commit ab5a553
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 74 deletions.
Binary file removed CGG1_v27.bin
Binary file not shown.
Binary file added CGG1_v27r.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ In case you want to go back to the original firmware, you can download them here
| 2.4 | Added parameter "Clock time step"
| 2.5 | Remove TRG/FLG errors, minor optimization
| 2.6 | Expanding the ranges of threshold parameters (TRG)
| 2.7 | Reducing power consumption of MHO-C401 (EDP update), adding beta version for CGG1
| 2.7 | Reducing power consumption of MHO-C401 (EDP update), adding version for CGG1


## Applications
Expand Down
2 changes: 1 addition & 1 deletion firmware.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{"version": 39,
"custom":["ATC_Thermometer27.bin", "MHO_C401_v27.bin", "CGG1_v27.bin"],
"custom":["ATC_Thermometer27.bin", "MHO_C401_v27.bin", "CGG1_v27r.bin"],
"original":["Original_OTA_Xiaomi_LYWSD03MMC_v1.0.0_0109.bin","Original_OTA_Xiaomi_MHO_C401_v1.0.0_0010.bin","Original_OTA_CGG1_v1.0.1_0093.bin"]}
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ $(LST_FILE): $(ELF_FILE)
$(BIN_FILE): $(ELF_FILE)
@echo 'Create Flash image (binary format)'
@tc32-elf-objcopy -v -O binary $(ELF_FILE) $(BIN_FILE)
@python3 $(TEL_PATH)/make/tl_firmware_tools.py add_crc $(BIN_FILE)
@$(PROJECT_PATH)/../utils/tl_check_fw2.exe $(BIN_FILE)
@echo 'Finished building: $@'
@echo ' '

Expand Down
4 changes: 2 additions & 2 deletions src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ typedef struct __attribute__((packed)) _cfg_t {
uint8_t connect_latency; // +1 x0.02 sec ( = connection interval), Tmin = 1*20 = 20 ms, Tmax = 256 * 20 = 5120 ms
uint8_t min_step_time_update_lcd; // x0.05 sec, 0.5..12.75 sec (10..255)
struct __attribute__((packed)) {
uint8_t hwver : 3; // 0 - LYWSD03MMC, 1 - MHO-C401
uint8_t hwver : 3; // 0 - LYWSD03MMC, 1 - MHO-C401, 2 - CGG1
uint8_t clock : 1; // clock
uint8_t memo : 1; // flash write measures
uint8_t trg : 1; // trigger out
uint8_t mi_beacon : 1; // advertising uses mi crypto beacon
uint8_t mi_beacon : 1; // advertising uses mi crypto beacon
uint8_t reserved : 1;
} hw_cfg; // read only
uint8_t averaging_measurements; // * measure_interval, 0 - off, 1..255 * measure_interval
Expand Down
2 changes: 1 addition & 1 deletion src/cstartup_825x.S
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ __start: @ MUST, referenced by boot.link
tj __reset
#endif
.org 0x18
.word (_bin_size_)
.word (_bin_size_+4)
@********************************************************************************************************
@ LOW-LEVEL INITIALIZATION
@********************************************************************************************************
Expand Down
102 changes: 34 additions & 68 deletions src/epd_cgg1.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "drivers/8258/timer.h"

#define DEF_EPD_SUMBOL_SIGMENTS 13
#define DEF_EPD_REFRESH_CNT 32
#define DEF_EPD_REFRESH_CNT 32

RAM uint8_t display_buff[18];
RAM uint8_t display_cmp_buff[18];
Expand Down Expand Up @@ -318,8 +318,9 @@ void init_lcd(void) {
lcd_refresh_cnt = DEF_EPD_REFRESH_CNT;
stage_lcd = 1;
epd_updated = 0;
flg_lcd_init = 3;
flg_lcd_init = 1;
gpio_write(EPD_RST, HIGH);
// EPD_BUSY: Low 866 us
}

void show_batt_cgg1(void) {
Expand Down Expand Up @@ -349,121 +350,86 @@ _attribute_ram_code_ __attribute__((optimize("-Os"))) int task_lcd(void) {
if (gpio_read(EPD_BUSY)) {
switch (stage_lcd) {
case 1: // Update/Init lcd, stage 1
if (flg_lcd_init)
flg_lcd_init--;
// send Charge Pump ON command
transmit(0, POWER_ON);
// wait ~30 ms for the display to become ready to receive new
// EPD_BUSY: Low 32 ms from reset, 47.5 ms in refresh cycle
stage_lcd = 2;
break;
case 2: // Update/Init lcd, stage 2
if (epd_updated == 0) {
// send next blocks ~25 ms
transmit(0, PANEL_SETTING);
transmit(1, 0x0B); // transmit(1, 0x0F); // 0x0F - inverted
transmit(1, 0x0F);

transmit(0, POWER_SETTING);
transmit(1, 0x32);
transmit(1, 0x32);
transmit(1, 0x32); // transmit(1, 0x32);
transmit(1, 0x32); // transmit(1, 0x32);
transmit(0, POWER_OFF_SEQUENCE_SETTING);
if (flg_lcd_init)
transmit(1, 0x00);
else
transmit(1, 0x06);
transmit(1, 0x00);
// Frame Rate Control
transmit(0, PLL_CONTROL);
if (flg_lcd_init)
transmit(1, 0x03);
else {
transmit(1, 0x07);
// NOTE: Original firmware makes partial refresh on update, but not when initialising the screen.
transmit(0, PARTIAL_DISPLAY_REFRESH);
transmit(1, 0x00);
transmit(1, 0x87);
transmit(1, 0x01);
transmit(0, POWER_OFF_SEQUENCE_SETTING);
transmit(1, 0x06);
}
// send the e-paper voltage settings (waves)
transmit(0, LUT_FOR_VCOM);
for (int i = 0; i < 15; i++)
for (int i = 0; i < sizeof(T_LUTV_init); i++)
transmit(1, T_LUTV_init[i]);

if (flg_lcd_init) {
flg_lcd_init = 0;
transmit(0, LUT_CMD_0x23);
if (flg_lcd_init == 1) { // pass 2
for (int i = 0; i < 15; i++)
transmit(1, T_LUT_KW_update[i]);
transmit(0, LUT_CMD_0x26);
for (int i = 0; i < 15; i++)
transmit(1, T_LUT_KK_update[i]);
// start an initialization sequence (white - all 0x00)
transmit(0, DATA_START_TRANSMISSION_1);
for (int i = 0; i < 18; i++)
transmit(1, 0);
#if 1
transmit(0, DATA_START_TRANSMISSION_2);
for (int i = 0; i < 18; i++)
transmit(1, 0);
#endif

} else { // pass 1
for (int i = 0; i < 15; i++)
transmit(1, T_LUT_KK_init[i]);
transmit(0, LUT_CMD_0x26);
for (int i = 0; i < 15; i++)
transmit(1, T_LUT_KW_init[i]);
// start an initialization sequence (black - all 0xFF)
transmit(0, DATA_START_TRANSMISSION_1);
for (int i = 0; i < 18; i++)
transmit(1, 0xff);
#if 1
transmit(0, DATA_START_TRANSMISSION_2);
for (int i = 0; i < 18; i++)
transmit(1, 0xff);
#endif
}
for (int i = 0; i < sizeof(T_LUT_KK_init); i++)
transmit(1, T_LUT_KK_init[i]);
transmit(0, LUT_CMD_0x26);
for (int i = 0; i < sizeof(T_LUT_KW_init); i++)
transmit(1, T_LUT_KW_init[i]);
// start an initialization sequence (white - all 0x00)
stage_lcd = 2;
} else {
transmit(0, LUT_CMD_0x23);
for (int i = 0; i < 15; i++)
for (int i = 0; i < sizeof(T_LUTV_init); i++)
transmit(1, T_LUTV_init[i]);

transmit(0, LUT_CMD_0x24);
for (int i = 0; i < 15; i++)
for (int i = 0; i < sizeof(T_LUT_KK_update); i++)
transmit(1, T_LUT_KK_update[i]);

transmit(0, LUT_CMD_0x25);
for (int i = 0; i < 15; i++)
for (int i = 0; i < sizeof(T_LUT_KW_update); i++)
transmit(1, T_LUT_KW_update[i]);

transmit(0, LUT_CMD_0x26);
for (int i = 0; i < 15; i++)
for (int i = 0; i < sizeof(T_LUTV_init); i++)
transmit(1, T_LUTV_init[i]);
// send the actual data
transmit(0, DATA_START_TRANSMISSION_1);
for (int i = 0; i < 18; i++)
transmit(1, display_buff[i]);
stage_lcd = 3;
}
} else {
// send the actual data
transmit(0, DATA_START_TRANSMISSION_1);
for (int i = 0; i < 18; i++)
transmit(1, display_buff[i]);
stage_lcd = 3;
}
stage_lcd = 3;
// send the actual data
transmit(0, DATA_START_TRANSMISSION_1);
for (int i = 0; i < sizeof(display_buff); i++)
transmit(1, display_buff[i]^0xFF);
// Refresh
transmit(0, DISPLAY_REFRESH);
// wait ~700 ms for the display to become ready to receive new
// EPD_BUSY: Low 1217 ms from reset, 608.5 ms in refresh cycle
break;
case 3: // Update/Init lcd, stage 3
case 3: // Update lcd, stage 3
// send Charge Pump OFF command
transmit(0, POWER_OFF);
transmit(1, 0x03);
if (flg_lcd_init)
// wait ~20 ms for the display to become ready to receive new
stage_lcd = 1;
else {
epd_updated = 1;
stage_lcd = 0;
}
// EPD_BUSY: Low 9.82 ms in refresh cycle
epd_updated = 1;
stage_lcd = 0;
break;
default:
stage_lcd = 0;
Expand Down
Binary file added utils/tl_check_fw2.exe
Binary file not shown.

0 comments on commit ab5a553

Please sign in to comment.