diff --git a/main/drivers/power.cpp b/main/drivers/power.cpp index 2b37654..554ff20 100644 --- a/main/drivers/power.cpp +++ b/main/drivers/power.cpp @@ -3,7 +3,7 @@ static const char* TAG = "POWER"; -static void bat_monitor_task(void* arg) { +void bat_monitor_task(void* arg) { while (1) { char str_buf[33] = {0}; uint16_t voltage = lipo.voltage(); @@ -46,8 +46,6 @@ void init_power_board() { auto voltage = lipo.voltage(); ESP_LOGI(TAG, "Battery Voltage: %d", voltage); - - // xTaskCreate(bat_monitor_task, "bat_monitor", 4096, NULL, 5, NULL); } diff --git a/main/drivers/power.h b/main/drivers/power.h index 095cff9..f84bafc 100644 --- a/main/drivers/power.h +++ b/main/drivers/power.h @@ -4,6 +4,8 @@ #include "SparkFunBQ27441/SparkFunBQ27441.h" #include +void bat_monitor_task(void* arg); + /// Initializes the battery gas guage for getting battery stats. void init_power_board(); uint16_t get_bat_voltage(); diff --git a/main/steps/step0.cpp b/main/steps/step0.cpp index dd91295..36cf866 100644 --- a/main/steps/step0.cpp +++ b/main/steps/step0.cpp @@ -20,6 +20,18 @@ static void try_step5(void) { clean_bomb(); step5(); } static void try_step6(void) { clean_bomb(); step6(); } static void issue_strike(void) { strike("Strike Issued"); } static void debug_switches(void); +static void battery_stats(void) { + BaseType_t xReturned; + TaskHandle_t xHandle = NULL; + xReturned = xTaskCreate(bat_monitor_task, "bat_monitor", 4096, NULL, 5, &xHandle); + + KeypadKey k; + while (!get_pressed_keypad(&k) || k != KeypadKey::pound) vTaskDelay(pdMS_TO_TICKS(10)); + + if (xReturned == pdPASS) { + vTaskDelete(xHandle); + } +} /// Wait for "*9819" void step0(void) { @@ -45,11 +57,17 @@ void step0(void) { .callback = set_game_time, }, { - .code = "*598623", + .code = "*59863", .display_text = "Debug Switches", .should_exit = false, .callback = debug_switches, }, + { + .code = "*59864", + .display_text = "Battery Stats", + .should_exit = false, + .callback = battery_stats, + }, { .code = "*59871", .display_text = "Try Step 1", diff --git a/main/steps/step0.h b/main/steps/step0.h index 9fe35f0..66aa431 100644 --- a/main/steps/step0.h +++ b/main/steps/step0.h @@ -4,6 +4,7 @@ #include "../drivers/bottom_half.h" #include "../drivers/char_lcd.h" #include "../drivers/wires.h" +#include "../drivers/power.h" #include "setup_wires.h" #include "../helper.h" diff --git a/main/steps/step1.cpp b/main/steps/step1.cpp index 8a79ea0..80a9bbb 100644 --- a/main/steps/step1.cpp +++ b/main/steps/step1.cpp @@ -67,9 +67,9 @@ static void init_step(void) { lv_obj_add_style(lv_scr_act(), &style_screen, LV_STATE_DEFAULT); // rgb565 - lv_color_t green = { .full = 0x0640 }; + lv_color_t green = { .full = 0x0560 }; lv_color_t red = { .full = 0xf800 }; - lv_color_t yellow = { .full = 0xfe80 }; + lv_color_t yellow = { .full = 0xfce0 }; lv_color_t blue = { .full = 0x045f }; lv_style_init(&green_text); @@ -194,7 +194,7 @@ static int generate_part(void) { } static void update_lcd_count(int times) { - char buf[6] = {0}; + char buf[16] = {0}; sprintf(buf, "%d/15", times); lcd_set_cursor(&lcd, 14, 1); lcd_print(&lcd, buf);