power screen star code

This commit is contained in:
Drake Marino 2024-12-28 17:43:49 -06:00
parent a4cf115bd6
commit a6f435216a
5 changed files with 26 additions and 7 deletions

View File

@ -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);
}

View File

@ -4,6 +4,8 @@
#include "SparkFunBQ27441/SparkFunBQ27441.h"
#include <esp_log.h>
void bat_monitor_task(void* arg);
/// Initializes the battery gas guage for getting battery stats.
void init_power_board();
uint16_t get_bat_voltage();

View File

@ -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",

View File

@ -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"

View File

@ -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);