diff --git a/examples/factory/factory.h b/examples/factory/factory.h index 807cac1..6698239 100644 --- a/examples/factory/factory.h +++ b/examples/factory/factory.h @@ -4,6 +4,7 @@ /********************************************************************************* * INCLUDES * *******************************************************************************/ +#include /********************************************************************************* * DEFINES @@ -24,6 +25,8 @@ extern bool flag_Keypad_init; extern bool flag_BQ25896_init; extern bool flag_BQ27220_init; extern bool flag_LTR553ALS_init; + +extern XPowersPPM PPM; /********************************************************************************* * TYPEDEFS * *******************************************************************************/ diff --git a/examples/factory/factory.ino b/examples/factory/factory.ino index 8cf0bcb..887f985 100644 --- a/examples/factory/factory.ino +++ b/examples/factory/factory.ino @@ -23,13 +23,15 @@ #include "SPI.h" +XPowersPPM PPM; + TouchDrvCSTXXX touch; GxEPD2_BW display(GxEPD2_310_GDEQ031T10(BOARD_EPD_CS, BOARD_EPD_DC, BOARD_EPD_RST, BOARD_EPD_BUSY)); // GDEQ031T10 240x320, UC8253, (no inking, backside mark KEGMO 3100) uint8_t *decodebuffer = NULL; lv_timer_t *flush_timer = NULL; int disp_refr_mode = DISP_REFR_MODE_PART; -const char HelloWorld[] = "Hello World!"; +const char HelloWorld[] = "T-Deck-Pro!"; bool flag_sd_init = false; bool flag_lora_init = false; @@ -186,6 +188,47 @@ static void lvgl_init(void) lv_indev_drv_register(&indev_drv); } +static void bq25896_init(void) +{ + // BQ25896 --- 0x6B + Wire.beginTransmission(BOARD_I2C_ADDR_BQ25896); + if (Wire.endTransmission() == 0) + { + flag_BQ25896_init = true; + // battery_25896.begin(); + PPM.init(Wire, BOARD_I2C_SDA, BOARD_I2C_SCL, BOARD_I2C_ADDR_BQ25896); + // Set the minimum operating voltage. Below this voltage, the PPM will protect + PPM.setSysPowerDownVoltage(3300); + + // Set input current limit, default is 500mA + PPM.setInputCurrentLimit(3250); + + Serial.printf("getInputCurrentLimit: %d mA\n",PPM.getInputCurrentLimit()); + + // Disable current limit pin + PPM.disableCurrentLimitPin(); + + // Set the charging target voltage, Range:3840 ~ 4608mV ,step:16 mV + PPM.setChargeTargetVoltage(4208); + + // Set the precharge current , Range: 64mA ~ 1024mA ,step:64mA + PPM.setPrechargeCurr(64); + + // The premise is that Limit Pin is disabled, or it will only follow the maximum charging current set by Limi tPin. + // Set the charging current , Range:0~5056mA ,step:64mA + PPM.setChargerConstantCurr(832); + + // Get the set charging current + PPM.getChargerConstantCurr(); + Serial.printf("getChargerConstantCurr: %d mA\n",PPM.getChargerConstantCurr()); + + PPM.enableADCMeasure(); + + PPM.enableCharge(); + } +} + + void setup() { Serial.begin(115200); @@ -237,6 +280,7 @@ void setup() } } } + bq25896_init(); Serial.printf("------------------------------ \n"); touch.setPins(BOARD_TOUCH_RST, BOARD_TOUCH_INT); diff --git a/examples/factory/ui_deckpro.cpp b/examples/factory/ui_deckpro.cpp index 29c6641..4abc4b9 100644 --- a/examples/factory/ui_deckpro.cpp +++ b/examples/factory/ui_deckpro.cpp @@ -88,8 +88,8 @@ static struct menu_btn menu_btn_list[] = {SCREEN6_ID, &img_batt, "Battery", 167, 111}, {SCREEN7_ID, &img_touch, "Input", 23, 199}, {SCREEN8_ID, &img_A7682, "A7682", 95, 199}, - {SCREEN9_ID, &img_lora, "Lora8", 167, 199}, - {SCREEN10_ID, &img_lora, "Lora9", 23, 23}, // Page two + {SCREEN9_ID, &img_lora, "Shutdown", 167, 199}, + {SCREEN10_ID, &img_lora, "Text ", 23, 23}, // Page two }; static void menu_btn_event_cb(lv_event_t *e) @@ -847,7 +847,7 @@ static void scr6_btn_event_cb(lv_event_t * e) } } -void batt_trans_event_cb(lv_event_t *e) +static void batt_trans_event_cb(lv_event_t *e) { if(e->code == LV_EVENT_CLICKED) { show_batt_type = !show_batt_type; @@ -1048,6 +1048,8 @@ static scr_lifecycle_t screen8 = { #endif //************************************[ screen 9 ]****************************************** #if 1 +static lv_timer_t *shutdown_timer = NULL; + static void scr9_btn_event_cb(lv_event_t * e) { if(e->code == LV_EVENT_CLICKED){ @@ -1055,10 +1057,22 @@ static void scr9_btn_event_cb(lv_event_t * e) } } +static void shutdown_timer_event(lv_timer_t* t) +{ + ui_shutdown_on(); +} + static void create9(lv_obj_t *parent) { - - lv_obj_t *back9_label = scr_back_btn_create(parent, ("999"), scr9_btn_event_cb); + lv_obj_t *lab = lv_label_create(parent); + lv_obj_set_style_text_font(lab, FONT_BOLD_SIZE_15, LV_PART_MAIN); + lv_label_set_text(lab, "Shutdown..."); + lv_obj_center(lab); + + shutdown_timer = lv_timer_create(shutdown_timer_event, 1000, NULL); + + + lv_obj_t *back9_label = scr_back_btn_create(parent, ("Shutdown"), scr9_btn_event_cb); } static void entry9(void) { diff --git a/examples/factory/ui_deckpro_port.cpp b/examples/factory/ui_deckpro_port.cpp index 5a0b1e9..9326974 100644 --- a/examples/factory/ui_deckpro_port.cpp +++ b/examples/factory/ui_deckpro_port.cpp @@ -205,43 +205,57 @@ bool ui_gyroscope_is_vaild(void) { return flag_Gyroscope_init; } // BQ25896 bool ui_batt_25896_is_chg(void) { - return true; + if(PPM.isVbusIn() == false) { + return false; + } else { + return true; + } + // return true; } float ui_batt_25896_get_vbus(void) { - return 4.5; + return (PPM.getVbusVoltage() *1.0 / 1000.0 ); + // return 4.5; } float ui_batt_25896_get_vsys(void) { - return 4.5; + return (PPM.getSystemVoltage() * 1.0 / 1000.0); + // return 4.5; } float ui_batt_25896_get_vbat(void) { - return 4.5; + return (PPM.getBattVoltage() * 1.0 / 1000.0); + // return 4.5; } float ui_batt_25896_get_volt_targ(void) { - return 4.5; + return (PPM.getChargeTargetVoltage() * 1.0 / 1000.0); + // return 4.5; } float ui_batt_25896_get_chg_curr(void) { - return 4.5; + return (PPM.getChargeCurrent()); + // return 4.5; } float ui_batt_25896_get_pre_curr(void) { - return 4.5; + return (PPM.getPrechargeCurr());; + // return 4.5; } const char * ui_batt_25896_get_chg_st(void) { - return "hello"; + return PPM.getChargeStatusString(); + // return "hello"; } const char * ui_batt_25896_get_vbus_st(void) { - return "hello"; + return PPM.getBusStatusString(); + // return "hello"; } const char * ui_batt_25896_get_ntc_st(void) { - return "hello"; + return PPM.getNTCStatusString(); + // return "hello"; } //************************************[ screen 7 ]****************************************** Input @@ -264,4 +278,10 @@ void ui_input_set_keypay_flag(void) { keypad_set_flag(); } +//************************************[ screen 9 ]****************************************** Input +void ui_shutdown_on(void) +{ + PPM.shutdown(); + Serial.println("Shutdown ....."); +} \ No newline at end of file diff --git a/examples/factory/ui_deckpro_port.h b/examples/factory/ui_deckpro_port.h index 65b04f7..6e32827 100644 --- a/examples/factory/ui_deckpro_port.h +++ b/examples/factory/ui_deckpro_port.h @@ -105,6 +105,10 @@ const char * ui_batt_25896_get_ntc_st(void); int ui_input_get_touch_coord(int *x, int *y); int ui_input_get_keypay_val(char *v); void ui_input_set_keypay_flag(void); + +// +void ui_shutdown_on(void); + #ifdef __cplusplus } /*extern "C"*/ #endif diff --git a/hardware/T-Deckpro 24-05-16/T-DeckPro V1.0 24-05-16.pdf b/hardware/T-Deckpro 24-05-16/T-DeckPro V1.0 24-05-16.pdf new file mode 100644 index 0000000..8538a16 Binary files /dev/null and b/hardware/T-Deckpro 24-05-16/T-DeckPro V1.0 24-05-16.pdf differ diff --git a/platformio.ini b/platformio.ini index 8dd410e..bdd0cc5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -78,7 +78,7 @@ lib_deps = mikalhart/TinyGPSPlus @ ^1.0.3 vshymanskyy/TinyGSM@^0.12.0 lvgl/lvgl @ ~8.3.9 - lewisxhe/XPowersLib @ ^0.1.8 + lewisxhe/XPowersLib @ ^0.2.4 adafruit/Adafruit TCA8418 @ ^1.0.1 adafruit/Adafruit BusIO @ ^1.14.4 olikraus/U8g2_for_Adafruit_GFX@^1.8.0