starcode updates

This commit is contained in:
Mitchell Marino 2025-08-21 20:15:29 -05:00
parent 8bddceca66
commit 202b926eb7
9 changed files with 19 additions and 22 deletions

View File

@ -16,7 +16,7 @@ set(SOURCES
"sd.cpp"
"speaker.cpp"
"sseg.cpp"
"star_code.cpp"
"starcode.cpp"
"state_tracking.cpp"
"tft.cpp"
"wires.cpp"

View File

@ -10,7 +10,7 @@
#include "sd.h"
#include "speaker.h"
#include "sseg.h"
#include "star_code.h"
#include "starcode.h"
#include "state_tracking.h"
#include "tft.h"
#include "wires.h"

View File

@ -1,7 +1,7 @@
#include "bottom_half.h"
#include <esp_log.h>
#include "state_tracking.h"
#include "star_code.h"
#include "starcode.h"
static const char *TAG = "bottom_half";

View File

@ -5,7 +5,7 @@
#include "state_tracking.h"
#include <cstring>
#include "power.h"
#include "star_code.h"
#include "starcode.h"
#include "game_info.h"
i2c_lcd_pcf8574_handle_t lcd;

View File

@ -1,24 +1,21 @@
#include "game_info.h"
#include "star_code.h"
#include "starcode.h"
#include <stdio.h>
#include "char_lcd.h"
static char game_state[GAME_STATE_MAX_LEN+1] = "MENU ";
static char game_state[GAME_STATE_MAX_LEN+2] = " MENU ";
void set_game_state(char* new_state) {
snprintf(game_state, sizeof(game_state), "%-5s", new_state);
void set_game_state(const char* new_state) {
snprintf(game_state, sizeof(game_state), " %-5s", new_state);
}
void reset_game_state() {
for (int i = 0; i < GAME_STATE_MAX_LEN; i++) {
game_state[i] = '\0';
}
game_state[GAME_STATE_MAX_LEN] = '\0';
set_game_state("");
}
void lcd_print_header_step() {
if (!lcd_header_enabled()) return;
if (lcd_starcode_displaying_result()) return;
lcd_print(11, 0, game_state);
lcd_print(10, 0, game_state);
}

View File

@ -6,7 +6,7 @@
/// @brief Sets the game state, used for the header.
///
/// Must be <= 5 characters
void set_game_state(char* new_state);
void set_game_state(const char* new_state);
/// @brief Resets the game state to be blank.
void reset_game_state();

View File

@ -1,6 +1,6 @@
#include "power.h"
#include "char_lcd.h"
#include "star_code.h"
#include "starcode.h"
#include <esp_log.h>
static const char* TAG = "power";
@ -61,18 +61,18 @@ void lcd_print_header_bat() {
uint8_t soc = lipo.soc();
uint8_t current = lipo.current();
char buf[5];
char buf[6];
if (soc < 5 && current <= 0) {
snprintf(buf, sizeof(buf), "LOW");
snprintf(buf, sizeof(buf), " LOW");
} else if (soc == 100) {
snprintf(buf, sizeof(buf), "100");
snprintf(buf, sizeof(buf), " 100");
} else {
if (current > 0) {
snprintf(buf, sizeof(buf), "%2d+", soc);
snprintf(buf, sizeof(buf), " %2d+", soc);
} else {
snprintf(buf, sizeof(buf), "%2d%%", soc);
snprintf(buf, sizeof(buf), " %2d%%", soc);
}
}
lcd_print(17, 0, buf);
lcd_print(16, 0, buf);
}

View File

@ -1,4 +1,4 @@
#include "star_code.h"
#include "starcode.h"
#include <vector>
#include <algorithm>
#include <string.h>