Browse Source

Speed up charging with soft start

master
Englebert 3 years ago
parent
commit
b396e0d977
  1. 47
      src/main.cpp
  2. 1
      src/main.h

47
src/main.cpp

@ -32,6 +32,16 @@ void setup() {
// Task Creation
xTaskCreatePinnedToCore(
taskCharger,
"TaskCharger", // Name of the process
4096, // This stack size can be checked & adjusted by reading the Stack Highwater
NULL,
4, // Priority
NULL,
CPU_1
);
xTaskCreatePinnedToCore(
taskScreen,
"TaskScreen", // Name of the process
@ -109,6 +119,43 @@ void taskScreen(void *pvParameters) {
}
void taskCharger(void *pvParameters) {
(void) pvParameters;
bool charging = false;
bool high_current_charging = false;
uint32_t last_charging_time = 0;
for(;;) {
if(M5.Axp.isCharging()) {
// Just flipped...
if(!charging) {
charging = true;
last_charging_time = millis();
} else {
// Only after 5 seconds then put to 1A...
if(!high_current_charging) {
if((uint32_t)(millis() - last_charging_time) > 5000) {
high_current_charging = true;
M5.Axp.SetCHGCurrent(M5.Axp.kCHG_1000mA);
}
}
}
} else {
if(charging) {
// Setting back to 100mA
charging = false;
high_current_charging = false;
last_charging_time = millis();
M5.Axp.SetCHGCurrent(M5.Axp.kCHG_100mA);
}
}
vTaskDelay(200);
}
}
void taskSpeak(void *pvParameters) {
(void) pvParameters;

1
src/main.h

@ -23,5 +23,6 @@ void taskWeb(void *pvParameters);
void taskInput(void *pvParameters);
void taskBLE(void *pvParameters);
void taskNRF(void *pvParameters);
void taskCharger(void *pvParameters);
#endif
Loading…
Cancel
Save