update steps 3 & 5
This commit is contained in:
+9
-5
@@ -1,14 +1,18 @@
|
||||
#ifndef ALL_H
|
||||
#define ALL_H
|
||||
|
||||
#include "char_lcd.h"
|
||||
#include "bottom_half.h"
|
||||
#include "char_lcd.h"
|
||||
#include "game_timer.h"
|
||||
#include "leds.h"
|
||||
#include "power.h"
|
||||
#include "sd.h"
|
||||
#include "speaker.h"
|
||||
#include "game_timer.h"
|
||||
#include "drivers/tft.h"
|
||||
#include "drivers/leds.h"
|
||||
#include "drivers/power.h"
|
||||
#include "sseg.h"
|
||||
#include "star_code.h"
|
||||
#include "state_tracking.h"
|
||||
#include "tft.h"
|
||||
#include "wires.h"
|
||||
|
||||
void init_drivers();
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ enum LEDColor: uint32_t {
|
||||
LED_COLOR_WHITE_STRONG = 0xFF'FF'FF,
|
||||
};
|
||||
|
||||
// TODO: sepperate the indicator leds from the shape display.
|
||||
enum IndicatorLED {
|
||||
LED_SHAPE1 = 0u,
|
||||
LED_SHAPE2 = 1u,
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
static const char* TAG = "star_code";
|
||||
|
||||
static std::vector<StarCodeEntry> star_codes;
|
||||
|
||||
@@ -40,6 +43,7 @@ bool add_star_code(StarCodeEntry code) {
|
||||
|
||||
if (it != star_codes.end()) {
|
||||
// existing star code found!
|
||||
ESP_LOGW(TAG, "Failed to add star code %s", code.code);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,12 +51,23 @@ bool add_star_code(StarCodeEntry code) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rm_star_code(char* code){
|
||||
bool add_star_codes(const StarCodeEntry* codes, size_t len) {
|
||||
bool success = true;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (!add_star_code(codes[i])) {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
bool rm_star_code(const char* code){
|
||||
auto it = std::find_if(star_codes.begin(), star_codes.end(), [&](const StarCodeEntry& star_code) {
|
||||
return strcmp(code, star_code.code) == 0;
|
||||
});
|
||||
|
||||
if (it == star_codes.end()) {
|
||||
ESP_LOGW(TAG, "Failed to remove star code %s", code);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -60,7 +75,31 @@ bool rm_star_code(char* code){
|
||||
return true;
|
||||
}
|
||||
|
||||
bool trigger_star_code(char* code) {
|
||||
bool rm_star_codes(const StarCodeEntry* codes, size_t len) {
|
||||
bool success = true;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (!rm_star_code(codes[i].code)) {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
bool rm_star_codes_str(const char** codes, size_t len) {
|
||||
bool success = true;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (!rm_star_code(codes[i])) {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void clear_star_codes() {
|
||||
star_codes.clear();
|
||||
}
|
||||
|
||||
bool trigger_star_code(const char* code) {
|
||||
auto it = std::find_if(star_codes.begin(), star_codes.end(), [&](const StarCodeEntry& other) {
|
||||
return check_code_match(code, other.code);
|
||||
});
|
||||
|
||||
@@ -22,18 +22,39 @@ struct StarCodeEntry {
|
||||
};
|
||||
|
||||
/// @brief Adds a star code to be handled.
|
||||
/// @param code the star code to add (without the *)
|
||||
/// @param code the star code to add
|
||||
/// @return true iff the star code was added
|
||||
bool add_star_code(StarCodeEntry code);
|
||||
|
||||
/// @brief Adds a list of star codes to be handled.
|
||||
/// @param codes the list of star codes to add
|
||||
/// @param len the length of the list
|
||||
/// @return true iff all the star codes were added
|
||||
bool add_star_codes(const StarCodeEntry* codes, size_t len);
|
||||
|
||||
/// @brief removes a star code to stop handling it.
|
||||
/// @param code the star code to remove (without the *)
|
||||
/// @param code the star code to remove
|
||||
/// @return true iff the star code was removed
|
||||
bool rm_star_code(char* code);
|
||||
bool rm_star_code(const char* code);
|
||||
|
||||
/// @brief removes all given star codes to stop handling them.
|
||||
/// @param codes the list of star codes to remove
|
||||
/// @param len the length of the list
|
||||
/// @return true iff all star codes were removed
|
||||
bool rm_star_codes(const StarCodeEntry* codes, size_t len);
|
||||
|
||||
/// @brief removes all given star codes to stop handling them.
|
||||
/// @param codes the list of star codes to remove
|
||||
/// @param len the length of the list
|
||||
/// @return true iff all star codes were removed
|
||||
bool rm_star_codes_str(const char** codes, size_t len);
|
||||
|
||||
/// @brief clears all star codes.
|
||||
void clear_star_codes();
|
||||
|
||||
/// @brief Triggers the given starcode.
|
||||
/// @param code the star code to trigger (without the *)
|
||||
/// @return true iff a star code was triggered
|
||||
bool trigger_star_code(char* code);
|
||||
bool trigger_star_code(const char* code);
|
||||
|
||||
#endif /* STAR_CODE_H */
|
||||
Reference in New Issue
Block a user