Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b2813d62a3 |
@ -8,11 +8,9 @@ set(SOURCES
|
||||
"char_lcd.cpp"
|
||||
"game_info.cpp"
|
||||
"game_timer.cpp"
|
||||
"hwdata.cpp"
|
||||
"i2c_lcd_pcf8574.c"
|
||||
"i2c.cpp"
|
||||
"leds.cpp"
|
||||
"nvs.cpp"
|
||||
"perh.cpp"
|
||||
"power.cpp"
|
||||
"sd.cpp"
|
||||
|
||||
@ -729,9 +729,7 @@ uint16_t BQ27441::i2cWriteBytes(uint8_t subAddress, uint8_t * src, uint8_t count
|
||||
w_buff[i+1] = src[i];
|
||||
}
|
||||
|
||||
xSemaphoreTake(main_i2c_mutex, portMAX_DELAY);
|
||||
esp_err_t ret = i2c_master_write_to_device(BQ72441_I2C_NUM, _deviceAddress, src, count+1, timeout);
|
||||
xSemaphoreGive(main_i2c_mutex);
|
||||
|
||||
return ret == ESP_OK;
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ void init_drivers() {
|
||||
init_i2c();
|
||||
// init char_lcd so we can use it to report other initialization errors.
|
||||
init_lcd();
|
||||
init_nvs();
|
||||
init_star_code_system();
|
||||
// init the bottom half so that we can get user input.
|
||||
init_bottom_half();
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
#include "game_timer.h"
|
||||
#include "i2c.h"
|
||||
#include "leds.h"
|
||||
#include "nvs.h"
|
||||
#include "power.h"
|
||||
#include "sd.h"
|
||||
#include "speaker.h"
|
||||
|
||||
@ -76,7 +76,6 @@ void init_bottom_half() {
|
||||
|
||||
static uint8_t receive_delta(void) {
|
||||
uint8_t reg = 1;
|
||||
xSemaphoreTake(main_i2c_mutex, portMAX_DELAY);
|
||||
esp_err_t result = i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, buf, 1, (100 / portTICK_PERIOD_MS));
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(result);
|
||||
if (result != ESP_OK) {
|
||||
@ -86,11 +85,10 @@ static uint8_t receive_delta(void) {
|
||||
}
|
||||
|
||||
static void receive_keypad(void) {
|
||||
// TODO: use mutex
|
||||
// TODO: change the bottom half polling scheme from a state-based protocol to an event based protocol
|
||||
uint8_t reg = 2;
|
||||
xSemaphoreTake(main_i2c_mutex, portMAX_DELAY);
|
||||
esp_err_t result = i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, buf, 2, (100 / portTICK_PERIOD_MS));
|
||||
xSemaphoreGive(main_i2c_mutex);
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(result);
|
||||
if (result != ESP_OK) {
|
||||
return;
|
||||
@ -119,9 +117,7 @@ static void receive_keypad(void) {
|
||||
|
||||
static void receive_button_switch(void) {
|
||||
uint8_t reg = 3;
|
||||
xSemaphoreTake(main_i2c_mutex, portMAX_DELAY);
|
||||
esp_err_t result = i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, buf, 2, (100 / portTICK_PERIOD_MS));
|
||||
xSemaphoreGive(main_i2c_mutex);
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(result);
|
||||
if (result != ESP_OK) {
|
||||
return;
|
||||
@ -192,9 +188,7 @@ static void receive_button_switch(void) {
|
||||
static void receive_touch(void) {
|
||||
uint8_t reg = 4;
|
||||
buf[0] = 0;
|
||||
xSemaphoreTake(main_i2c_mutex, portMAX_DELAY);
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(BOTTOM_I2C_NUM, BOTTOM_I2C_ADDR, ®, 1, buf, 1, (100 / portTICK_PERIOD_MS)));
|
||||
xSemaphoreGive(main_i2c_mutex);
|
||||
bool new_touch_state = buf[0] != 0;
|
||||
|
||||
bool just_pressed = new_touch_state & !touch_state;
|
||||
|
||||
@ -9,11 +9,6 @@
|
||||
#include "game_info.h"
|
||||
|
||||
i2c_lcd_pcf8574_handle_t lcd;
|
||||
SemaphoreHandle_t lcd_mutex;
|
||||
|
||||
static volatile bool cursor_visible = false;
|
||||
static volatile uint8_t cursor_resting_row = 0;
|
||||
static volatile uint8_t cursor_resting_col = 0;
|
||||
|
||||
static volatile bool header_enabled = false;
|
||||
|
||||
@ -22,7 +17,6 @@ static const char* EMPTY_ROW = " ";
|
||||
|
||||
static char buf[65];
|
||||
|
||||
// TODO: move this to power.cpp
|
||||
static void monitor_battery_task(void* _arg) {
|
||||
(void) _arg;
|
||||
|
||||
@ -35,35 +29,53 @@ static void monitor_battery_task(void* _arg) {
|
||||
static bool replay_handler(const char* event, char* arg) {
|
||||
if (strcmp(event, "LCD_CLEAR") == 0) {
|
||||
lcd_clear();
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(event, "LCD_SET_DISPLAY") == 0) {
|
||||
if (strcmp(event, "LCD_CURSOR") == 0) {
|
||||
char* col_str = strtok(arg, ",");
|
||||
char* row_str = strtok(NULL, ",");
|
||||
uint32_t col = atoi(col_str);
|
||||
uint32_t row = atoi(row_str);
|
||||
lcd_set_cursor_pos(col, row);
|
||||
return true;
|
||||
}
|
||||
if (strcmp(event, "LCD_SET_DISPLAY") == 0) {
|
||||
lcd_set_display(strcmp(arg, "true") == 0);
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(event, "LCD_CURSOR_VIS") == 0) {
|
||||
if (strcmp(event, "LCD_CURSOR_VIS") == 0) {
|
||||
lcd_set_cursor_vis(strcmp(arg, "true") == 0);
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(event, "LCD_CURSOR_BLINK") == 0) {
|
||||
if (strcmp(event, "LCD_CURSOR_BLINK") == 0) {
|
||||
lcd_set_cursor_blink(strcmp(arg, "true") == 0);
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(event, "LCD_SCROLL_DISPLAY_LEFT") == 0) {
|
||||
if (strcmp(event, "LCD_SCROLL_DISPLAY_LEFT") == 0) {
|
||||
lcd_scroll_display_left();
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(event, "LCD_SCROLL_DISPLAY_RIGHT") == 0) {
|
||||
if (strcmp(event, "LCD_SCROLL_DISPLAY_RIGHT") == 0) {
|
||||
lcd_scroll_display_right();
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(event, "LCD_LEFT_TO_RIGHT") == 0) {
|
||||
if (strcmp(event, "LCD_LEFT_TO_RIGHT") == 0) {
|
||||
lcd_left_to_right();
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(event, "LCD_RIGHT_TO_LEFT") == 0) {
|
||||
if (strcmp(event, "LCD_RIGHT_TO_LEFT") == 0) {
|
||||
lcd_right_to_left();
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(event, "LCD_AUTOSCROLL") == 0) {
|
||||
if (strcmp(event, "LCD_AUTOSCROLL") == 0) {
|
||||
lcd_set_autoscroll(strcmp(arg, "true") == 0);
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(event, "LCD_BACKLIGHT") == 0) {
|
||||
if (strcmp(event, "LCD_BACKLIGHT") == 0) {
|
||||
lcd_set_backlight(strcmp(arg, "true") == 0);
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(event, "LCD_CREATE_CHAR") == 0) {
|
||||
if (strcmp(event, "LCD_CREATE_CHAR") == 0) {
|
||||
char* location_str = strtok(arg, ",");
|
||||
uint8_t location = atoi(location_str);
|
||||
|
||||
@ -74,34 +86,24 @@ static bool replay_handler(const char* event, char* arg) {
|
||||
}
|
||||
|
||||
lcd_create_char(location, charmap);
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(event, "LCD_PRINT") == 0) {
|
||||
char* str = strtok(arg, ",");
|
||||
uint8_t row = atoi(str);
|
||||
str = strtok(NULL, ",");
|
||||
uint8_t col = atoi(str);
|
||||
// get remaining part of string.
|
||||
str = strtok(NULL, "");
|
||||
|
||||
if (strcmp(event, "LCD_PRINT") == 0) {
|
||||
// TODO: handle \r and \n
|
||||
lcd_print(row, col, str);
|
||||
} else {
|
||||
return false;
|
||||
lcd_print(&lcd, arg);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void init_lcd() {
|
||||
ESP_LOGI(TAG, "Initializing LCD...");
|
||||
|
||||
lcd_mutex = xSemaphoreCreateMutex();
|
||||
assert(lcd_mutex != NULL);
|
||||
|
||||
lcd_init(&lcd, LCD_ADDR, CHAR_LCD_I2C_NUM);
|
||||
lcd_begin(&lcd, LCD_COLS, LCD_ROWS);
|
||||
|
||||
lcd_set_backlight_to(&lcd, 1);
|
||||
lcd_set_backlight(&lcd, 255);
|
||||
|
||||
register_replay_fn(replay_handler);
|
||||
|
||||
@ -110,124 +112,115 @@ void init_lcd() {
|
||||
ESP_LOGI(TAG, "LCD initialized!");
|
||||
}
|
||||
|
||||
void lcd_clear(bool no_lock) {
|
||||
void lcd_clear() {
|
||||
if (!header_enabled) {
|
||||
if (!no_lock) xSemaphoreTake(lcd_mutex, portMAX_DELAY);
|
||||
lcd_clear(&lcd);
|
||||
if (!no_lock) xSemaphoreGive(lcd_mutex);
|
||||
|
||||
if (is_state_tracking()) {
|
||||
event_occured("LCD_CLEAR", NULL);
|
||||
}
|
||||
} else {
|
||||
if (!no_lock) xSemaphoreTake(lcd_mutex, portMAX_DELAY);
|
||||
lcd_print(1, 0, EMPTY_ROW, true);
|
||||
lcd_print(2, 0, EMPTY_ROW, true);
|
||||
lcd_print(3, 0, EMPTY_ROW, true);
|
||||
if (!no_lock) xSemaphoreGive(lcd_mutex);
|
||||
lcd_print(0, 1, EMPTY_ROW);
|
||||
lcd_print(0, 2, EMPTY_ROW);
|
||||
lcd_print(0, 3, EMPTY_ROW);
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_set_display(bool display, bool no_lock) {
|
||||
if (!no_lock) xSemaphoreTake(lcd_mutex, portMAX_DELAY);
|
||||
// TODO: rm
|
||||
void lcd_cursor_home() {
|
||||
lcd_set_cursor_pos(0, 0);
|
||||
}
|
||||
|
||||
// TODO: with print requiring you to set a pos every time, this function is not helpful
|
||||
void lcd_set_cursor_pos(uint8_t col, uint8_t row) {
|
||||
lcd_set_cursor(&lcd, col, row);
|
||||
|
||||
if (is_state_tracking()) {
|
||||
sprintf(buf, "%d,%d", col, row);
|
||||
event_occured("LCD_CURSOR", buf);
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_set_display(bool display) {
|
||||
if (display) {
|
||||
lcd_display(&lcd);
|
||||
} else {
|
||||
lcd_no_display(&lcd);
|
||||
}
|
||||
if (!no_lock) xSemaphoreGive(lcd_mutex);
|
||||
|
||||
if (is_state_tracking()) {
|
||||
event_occured("LCD_SET_DISPLAY", display ? "true" : "false");
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_set_cursor_vis(bool cursor, bool no_lock) {
|
||||
if (!no_lock) xSemaphoreTake(lcd_mutex, portMAX_DELAY);
|
||||
void lcd_set_cursor_vis(bool cursor) {
|
||||
if (cursor) {
|
||||
lcd_cursor(&lcd);
|
||||
} else {
|
||||
lcd_no_cursor(&lcd);
|
||||
}
|
||||
if (!no_lock) xSemaphoreGive(lcd_mutex);
|
||||
|
||||
cursor_visible = cursor;
|
||||
|
||||
if (is_state_tracking()) {
|
||||
event_occured("LCD_CURSOR_VIS", cursor ? "true" : "false");
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_set_cursor_blink(bool blink, bool no_lock) {
|
||||
if (!no_lock) xSemaphoreTake(lcd_mutex, portMAX_DELAY);
|
||||
void lcd_set_cursor_blink(bool blink) {
|
||||
if (blink) {
|
||||
lcd_blink(&lcd);
|
||||
} else {
|
||||
lcd_no_blink(&lcd);
|
||||
}
|
||||
if (!no_lock) xSemaphoreGive(lcd_mutex);
|
||||
|
||||
if (is_state_tracking()) {
|
||||
event_occured("LCD_CURSOR_BLINK", blink ? "true" : "false");
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_scroll_display_left(bool no_lock) {
|
||||
if (!no_lock) xSemaphoreTake(lcd_mutex, portMAX_DELAY);
|
||||
void lcd_scroll_display_left() {
|
||||
lcd_scroll_display_left(&lcd);
|
||||
if (!no_lock) xSemaphoreGive(lcd_mutex);
|
||||
|
||||
if (is_state_tracking()) {
|
||||
event_occured("LCD_SCROLL_DISPLAY_LEFT", NULL);
|
||||
}
|
||||
}
|
||||
void lcd_scroll_display_right(bool no_lock) {
|
||||
if (!no_lock) xSemaphoreTake(lcd_mutex, portMAX_DELAY);
|
||||
void lcd_scroll_display_right() {
|
||||
lcd_scroll_display_right(&lcd);
|
||||
if (!no_lock) xSemaphoreGive(lcd_mutex);
|
||||
|
||||
if (is_state_tracking()) {
|
||||
event_occured("LCD_SCROLL_DISPLAY_RIGHT", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_left_to_right(bool no_lock) {
|
||||
if (!no_lock) xSemaphoreTake(lcd_mutex, portMAX_DELAY);
|
||||
void lcd_left_to_right() {
|
||||
lcd_left_to_right(&lcd);
|
||||
if (!no_lock) xSemaphoreGive(lcd_mutex);
|
||||
|
||||
if (is_state_tracking()) {
|
||||
event_occured("LCD_LEFT_TO_RIGHT", NULL);
|
||||
}
|
||||
}
|
||||
void lcd_right_to_left(bool no_lock) {
|
||||
if (!no_lock) xSemaphoreTake(lcd_mutex, portMAX_DELAY);
|
||||
void lcd_right_to_left() {
|
||||
lcd_right_to_left(&lcd);
|
||||
if (!no_lock) xSemaphoreGive(lcd_mutex);
|
||||
|
||||
if (is_state_tracking()) {
|
||||
event_occured("LCD_RIGHT_TO_LEFT", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_set_autoscroll(bool autoscroll, bool no_lock) {
|
||||
if (!no_lock) xSemaphoreTake(lcd_mutex, portMAX_DELAY);
|
||||
void lcd_set_autoscroll(bool autoscroll) {
|
||||
if (autoscroll) {
|
||||
lcd_autoscroll(&lcd);
|
||||
} else {
|
||||
lcd_no_autoscroll(&lcd);
|
||||
}
|
||||
if (!no_lock) xSemaphoreGive(lcd_mutex);
|
||||
|
||||
if (is_state_tracking()) {
|
||||
event_occured("LCD_AUTOSCROLL", autoscroll ? "true" : "false");
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_set_backlight(bool backlight, bool no_lock) {
|
||||
if (!no_lock) xSemaphoreTake(lcd_mutex, portMAX_DELAY);
|
||||
lcd_set_backlight_to(&lcd, backlight);
|
||||
if (!no_lock) xSemaphoreGive(lcd_mutex);
|
||||
void lcd_set_backlight(bool backlight) {
|
||||
lcd_set_backlight(&lcd, backlight);
|
||||
|
||||
if (is_state_tracking()) {
|
||||
sprintf(buf, "%d", backlight);
|
||||
@ -235,15 +228,11 @@ void lcd_set_backlight(bool backlight, bool no_lock) {
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_create_char(uint8_t location, const uint8_t charmap[], bool no_lock) {
|
||||
if (location == 8) location = 0;
|
||||
|
||||
if (!no_lock) xSemaphoreTake(lcd_mutex, portMAX_DELAY);
|
||||
void lcd_create_char(uint8_t location, const uint8_t charmap[]) {
|
||||
lcd_create_char(&lcd, location, charmap);
|
||||
if (!no_lock) xSemaphoreGive(lcd_mutex);
|
||||
|
||||
if (is_state_tracking()) {
|
||||
snprintf(buf, sizeof(buf),
|
||||
snprintf(buf, 65,
|
||||
"%d,%d,%d,%d,%d,%d,%d,%d,%d", location,
|
||||
charmap[0], charmap[1], charmap[2], charmap[3], charmap[4], charmap[5], charmap[6], charmap[7]
|
||||
);
|
||||
@ -251,21 +240,14 @@ void lcd_create_char(uint8_t location, const uint8_t charmap[], bool no_lock) {
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_print(uint8_t row, uint8_t col, const char* str, bool no_lock) {
|
||||
if (!no_lock) xSemaphoreTake(lcd_mutex, portMAX_DELAY);
|
||||
lcd_set_cursor(&lcd, col, row);
|
||||
// TODO: switch to row, col
|
||||
void lcd_print(uint8_t col, uint8_t row, const char* str) {
|
||||
lcd_set_cursor_pos(col, row);
|
||||
lcd_print(&lcd, str);
|
||||
|
||||
if (cursor_visible) {
|
||||
lcd_set_cursor(&lcd, cursor_resting_col, cursor_resting_row);
|
||||
}
|
||||
|
||||
if (!no_lock) xSemaphoreGive(lcd_mutex);
|
||||
|
||||
if (is_state_tracking()) {
|
||||
// TODO: handle \r and \n and others
|
||||
snprintf(buf, sizeof(buf), "%d,%d,%s", row, col, str);
|
||||
event_occured("LCD_PRINT", buf);
|
||||
// TODO: handle \r and \n
|
||||
event_occured("LCD_PRINT", str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,37 +284,13 @@ void lcd_do_splash() {
|
||||
};
|
||||
|
||||
// TODO: make the lcd_lib somehow support the custom character 0 which would otherwise be a null terminator
|
||||
xSemaphoreTake(lcd_mutex, portMAX_DELAY);
|
||||
lcd_create_char(1, custom_char[0], true);
|
||||
lcd_create_char(2, custom_char[1], true);
|
||||
lcd_create_char(3, custom_char[2], true);
|
||||
lcd_create_char(4, custom_char[3], true);
|
||||
lcd_create_char(5, custom_char[4], true);
|
||||
lcd_create_char(6, custom_char[5], true);
|
||||
lcd_create_char(1, custom_char[0]);
|
||||
lcd_create_char(2, custom_char[1]);
|
||||
lcd_create_char(3, custom_char[2]);
|
||||
lcd_create_char(4, custom_char[3]);
|
||||
lcd_create_char(5, custom_char[4]);
|
||||
lcd_create_char(6, custom_char[5]);
|
||||
|
||||
lcd_print(1, 6, "\x01\x02Marino", true);
|
||||
lcd_print(2, 5, "\x03\x04\x05\x06""DEV", true);
|
||||
xSemaphoreGive(lcd_mutex);
|
||||
}
|
||||
|
||||
bool lcd_lock(uint32_t ticks_to_wait) {
|
||||
return xSemaphoreTake(lcd_mutex, ticks_to_wait);
|
||||
}
|
||||
|
||||
void lcd_unlock() {
|
||||
xSemaphoreGive(lcd_mutex);
|
||||
}
|
||||
|
||||
void lcd_set_cursor_resting_position(uint8_t row, uint8_t col) {
|
||||
cursor_resting_row = row;
|
||||
cursor_resting_col = col;
|
||||
}
|
||||
|
||||
void lcd_get_cursor_resting_position(uint8_t* row, uint8_t* col) {
|
||||
if (row) *row = cursor_resting_row;
|
||||
if (col) *col = cursor_resting_col;
|
||||
}
|
||||
|
||||
bool lcd_is_cursor_visible() {
|
||||
return cursor_visible;
|
||||
lcd_print(6, 1, "\x01\x02Marino");
|
||||
lcd_print(5, 2, "\x03\x04\x05\x06""DEV");
|
||||
}
|
||||
@ -6,53 +6,54 @@
|
||||
#define CHAR_LCD_I2C_NUM I2C_NUM_0
|
||||
|
||||
#define LCD_ADDR 0x27
|
||||
#define LCD_ROWS 4
|
||||
#define LCD_COLS 20
|
||||
#define LCD_ROWS 4
|
||||
|
||||
/// @brief Initializes the 2004 Character LCD
|
||||
/// Initializes the 2004 Character LCD
|
||||
void init_lcd();
|
||||
|
||||
/// @brief Clear the LCD
|
||||
void lcd_clear(bool no_lock = false);
|
||||
/// Clear the LCD
|
||||
void lcd_clear();
|
||||
|
||||
/// @brief Move cursor to home position
|
||||
void lcd_cursor_home(bool no_lock = false);
|
||||
/// Move cursor to home position
|
||||
void lcd_cursor_home();
|
||||
|
||||
/// @brief Turn the display on/off
|
||||
void lcd_set_display(bool display, bool no_lock = false);
|
||||
/// Set cursor position
|
||||
void lcd_set_cursor_pos(uint8_t col, uint8_t row);
|
||||
|
||||
/// @brief Turn the cursor's visibility on/off
|
||||
void lcd_set_cursor_vis(bool cursor, bool no_lock = false);
|
||||
/// Turn the display on/off
|
||||
void lcd_set_display(bool display);
|
||||
|
||||
/// @brief Turn blinking cursor on/off
|
||||
void lcd_set_cursor_blink(bool blink, bool no_lock = false);
|
||||
/// Turn the cursor's visibility on/off
|
||||
void lcd_set_cursor_vis(bool cursor);
|
||||
|
||||
/// @brief Scroll the display left
|
||||
void lcd_scroll_display_left(bool no_lock = false);
|
||||
/// @brief Scroll the display right
|
||||
void lcd_scroll_display_right(bool no_lock = false);
|
||||
/// Turn blinking cursor on/off
|
||||
void lcd_set_cursor_blink(bool blink);
|
||||
|
||||
/// @brief Set the text to flows automatically left to right
|
||||
void lcd_left_to_right(bool no_lock = false);
|
||||
/// @brief Set the text to flows automatically right to left
|
||||
void lcd_right_to_left(bool no_lock = false);
|
||||
/// Scroll the display left
|
||||
void lcd_scroll_display_left();
|
||||
/// Scroll the display right
|
||||
void lcd_scroll_display_right();
|
||||
|
||||
/// @brief Turn on/off autoscroll
|
||||
void lcd_set_autoscroll(bool autoscroll, bool no_lock = false);
|
||||
/// Set the text to flows automatically left to right
|
||||
void lcd_left_to_right();
|
||||
/// Set the text to flows automatically right to left
|
||||
void lcd_right_to_left();
|
||||
|
||||
/// @brief Set backlight brightness
|
||||
void lcd_set_backlight(bool backlight, bool no_lock = false);
|
||||
// Turn on/off autoscroll
|
||||
void lcd_set_autoscroll(bool autoscroll);
|
||||
|
||||
/// @brief Create a custom character. You get 8 custom characters.
|
||||
/// You can print custom characters by using escape characters in strings:
|
||||
/// use '\x01' - '\x07' for custom characters 1-7. Use '\x08' for custom char 0.
|
||||
void lcd_create_char(uint8_t location, const uint8_t charmap[], bool no_lock = false);
|
||||
// Set backlight brightness
|
||||
void lcd_set_backlight(bool backlight);
|
||||
|
||||
// Create a custom character
|
||||
void lcd_create_char(uint8_t location, const uint8_t charmap[]);
|
||||
|
||||
/// @brief Print a string to the LCD at a given pos.
|
||||
/// @param row the row the print the string at.
|
||||
/// @param col the column to print the string at.
|
||||
/// @param row the row the print the string at.
|
||||
/// @param str the string to print.
|
||||
void lcd_print(uint8_t row, uint8_t col, const char* str, bool no_lock = false);
|
||||
void lcd_print(uint8_t col, uint8_t row, const char* str);
|
||||
|
||||
/// @brief Enables or disables the header on the LCD.
|
||||
/// @param enable `true` to enable the header, `false` to disable.
|
||||
@ -68,29 +69,4 @@ void lcd_print_header();
|
||||
/// @brief Prints the splash screen for the BLK_BOX.
|
||||
void lcd_do_splash();
|
||||
|
||||
/// @brief Locks the LCD to allow chaining multiple commands without interuptions.
|
||||
///
|
||||
/// Commands you call while you lock the LCD, you must call with the `no_lock` flag set to true.
|
||||
///
|
||||
/// Do not hold this lock for an extended period of time.
|
||||
/// @return `true` iff the lock was aquired.
|
||||
bool lcd_lock(uint32_t ticks_to_wait);
|
||||
|
||||
/// @brief Unlocks the LCD to give away the mutex access to it.
|
||||
void lcd_unlock();
|
||||
|
||||
/// @brief Set the resting position for the cursor
|
||||
/// @param row the row where the cursor should rest
|
||||
/// @param col the column where the cursor should rest
|
||||
void lcd_set_cursor_resting_position(uint8_t row, uint8_t col);
|
||||
|
||||
/// @brief Get the current resting position of the cursor
|
||||
/// @param row pointer to store the resting row
|
||||
/// @param col pointer to store the resting column
|
||||
void lcd_get_cursor_resting_position(uint8_t* row, uint8_t* col);
|
||||
|
||||
/// @brief Check if the cursor is currently visible
|
||||
/// @return true if cursor is visible, false otherwise
|
||||
bool lcd_is_cursor_visible();
|
||||
|
||||
#endif /* CHAR_LCD_H */
|
||||
#endif /* CHAR_LCD_H */
|
||||
@ -17,5 +17,5 @@ void lcd_print_header_step() {
|
||||
if (!lcd_header_enabled()) return;
|
||||
if (lcd_starcode_displaying_result()) return;
|
||||
|
||||
lcd_print(0, 10, game_state);
|
||||
lcd_print(10, 0, game_state);
|
||||
}
|
||||
|
||||
@ -1,494 +0,0 @@
|
||||
#include "hwdata.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "bottom_half.h"
|
||||
#include "char_lcd.h"
|
||||
#include "../helper.h"
|
||||
#include "nvs.h"
|
||||
|
||||
static const char* TAG = "hwdata";
|
||||
|
||||
HWData::HWData()
|
||||
: compat_mode(true)
|
||||
{}
|
||||
|
||||
HWData::HWData(HWData1 data, bool compat_mode)
|
||||
: compat_mode(compat_mode),
|
||||
inner(data)
|
||||
{}
|
||||
|
||||
esp_err_t HWData::save(nvs_handle_t handle, bool force) {
|
||||
if (compat_mode && !force) {
|
||||
ESP_LOGW(TAG, "Not saving due to being in compatability mode.");
|
||||
return ESP_OK;
|
||||
}
|
||||
return inner.save(handle);
|
||||
}
|
||||
|
||||
HWData HWData::load(nvs_handle_t handle) {
|
||||
esp_err_t err;
|
||||
|
||||
uint16_t stored_version = 0;
|
||||
err = nvs_get_u16(handle, "version", &stored_version);
|
||||
if (err == ESP_ERR_NVS_NOT_FOUND) {
|
||||
ESP_LOGE(TAG, "No NVS data found! using defaults");
|
||||
return HWData();
|
||||
} else if (err != ESP_OK) {
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(err);
|
||||
ESP_LOGE(TAG, "Other esp error! using defaults");
|
||||
return HWData();
|
||||
}
|
||||
|
||||
HWData1 data;
|
||||
switch (stored_version) {
|
||||
case 0:
|
||||
ESP_LOGE(TAG, "HWData version was 0! using defaults");
|
||||
return HWData();
|
||||
case 1:
|
||||
data.load(handle);
|
||||
return HWData(data, false);
|
||||
default:
|
||||
ESP_LOGW(TAG, "Max currently supported version is %d, but saved version is %d. Loading version %d anyway!", CURRENT_HWDATA_VERSION, stored_version, CURRENT_HWDATA_VERSION);
|
||||
data.load(handle);
|
||||
return HWData(data, true);
|
||||
}
|
||||
}
|
||||
|
||||
HWData1::HWData1() {}
|
||||
|
||||
esp_err_t HWData1::save(nvs_handle_t handle) const {
|
||||
ESP_ERROR_CHECK(nvs_set_u16(handle, "version", 1));
|
||||
|
||||
// Serial number
|
||||
ESP_ERROR_CHECK(nvs_set_str(handle, "serial_num", serial_num.c_str()));
|
||||
|
||||
// Revisions
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "rev_ctrl_maj", rev_ctrl_maj));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "rev_ctrl_min", rev_ctrl_min));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "rev_exp_maj", rev_exp_maj));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "rev_exp_min", rev_exp_min));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "rev_ft_maj", rev_ft_maj));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "rev_ft_min", rev_ft_min));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "rev_fb_maj", rev_fb_maj));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "rev_fb_min", rev_fb_min));
|
||||
|
||||
// Enums
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "sseg_color_t", static_cast<uint8_t>(sseg_color_t)));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "sseg_color_b", static_cast<uint8_t>(sseg_color_b)));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "lcd_color", static_cast<uint8_t>(lcd_color)));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "button_type", static_cast<uint8_t>(button_type)));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "tft_type", static_cast<uint8_t>(tft_type)));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "bat_type", static_cast<uint8_t>(bat_type)));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "shape1", static_cast<uint8_t>(shape1)));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "shape2", static_cast<uint8_t>(shape2)));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "shape3", static_cast<uint8_t>(shape3)));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "shape4", static_cast<uint8_t>(shape4)));
|
||||
|
||||
// Other fields
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "switch_pos", switch_pos));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "has_speaker", has_speaker));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "has_mic", has_mic));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "has_ir", has_ir));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "has_rfid", has_rfid));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "has_fp", has_fp));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "has_fp_hall", has_fp_hall));
|
||||
ESP_ERROR_CHECK(nvs_set_u8(handle, "has_close_hall", has_close_hall));
|
||||
|
||||
// Battery capacity
|
||||
ESP_ERROR_CHECK(nvs_set_u16(handle, "bat_cap", bat_cap));
|
||||
|
||||
return nvs_commit(handle);
|
||||
}
|
||||
|
||||
void HWData1::load(nvs_handle_t handle) {
|
||||
char buf[128];
|
||||
size_t required_size = sizeof(buf);
|
||||
esp_err_t err = nvs_get_str(handle, "serial_num", buf, &required_size);
|
||||
serial_num = (err == ESP_OK) ? std::string(buf) : "";
|
||||
|
||||
nvs_get_u8(handle, "rev_ctrl_maj", &rev_ctrl_maj);
|
||||
nvs_get_u8(handle, "rev_ctrl_min", &rev_ctrl_min);
|
||||
nvs_get_u8(handle, "rev_exp_maj", &rev_exp_maj);
|
||||
nvs_get_u8(handle, "rev_exp_min", &rev_exp_min);
|
||||
nvs_get_u8(handle, "rev_ft_maj", &rev_ft_maj);
|
||||
nvs_get_u8(handle, "rev_ft_min", &rev_ft_min);
|
||||
nvs_get_u8(handle, "rev_fb_maj", &rev_fb_maj);
|
||||
nvs_get_u8(handle, "rev_fb_min", &rev_fb_min);
|
||||
|
||||
uint8_t tmp;
|
||||
if (nvs_get_u8(handle, "sseg_color_t", &tmp) == ESP_OK) sseg_color_t = static_cast<SSegColor>(tmp);
|
||||
if (nvs_get_u8(handle, "sseg_color_b", &tmp) == ESP_OK) sseg_color_b = static_cast<SSegColor>(tmp);
|
||||
if (nvs_get_u8(handle, "lcd_color", &tmp) == ESP_OK) lcd_color = static_cast<LCDColor>(tmp);
|
||||
if (nvs_get_u8(handle, "button_type", &tmp) == ESP_OK) button_type = static_cast<ButtonType>(tmp);
|
||||
if (nvs_get_u8(handle, "tft_type", &tmp) == ESP_OK) tft_type = static_cast<TFTType>(tmp);
|
||||
if (nvs_get_u8(handle, "bat_type", &tmp) == ESP_OK) bat_type = static_cast<BatType>(tmp);
|
||||
nvs_get_u16(handle, "bat_cap", &bat_cap);
|
||||
|
||||
if (nvs_get_u8(handle, "shape1", &tmp) == ESP_OK) shape1 = static_cast<ShapeType>(tmp);
|
||||
if (nvs_get_u8(handle, "shape2", &tmp) == ESP_OK) shape2 = static_cast<ShapeType>(tmp);
|
||||
if (nvs_get_u8(handle, "shape3", &tmp) == ESP_OK) shape3 = static_cast<ShapeType>(tmp);
|
||||
if (nvs_get_u8(handle, "shape4", &tmp) == ESP_OK) shape4 = static_cast<ShapeType>(tmp);
|
||||
|
||||
nvs_get_u8(handle, "switch_pos", &switch_pos);
|
||||
nvs_get_u8(handle, "has_speaker", &tmp); has_speaker = tmp;
|
||||
nvs_get_u8(handle, "has_mic", &tmp); has_mic = tmp;
|
||||
nvs_get_u8(handle, "has_ir", &tmp); has_ir = tmp;
|
||||
nvs_get_u8(handle, "has_rfid", &tmp); has_rfid = tmp;
|
||||
nvs_get_u8(handle, "has_fp", &tmp); has_fp = tmp;
|
||||
nvs_get_u8(handle, "has_fp_hall", &tmp); has_fp_hall = tmp;
|
||||
nvs_get_u8(handle, "has_close_hall", &tmp); has_close_hall = tmp;
|
||||
}
|
||||
|
||||
static void handle_uint8(KeypadKey key, uint8_t& val) {
|
||||
char key_c = char_of_keypad_key(key);
|
||||
bool is_digit = std::isdigit(static_cast<unsigned char>(key_c));
|
||||
uint8_t digit = is_digit ? static_cast<uint8_t>(key_c - '0') : 0;
|
||||
|
||||
if (key == KeypadKey::star) {
|
||||
val = 0;
|
||||
} else if (is_digit) {
|
||||
uint16_t new_digit = ((uint16_t) val) * 10 + (uint16_t) digit;
|
||||
if (new_digit < 255) val = new_digit;
|
||||
}
|
||||
}
|
||||
static void handle_uint16(KeypadKey key, uint16_t& val) {
|
||||
char key_c = char_of_keypad_key(key);
|
||||
bool is_digit = std::isdigit(static_cast<unsigned char>(key_c));
|
||||
uint8_t digit = is_digit ? static_cast<uint8_t>(key_c - '0') : 0;
|
||||
|
||||
if (key == KeypadKey::star) {
|
||||
val = 0;
|
||||
} else if (is_digit) {
|
||||
uint32_t new_digit = ((uint32_t) val) * 10 + (uint32_t) digit;
|
||||
if (new_digit < 65535) val = new_digit;
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_enum(ButtonKey key, uint8_t& val, uint8_t n_items) {
|
||||
if (key == ButtonKey::b1) {
|
||||
// dec
|
||||
val = (val + n_items - 1) % n_items;
|
||||
} else if (key == ButtonKey::b2) {
|
||||
// inc
|
||||
val = (val + 1) % n_items;
|
||||
}
|
||||
}
|
||||
|
||||
void hardware_config() {
|
||||
clean_bomb();
|
||||
uint8_t current_item = 0;
|
||||
const uint8_t n_items = 28;
|
||||
|
||||
HWData1& hwdata = get_hw_data().inner;
|
||||
|
||||
ButtonKey btn;
|
||||
KeypadKey key;
|
||||
bool dirty = true;
|
||||
while (true) {
|
||||
if (dirty) {
|
||||
// display
|
||||
char name[21];
|
||||
char value[21];
|
||||
|
||||
switch (current_item) {
|
||||
case 0: // serial_num
|
||||
snprintf(name, sizeof(name), "%-20s", "serial_num");
|
||||
snprintf(value, sizeof(value), "%s", hwdata.serial_num.c_str());
|
||||
break;
|
||||
|
||||
case 1: // rev_ctrl_maj
|
||||
snprintf(name, sizeof(name), "%-20s", "rev_ctrl_maj");
|
||||
snprintf(value, sizeof(value), "%d", hwdata.rev_ctrl_maj);
|
||||
break;
|
||||
|
||||
case 2: // rev_ctrl_min
|
||||
snprintf(name, sizeof(name), "%-20s", "rev_ctrl_min");
|
||||
snprintf(value, sizeof(value), "%d", hwdata.rev_ctrl_min);
|
||||
break;
|
||||
|
||||
case 3: // rev_exp_maj
|
||||
snprintf(name, sizeof(name), "%-20s", "rev_exp_maj");
|
||||
snprintf(value, sizeof(value), "%d", hwdata.rev_exp_maj);
|
||||
break;
|
||||
|
||||
case 4: // rev_exp_min
|
||||
snprintf(name, sizeof(name), "%-20s", "rev_exp_min");
|
||||
snprintf(value, sizeof(value), "%d", hwdata.rev_exp_min);
|
||||
break;
|
||||
|
||||
case 5: // rev_ft_maj
|
||||
snprintf(name, sizeof(name), "%-20s", "rev_ft_maj");
|
||||
snprintf(value, sizeof(value), "%d", hwdata.rev_ft_maj);
|
||||
break;
|
||||
|
||||
case 6: // rev_ft_min
|
||||
snprintf(name, sizeof(name), "%-20s", "rev_ft_min");
|
||||
snprintf(value, sizeof(value), "%d", hwdata.rev_ft_min);
|
||||
break;
|
||||
|
||||
case 7: // rev_fb_maj
|
||||
snprintf(name, sizeof(name), "%-20s", "rev_fb_maj");
|
||||
snprintf(value, sizeof(value), "%d", hwdata.rev_fb_maj);
|
||||
break;
|
||||
|
||||
case 8: // rev_fb_min
|
||||
snprintf(name, sizeof(name), "%-20s", "rev_fb_min");
|
||||
snprintf(value, sizeof(value), "%d", hwdata.rev_fb_min);
|
||||
break;
|
||||
|
||||
case 9: // sseg_color_t
|
||||
snprintf(name, sizeof(name), "%-20s", "sseg_color_t");
|
||||
snprintf(value, sizeof(value), "%s", SSEG_COLOR_NAMES[static_cast<uint8_t>(hwdata.sseg_color_t)]);
|
||||
break;
|
||||
|
||||
case 10: // sseg_color_b
|
||||
snprintf(name, sizeof(name), "%-20s", "sseg_color_b");
|
||||
snprintf(value, sizeof(value), "%s", SSEG_COLOR_NAMES[static_cast<uint8_t>(hwdata.sseg_color_b)]);
|
||||
break;
|
||||
|
||||
case 11: // lcd_color
|
||||
snprintf(name, sizeof(name), "%-20s", "lcd_color");
|
||||
snprintf(value, sizeof(value), "%s", LCD_COLOR_NAMES[static_cast<uint8_t>(hwdata.lcd_color)]);
|
||||
break;
|
||||
|
||||
case 12: // switch_pos
|
||||
snprintf(name, sizeof(name), "%-20s", "switch_pos");
|
||||
snprintf(value, sizeof(value), "%d", hwdata.switch_pos);
|
||||
break;
|
||||
|
||||
case 13: // button_type
|
||||
snprintf(name, sizeof(name), "%-20s", "button_type");
|
||||
snprintf(value, sizeof(value), "%s", BUTTON_TYPE_NAMES[static_cast<uint8_t>(hwdata.button_type)]);
|
||||
break;
|
||||
|
||||
case 14: // tft_type
|
||||
snprintf(name, sizeof(name), "%-20s", "tft_type");
|
||||
snprintf(value, sizeof(value), "%s", TFT_TYPE_NAMES[static_cast<uint8_t>(hwdata.tft_type)]);
|
||||
break;
|
||||
|
||||
case 15: // bat_type
|
||||
snprintf(name, sizeof(name), "%-20s", "bat_type");
|
||||
snprintf(value, sizeof(value), "%s", BAT_TYPE_NAMES[static_cast<uint8_t>(hwdata.bat_type)]);
|
||||
break;
|
||||
|
||||
case 16: // bat_cap
|
||||
snprintf(name, sizeof(name), "%-20s", "bat_cap");
|
||||
snprintf(value, sizeof(value), "%d", hwdata.bat_cap);
|
||||
break;
|
||||
|
||||
case 17: // shape1
|
||||
snprintf(name, sizeof(name), "%-20s", "shape1");
|
||||
snprintf(value, sizeof(value), "%s", SHAPE_TYPE_NAMES[static_cast<uint8_t>(hwdata.shape1)]);
|
||||
break;
|
||||
|
||||
case 18: // shape2
|
||||
snprintf(name, sizeof(name), "%-20s", "shape2");
|
||||
snprintf(value, sizeof(value), "%s", SHAPE_TYPE_NAMES[static_cast<uint8_t>(hwdata.shape2)]);
|
||||
break;
|
||||
|
||||
case 19: // shape3
|
||||
snprintf(name, sizeof(name), "%-20s", "shape3");
|
||||
snprintf(value, sizeof(value), "%s", SHAPE_TYPE_NAMES[static_cast<uint8_t>(hwdata.shape3)]);
|
||||
break;
|
||||
|
||||
case 20: // shape4
|
||||
snprintf(name, sizeof(name), "%-20s", "shape4");
|
||||
snprintf(value, sizeof(value), "%s", SHAPE_TYPE_NAMES[static_cast<uint8_t>(hwdata.shape4)]);
|
||||
break;
|
||||
|
||||
case 21: // has_speaker
|
||||
snprintf(name, sizeof(name), "%-20s", "has_speaker");
|
||||
snprintf(value, sizeof(value), "%s", hwdata.has_speaker ? "true" : "false");
|
||||
break;
|
||||
|
||||
case 22: // has_mic
|
||||
snprintf(name, sizeof(name), "%-20s", "has_mic");
|
||||
snprintf(value, sizeof(value), "%s", hwdata.has_mic ? "true" : "false");
|
||||
break;
|
||||
|
||||
case 23: // has_ir
|
||||
snprintf(name, sizeof(name), "%-20s", "has_ir");
|
||||
snprintf(value, sizeof(value), "%s", hwdata.has_ir ? "true" : "false");
|
||||
break;
|
||||
|
||||
case 24: // has_rfid
|
||||
snprintf(name, sizeof(name), "%-20s", "has_rfid");
|
||||
snprintf(value, sizeof(value), "%s", hwdata.has_rfid ? "true" : "false");
|
||||
break;
|
||||
|
||||
case 25: // has_fp
|
||||
snprintf(name, sizeof(name), "%-20s", "has_fp");
|
||||
snprintf(value, sizeof(value), "%s", hwdata.has_fp ? "true" : "false");
|
||||
break;
|
||||
|
||||
case 26: // has_fp_hall
|
||||
snprintf(name, sizeof(name), "%-20s", "has_fp_hall");
|
||||
snprintf(value, sizeof(value), "%s", hwdata.has_fp_hall ? "true" : "false");
|
||||
break;
|
||||
|
||||
case 27: // has_close_hall
|
||||
snprintf(name, sizeof(name), "%-20s", "has_close_hall");
|
||||
snprintf(value, sizeof(value), "%s", hwdata.has_close_hall ? "true" : "false");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
lcd_print(1, 0, name);
|
||||
lcd_print(2, 0, value);
|
||||
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
if (get_button_pressed(&btn)) {
|
||||
dirty = true;
|
||||
switch (btn) {
|
||||
case ButtonKey::b3: // dec
|
||||
current_item = (current_item + n_items - 1) % n_items;
|
||||
break;
|
||||
case ButtonKey::b4: // inc
|
||||
current_item = (current_item + 1) % n_items;
|
||||
break;
|
||||
default:
|
||||
switch (current_item) {
|
||||
case 9: // sseg_color_t
|
||||
handle_enum(btn, reinterpret_cast<uint8_t&>(hwdata.sseg_color_t), SSEG_COLOR_COUNT);
|
||||
break;
|
||||
|
||||
case 10: // sseg_color_b
|
||||
handle_enum(btn, reinterpret_cast<uint8_t&>(hwdata.sseg_color_b), SSEG_COLOR_COUNT);
|
||||
break;
|
||||
|
||||
case 11: // lcd_color
|
||||
handle_enum(btn, reinterpret_cast<uint8_t&>(hwdata.lcd_color), LCD_COLOR_COUNT);
|
||||
break;
|
||||
|
||||
case 13: // button_type
|
||||
handle_enum(btn, reinterpret_cast<uint8_t&>(hwdata.button_type), BUTTON_TYPE_COUNT);
|
||||
break;
|
||||
|
||||
case 14: // tft_type
|
||||
handle_enum(btn, reinterpret_cast<uint8_t&>(hwdata.tft_type), TFT_TYPE_COUNT);
|
||||
break;
|
||||
|
||||
case 15: // bat_type
|
||||
handle_enum(btn, reinterpret_cast<uint8_t&>(hwdata.bat_type), BAT_TYPE_COUNT);
|
||||
break;
|
||||
|
||||
case 17: // shape1
|
||||
handle_enum(btn, reinterpret_cast<uint8_t&>(hwdata.shape1), SHAPE_TYPE_COUNT);
|
||||
break;
|
||||
case 18: // shape2
|
||||
handle_enum(btn, reinterpret_cast<uint8_t&>(hwdata.shape2), SHAPE_TYPE_COUNT);
|
||||
break;
|
||||
case 19: // shape3
|
||||
handle_enum(btn, reinterpret_cast<uint8_t&>(hwdata.shape3), SHAPE_TYPE_COUNT);
|
||||
break;
|
||||
case 20: // shape4
|
||||
handle_enum(btn, reinterpret_cast<uint8_t&>(hwdata.shape4), SHAPE_TYPE_COUNT);
|
||||
break;
|
||||
|
||||
case 21: // has_speaker
|
||||
hwdata.has_speaker = btn == ButtonKey::button_green;
|
||||
break;
|
||||
|
||||
case 22: // has_mic
|
||||
hwdata.has_mic = btn == ButtonKey::button_green;
|
||||
break;
|
||||
|
||||
case 23: // has_ir
|
||||
hwdata.has_ir = btn == ButtonKey::button_green;
|
||||
break;
|
||||
|
||||
case 24: // has_rfid
|
||||
hwdata.has_rfid = btn == ButtonKey::button_green;
|
||||
break;
|
||||
|
||||
case 25: // has_fp
|
||||
hwdata.has_fp = btn == ButtonKey::button_green;
|
||||
break;
|
||||
|
||||
case 26: // has_fp_hall
|
||||
hwdata.has_fp_hall = btn == ButtonKey::button_green;
|
||||
break;
|
||||
|
||||
case 27: // has_close_hall
|
||||
hwdata.has_close_hall = btn == ButtonKey::button_green;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (get_keypad_pressed(&key)) {
|
||||
dirty = true;
|
||||
if (key == KeypadKey::pound) {
|
||||
// TODO: ask the user to save
|
||||
return; // done
|
||||
}
|
||||
|
||||
char key_c = char_of_keypad_key(key);
|
||||
bool is_digit = std::isdigit(static_cast<unsigned char>(key_c));
|
||||
uint8_t digit = is_digit ? static_cast<uint8_t>(key_c - '0') : 0;
|
||||
|
||||
// update the current value
|
||||
switch (current_item) {
|
||||
case 0: // serial_num
|
||||
if (key == KeypadKey::star) {
|
||||
hwdata.serial_num.clear();
|
||||
} else {
|
||||
hwdata.serial_num.push_back(char_of_keypad_key(key));
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: // rev_ctrl_maj
|
||||
handle_uint8(key, hwdata.rev_ctrl_maj);
|
||||
break;
|
||||
|
||||
case 2: // rev_ctrl_min
|
||||
handle_uint8(key, hwdata.rev_ctrl_min);
|
||||
break;
|
||||
|
||||
case 3: // rev_exp_maj
|
||||
handle_uint8(key, hwdata.rev_exp_maj);
|
||||
break;
|
||||
|
||||
case 4: // rev_exp_min
|
||||
handle_uint8(key, hwdata.rev_exp_min);
|
||||
break;
|
||||
|
||||
case 5: // rev_ft_maj
|
||||
handle_uint8(key, hwdata.rev_ft_maj);
|
||||
break;
|
||||
|
||||
case 6: // rev_ft_min
|
||||
handle_uint8(key, hwdata.rev_ft_min);
|
||||
break;
|
||||
|
||||
case 7: // rev_fb_maj
|
||||
handle_uint8(key, hwdata.rev_fb_maj);
|
||||
break;
|
||||
|
||||
case 8: // rev_fb_min
|
||||
handle_uint8(key, hwdata.rev_fb_min);
|
||||
break;
|
||||
|
||||
case 12: // switch_pos
|
||||
if (digit == 2 || digit == 3) hwdata.switch_pos = digit;
|
||||
break;
|
||||
|
||||
case 16: // bat_cap
|
||||
handle_uint16(key, hwdata.bat_cap);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
}
|
||||
@ -1,199 +0,0 @@
|
||||
#ifndef HWDATA_H
|
||||
#define HWDATA_H
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include "esp_err.h"
|
||||
#include "nvs_flash.h"
|
||||
|
||||
#define CURRENT_HWDATA_VERSION 1
|
||||
#define CURRENT_HWDATA_STRUCT HWData1
|
||||
|
||||
#define SSEG_COLOR_COUNT 10
|
||||
static constexpr const char* SSEG_COLOR_NAMES[SSEG_COLOR_COUNT] = {
|
||||
"UNKNOWN",
|
||||
"NONE",
|
||||
"OTHER",
|
||||
"RED",
|
||||
"ORANGE",
|
||||
"YELLOW",
|
||||
"GREEN",
|
||||
"BLUE",
|
||||
"PURPLE",
|
||||
"WHITE"
|
||||
};
|
||||
enum class SSegColor : uint8_t {
|
||||
UNKNOWN = 0,
|
||||
NONE = 1,
|
||||
OTHER = 2,
|
||||
RED = 3,
|
||||
ORANGE = 4,
|
||||
YELLOW = 5,
|
||||
GREEN = 6,
|
||||
BLUE = 7,
|
||||
PURPLE = 8,
|
||||
WHITE = 9,
|
||||
};
|
||||
|
||||
#define LCD_COLOR_COUNT 8
|
||||
static constexpr const char* LCD_COLOR_NAMES[LCD_COLOR_COUNT] = {
|
||||
"UNKNOWN",
|
||||
"NONE",
|
||||
"OTHER",
|
||||
"BLACK_GREEN",
|
||||
"WHITE_BLUE",
|
||||
"BLACK_SKY",
|
||||
"BLACK_WHITE",
|
||||
"WHITE_BLACK"
|
||||
};
|
||||
enum class LCDColor : uint8_t {
|
||||
UNKNOWN = 0,
|
||||
NONE = 1,
|
||||
OTHER = 2,
|
||||
BLACK_GREEN = 3,
|
||||
WHITE_BLUE = 4,
|
||||
BLACK_SKY = 5,
|
||||
BLACK_WHITE = 6,
|
||||
WHITE_BLACK = 7,
|
||||
};
|
||||
|
||||
#define BUTTON_TYPE_COUNT 6
|
||||
static constexpr const char* BUTTON_TYPE_NAMES[BUTTON_TYPE_COUNT] = {
|
||||
"UNKNOWN",
|
||||
"NONE",
|
||||
"OTHER",
|
||||
"WHITE",
|
||||
"BROWN",
|
||||
"RED"
|
||||
};
|
||||
enum class ButtonType : uint8_t {
|
||||
UNKNOWN = 0,
|
||||
NONE = 1,
|
||||
OTHER = 2,
|
||||
WHITE = 3,
|
||||
BROWN = 4,
|
||||
RED = 5,
|
||||
};
|
||||
|
||||
#define TFT_TYPE_COUNT 5
|
||||
static constexpr const char* TFT_TYPE_NAMES[TFT_TYPE_COUNT] = {
|
||||
"UNKNOWN",
|
||||
"NONE",
|
||||
"OTHER",
|
||||
"EAST_RISING",
|
||||
"SHENZHEN"
|
||||
};
|
||||
enum class TFTType : uint8_t {
|
||||
UNKNOWN = 0,
|
||||
NONE = 1,
|
||||
OTHER = 2,
|
||||
EAST_RISING = 3,
|
||||
SHENZHEN = 4,
|
||||
};
|
||||
|
||||
#define BAT_TYPE_COUNT 5
|
||||
static constexpr const char* BAT_TYPE_NAMES[BAT_TYPE_COUNT] = {
|
||||
"UNKNOWN",
|
||||
"NONE",
|
||||
"OTHER",
|
||||
"BAT_18650",
|
||||
"LIPO"
|
||||
};
|
||||
enum class BatType : uint8_t {
|
||||
UNKNOWN = 0,
|
||||
NONE = 1,
|
||||
OTHER = 2,
|
||||
BAT_18650 = 3,
|
||||
LIPO = 4,
|
||||
};
|
||||
|
||||
#define SHAPE_TYPE_COUNT 11
|
||||
static constexpr const char* SHAPE_TYPE_NAMES[SHAPE_TYPE_COUNT] = {
|
||||
"UNKNOWN",
|
||||
"OTHER",
|
||||
"CIRCLE",
|
||||
"SQUARE",
|
||||
"TRIANGLE",
|
||||
"X",
|
||||
"STAR",
|
||||
"SPADE",
|
||||
"DIAMOND",
|
||||
"CLUB",
|
||||
"HEART"
|
||||
};
|
||||
enum class ShapeType : uint8_t {
|
||||
UNKNOWN = 0,
|
||||
OTHER = 1,
|
||||
CIRCLE = 2,
|
||||
SQUARE = 3,
|
||||
TRIANGLE = 4,
|
||||
X = 5,
|
||||
STAR = 6,
|
||||
SPADE = 7,
|
||||
DIAMOND = 8,
|
||||
CLUB = 9,
|
||||
HEART = 10,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// @brief Version 1 of HWData, kept constant for migrations
|
||||
struct HWData1 {
|
||||
std::string serial_num;
|
||||
uint8_t rev_ctrl_maj;
|
||||
uint8_t rev_ctrl_min;
|
||||
uint8_t rev_exp_maj;
|
||||
uint8_t rev_exp_min;
|
||||
uint8_t rev_ft_maj;
|
||||
uint8_t rev_ft_min;
|
||||
uint8_t rev_fb_maj;
|
||||
uint8_t rev_fb_min;
|
||||
|
||||
SSegColor sseg_color_t;
|
||||
SSegColor sseg_color_b;
|
||||
LCDColor lcd_color;
|
||||
uint8_t switch_pos;
|
||||
ButtonType button_type;
|
||||
TFTType tft_type;
|
||||
BatType bat_type;
|
||||
uint16_t bat_cap;
|
||||
|
||||
ShapeType shape1;
|
||||
ShapeType shape2;
|
||||
ShapeType shape3;
|
||||
ShapeType shape4;
|
||||
|
||||
bool has_speaker;
|
||||
bool has_mic;
|
||||
bool has_ir;
|
||||
bool has_rfid;
|
||||
bool has_fp;
|
||||
bool has_fp_hall;
|
||||
bool has_close_hall;
|
||||
|
||||
HWData1();
|
||||
|
||||
esp_err_t save(nvs_handle_t handle) const;
|
||||
void load(nvs_handle_t handle);
|
||||
|
||||
// Add migration method as necessary
|
||||
};
|
||||
|
||||
/// @brief The current version of HWData, to be stored
|
||||
struct HWData {
|
||||
/// @brief `true` if there is some issue in loading, and we are doing a "best effort" to be compatible
|
||||
/// We should make no writes to NVS if this is `true`.
|
||||
volatile bool compat_mode;
|
||||
HWData1 inner;
|
||||
|
||||
HWData();
|
||||
HWData(HWData1 data, bool compat_mode);
|
||||
|
||||
esp_err_t save(nvs_handle_t handle, bool force = false);
|
||||
static HWData load(nvs_handle_t handle);
|
||||
};
|
||||
|
||||
void hardware_config();
|
||||
|
||||
#endif /* HWDATA_H */
|
||||
@ -233,7 +233,7 @@ void lcd_no_autoscroll(i2c_lcd_pcf8574_handle_t* lcd) {
|
||||
|
||||
// Setting the backlight: It can only be turn on or off.
|
||||
// Current backlight value is saved in the i2c_lcd_pcf8574_handle_t struct for further data transfers
|
||||
void lcd_set_backlight_to(i2c_lcd_pcf8574_handle_t* lcd, uint8_t brightness) {
|
||||
void lcd_set_backlight(i2c_lcd_pcf8574_handle_t* lcd, uint8_t brightness) {
|
||||
// Place the backlight value in the lcd struct
|
||||
lcd->backlight = brightness;
|
||||
// Send no data
|
||||
@ -258,12 +258,7 @@ void lcd_write(i2c_lcd_pcf8574_handle_t* lcd, uint8_t value) {
|
||||
// Print characters to the LCD: cursor set or clear instruction must preceded this instruction, or it will write on the current text.
|
||||
void lcd_print(i2c_lcd_pcf8574_handle_t* lcd, const char* str) {
|
||||
while (*str) {
|
||||
if (*str == '\x08') {
|
||||
lcd_write(lcd, '\x00');
|
||||
str++;
|
||||
} else {
|
||||
lcd_write(lcd, *str++);
|
||||
}
|
||||
lcd_write(lcd, *str++);
|
||||
}
|
||||
} // lcd_print()
|
||||
|
||||
@ -301,17 +296,18 @@ void lcd_print_number(i2c_lcd_pcf8574_handle_t* lcd, uint8_t col, uint8_t row, u
|
||||
|
||||
// Private functions: derived from the esp32 i2c_master driver
|
||||
|
||||
|
||||
static void lcd_send(i2c_lcd_pcf8574_handle_t* lcd, uint8_t value, bool is_data) {
|
||||
xSemaphoreTake(main_i2c_mutex, portMAX_DELAY);
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (lcd->i2c_addr << 1) | I2C_MASTER_WRITE, true);
|
||||
xSemaphoreTake(main_i2c_mutex, portMAX_DELAY);
|
||||
lcd_write_nibble(lcd, (value >> 4 & 0x0F), is_data, cmd);
|
||||
lcd_write_nibble(lcd, (value & 0x0F), is_data, cmd);
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(lcd->i2c_port, cmd, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
|
||||
xSemaphoreGive(main_i2c_mutex);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
xSemaphoreGive(main_i2c_mutex);
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to send data to LCD: %s", esp_err_to_name(ret));
|
||||
@ -350,15 +346,15 @@ static void lcd_write_i2c(i2c_lcd_pcf8574_handle_t* lcd, uint8_t data, bool is_d
|
||||
data |= lcd->backlight_mask;
|
||||
}
|
||||
|
||||
xSemaphoreTake(main_i2c_mutex, portMAX_DELAY);
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (lcd->i2c_addr << 1) | I2C_MASTER_WRITE, true);
|
||||
i2c_master_write_byte(cmd, data, true);
|
||||
i2c_master_stop(cmd);
|
||||
xSemaphoreTake(main_i2c_mutex, portMAX_DELAY);
|
||||
esp_err_t ret = i2c_master_cmd_begin(lcd->i2c_port, cmd, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
|
||||
xSemaphoreGive(main_i2c_mutex);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
xSemaphoreGive(main_i2c_mutex);
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to write to LCD: %s", esp_err_to_name(ret));
|
||||
|
||||
@ -91,7 +91,7 @@ void lcd_autoscroll(i2c_lcd_pcf8574_handle_t* lcd);
|
||||
void lcd_no_autoscroll(i2c_lcd_pcf8574_handle_t* lcd);
|
||||
|
||||
// Set backlight brightness
|
||||
void lcd_set_backlight_to(i2c_lcd_pcf8574_handle_t* lcd, uint8_t brightness);
|
||||
void lcd_set_backlight(i2c_lcd_pcf8574_handle_t* lcd, uint8_t brightness);
|
||||
|
||||
// Create a custom character
|
||||
void lcd_create_char(i2c_lcd_pcf8574_handle_t* lcd, uint8_t location, const uint8_t charmap[]);
|
||||
|
||||
@ -1,63 +0,0 @@
|
||||
#include "nvs.h"
|
||||
#include "esp_log.h"
|
||||
#include "bottom_half.h"
|
||||
#include "char_lcd.h"
|
||||
|
||||
static const char* TAG = "nvs";
|
||||
|
||||
static const char* HWDATA_NAMESPACE = "hwdata";
|
||||
static HWData hw_data;
|
||||
|
||||
bool init_nvs() {
|
||||
ESP_LOGI(TAG, "Initializing NVS...");
|
||||
esp_err_t ret = nvs_flash_init();
|
||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
// NVS partition was truncated, erase and retry
|
||||
ESP_LOGE(TAG, "Failed to init nvs flash: %s.", esp_err_to_name(ret));
|
||||
lcd_print(1, 0, "NVS: ");
|
||||
lcd_print(1, 4, esp_err_to_name(ret));
|
||||
lcd_print(2, 0, "Press Yellow to skip");
|
||||
lcd_print(3, 0, "Press Red to erase");
|
||||
|
||||
ButtonKey button;
|
||||
while (!( get_button_pressed(&button) && (button == ButtonKey::button_red || button == ButtonKey::button_yellow) )) vTaskDelay(pdMS_TO_TICKS(10));
|
||||
|
||||
lcd_clear();
|
||||
|
||||
if (button == ButtonKey::button_yellow) {
|
||||
return false;
|
||||
}
|
||||
if (button == ButtonKey::button_red) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
ret = nvs_flash_init();
|
||||
}
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
nvs_handle_t hw_handle;
|
||||
ret = nvs_open(HWDATA_NAMESPACE, NVS_READONLY, &hw_handle);
|
||||
if (ret == ESP_ERR_NVS_NOT_FOUND) {
|
||||
ESP_LOGW(TAG, "Partition \"%s\" has not been initialized. Loading defaults.", HWDATA_NAMESPACE);
|
||||
hw_data = HWData();
|
||||
} else {
|
||||
ESP_ERROR_CHECK(ret);
|
||||
hw_data = HWData::load(hw_handle);
|
||||
nvs_close(hw_handle);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "NVS initialized!");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
HWData& get_hw_data() {
|
||||
return hw_data;
|
||||
}
|
||||
|
||||
void save_hw_data(bool force) {
|
||||
nvs_handle_t hw_handle;
|
||||
ESP_ERROR_CHECK(nvs_open(HWDATA_NAMESPACE, NVS_READWRITE, &hw_handle));
|
||||
hw_data.save(hw_handle);
|
||||
nvs_close(hw_handle);
|
||||
}
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
#ifndef NVS_H
|
||||
#define NVS_H
|
||||
|
||||
#include "nvs_flash.h"
|
||||
#include "hwdata.h"
|
||||
|
||||
/// @brief Initializes the NVS.
|
||||
bool init_nvs();
|
||||
|
||||
/// Gets the HWData stored in NVS.
|
||||
HWData& get_hw_data();
|
||||
|
||||
#endif /* NVS_H */
|
||||
@ -12,9 +12,9 @@ void bat_monitor_task(void* arg) {
|
||||
sprintf(str_buf, "%d.%03dV", voltage / 1000, voltage % 1000);
|
||||
|
||||
lcd_clear();
|
||||
lcd_print(0, 1, str_buf);
|
||||
lcd_print(1, 0, str_buf);
|
||||
|
||||
int16_t current = lipo.current();
|
||||
int16_t current = lipo.current(current_measure::AVG);
|
||||
sprintf(str_buf, "%dmA", current);
|
||||
|
||||
lcd_print(1, 1, str_buf);
|
||||
@ -23,12 +23,12 @@ void bat_monitor_task(void* arg) {
|
||||
int16_t total_cap = lipo.capacity(capacity_measure::FULL);
|
||||
sprintf(str_buf, "%dmAh", total_cap);
|
||||
|
||||
lcd_print(2, 1, str_buf);
|
||||
lcd_print(1, 2, str_buf);
|
||||
|
||||
int16_t soc = lipo.soc(soc_measure::FILTERED);
|
||||
sprintf(str_buf, "%d%%", soc);
|
||||
|
||||
lcd_print(3, 1, str_buf);
|
||||
lcd_print(1, 3, str_buf);
|
||||
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(250));
|
||||
@ -60,7 +60,7 @@ void lcd_print_header_bat() {
|
||||
if (lcd_starcode_displaying_result()) return;
|
||||
|
||||
uint8_t soc = lipo.soc();
|
||||
int16_t current = lipo.current();
|
||||
uint8_t current = lipo.current();
|
||||
char buf[6];
|
||||
if (soc < 5 && current <= 0) {
|
||||
snprintf(buf, sizeof(buf), " LOW");
|
||||
@ -74,27 +74,5 @@ void lcd_print_header_bat() {
|
||||
}
|
||||
}
|
||||
|
||||
lcd_print(0, 16, buf);
|
||||
lcd_print(16, 0, buf);
|
||||
}
|
||||
|
||||
// memory version
|
||||
// void lcd_print_header_bat() {
|
||||
// if (!lcd_header_enabled()) return;
|
||||
// if (lcd_starcode_displaying_result()) return;
|
||||
|
||||
// // Show memory usage percentage instead of battery percentage
|
||||
// char buf[6];
|
||||
// size_t free_heap = heap_caps_get_free_size(MALLOC_CAP_DEFAULT);
|
||||
// size_t total_heap = heap_caps_get_total_size(MALLOC_CAP_DEFAULT);
|
||||
// uint8_t mem_percent = 0;
|
||||
// if (total_heap > 0) {
|
||||
// mem_percent = (uint8_t)(100 - ((free_heap * 100) / total_heap));
|
||||
// }
|
||||
// if (mem_percent >= 100) {
|
||||
// snprintf(buf, sizeof(buf), " 100");
|
||||
// } else {
|
||||
// snprintf(buf, sizeof(buf), " %2d%%", mem_percent);
|
||||
// }
|
||||
|
||||
// lcd_print(0, 16, buf);
|
||||
// }
|
||||
|
||||
@ -51,10 +51,10 @@ bool init_sd() {
|
||||
ESP_LOGE(TAG, "Failed to mount sd card: %s.", esp_err_to_name(ret));
|
||||
|
||||
lcd_print(0, 0, "SD: ");
|
||||
lcd_print(0, 4, esp_err_to_name(ret));
|
||||
lcd_print(1, 0, "Press Green to retry");
|
||||
lcd_print(2, 0, "Press Yellow to skip");
|
||||
lcd_print(3, 0, "Press Red to format");
|
||||
lcd_print(4, 0, esp_err_to_name(ret));
|
||||
lcd_print(0, 1, "Press Green to retry");
|
||||
lcd_print(0, 2, "Press Yellow to skip");
|
||||
lcd_print(0, 3, "Press Red to format");
|
||||
|
||||
ButtonKey button;
|
||||
while (!( get_button_pressed(&button) && (button == ButtonKey::button_green || button == ButtonKey::button_red || button == ButtonKey::button_yellow) )) vTaskDelay(pdMS_TO_TICKS(10));
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
#include "drivers/bottom_half.h"
|
||||
#include "char_lcd.h"
|
||||
#include "esp_timer.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
static const char* TAG = "star_code";
|
||||
|
||||
@ -15,7 +14,7 @@ volatile bool handling_new_starcodes = false;
|
||||
static volatile bool system_initialized = false;
|
||||
|
||||
// TODO: use the semaphore, convert to RWLock?
|
||||
static volatile SemaphoreHandle_t star_codes_mutex;
|
||||
static volatile SemaphoreHandle_t star_codes_sem;
|
||||
static std::vector<StarCodeEntry> star_codes;
|
||||
|
||||
static const char EMPTY_STAR_CODE_HEADER[] = " ";
|
||||
@ -30,40 +29,23 @@ static uint16_t starcode_waiting_on_release;
|
||||
static char current[STARCODE_MAX_LEN + 1];
|
||||
static size_t current_idx;
|
||||
|
||||
// Task handle for the starcode callback task
|
||||
static TaskHandle_t starcode_callback_task_handle = nullptr;
|
||||
|
||||
static void starcode_callback_task(void* arg) {
|
||||
(void) arg;
|
||||
|
||||
while (true) {
|
||||
// Wait for notification from starcode_trigger_cb
|
||||
uint32_t notification_value;
|
||||
if (xTaskNotifyWait(0, ULONG_MAX, ¬ification_value, portMAX_DELAY) == pdTRUE) {
|
||||
// Process the starcode callback
|
||||
delaying_for_starcode = false;
|
||||
lcd_print_header();
|
||||
|
||||
if (current_starcode != nullptr) {
|
||||
if (current_starcode->triggered_sem != nullptr)
|
||||
xSemaphoreGive(current_starcode->triggered_sem);
|
||||
if (current_starcode->callback != nullptr)
|
||||
(current_starcode->callback)();
|
||||
|
||||
current_starcode = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void starcode_trigger_cb(void* arg) {
|
||||
(void) arg;
|
||||
|
||||
if (starcode_callback_task_handle != nullptr) {
|
||||
xTaskNotify(starcode_callback_task_handle, 1, eSetBits);
|
||||
delaying_for_starcode = false;
|
||||
|
||||
if (current_starcode != nullptr) {
|
||||
if (current_starcode->triggered_sem != nullptr)
|
||||
xSemaphoreGive(current_starcode->triggered_sem);
|
||||
if (current_starcode->callback != nullptr)
|
||||
(current_starcode->callback)();
|
||||
|
||||
current_starcode = nullptr;
|
||||
}
|
||||
|
||||
// TODO: rename star code everywhere to starcode
|
||||
lcd_print_header();
|
||||
}
|
||||
// TODO: rename star code everywhere to starcode
|
||||
|
||||
|
||||
void star_code_handle_keypad(uint16_t* just_pressed, uint16_t* just_released) {
|
||||
@ -109,9 +91,8 @@ void star_code_handle_keypad(uint16_t* just_pressed, uint16_t* just_released) {
|
||||
}
|
||||
|
||||
void init_star_code_system() {
|
||||
star_codes_mutex = xSemaphoreCreateMutex();
|
||||
|
||||
xTaskCreate(starcode_callback_task, "starcode_cb", 4096, NULL, 3, &starcode_callback_task_handle);
|
||||
star_codes_sem = xSemaphoreCreateBinary();
|
||||
xSemaphoreGive(star_codes_sem);
|
||||
|
||||
const esp_timer_create_args_t timer_args = {
|
||||
.callback = &starcode_trigger_cb,
|
||||
|
||||
@ -2,9 +2,6 @@
|
||||
|
||||
extern uint32_t current_step;
|
||||
|
||||
/// The mutex for accessing `I2C_NUM_1` (wires I2C bus).
|
||||
SemaphoreHandle_t wires_i2c_mutex;
|
||||
|
||||
uint32_t total_strikes;
|
||||
uint32_t step_strikes[N_STEPS] = {0};
|
||||
uint32_t step_finish_times[N_STEPS] = {0};
|
||||
@ -44,10 +41,6 @@ void init_wires(void) {
|
||||
ESP_ERROR_CHECK(i2c_param_config(WIRES_I2C_NUM, &wires_conf));
|
||||
ESP_ERROR_CHECK(i2c_driver_install(WIRES_I2C_NUM, wires_conf.mode, 0, 0, 0));
|
||||
|
||||
// Create mutex for wires I2C bus
|
||||
wires_i2c_mutex = xSemaphoreCreateMutex();
|
||||
assert(wires_i2c_mutex != NULL);
|
||||
|
||||
gpio_config_t int_pin_conf = {};
|
||||
// delta_pin_conf.intr_type = GPIO_INTR_LOW_LEVEL;
|
||||
int_pin_conf.mode = GPIO_MODE_INPUT;
|
||||
@ -92,55 +85,45 @@ void clear_wires_pressed_released_cut(void) {
|
||||
|
||||
void strike(const char* reason) {
|
||||
ESP_LOGW("strike!", "%s", reason);
|
||||
lcd_print(3, 0, reason);
|
||||
lcd_print(0, 3, reason);
|
||||
time_penalty(STRIKE_TIME_PENALTY);
|
||||
if (current_step > 0 && current_step <= N_STEPS) {
|
||||
total_strikes += 1;
|
||||
step_strikes[current_step - 1] += 1;
|
||||
}
|
||||
uint8_t reg = 6;
|
||||
xSemaphoreTake(wires_i2c_mutex, portMAX_DELAY);
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_to_device(WIRES_I2C_NUM, WIRES_I2C_ADDR, ®, 1, (100 / portTICK_PERIOD_MS)));
|
||||
xSemaphoreGive(wires_i2c_mutex);
|
||||
}
|
||||
|
||||
void set_leds(uint8_t led_states) {
|
||||
buf[0] = 5; // register 5
|
||||
buf[1] = led_states;
|
||||
xSemaphoreTake(wires_i2c_mutex, portMAX_DELAY);
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_to_device(WIRES_I2C_NUM, WIRES_I2C_ADDR, buf, 2, (100 / portTICK_PERIOD_MS)));
|
||||
xSemaphoreGive(wires_i2c_mutex);
|
||||
}
|
||||
|
||||
static uint8_t receive_delta(void) {
|
||||
uint8_t reg = 1;
|
||||
buf[0] = 0;
|
||||
xSemaphoreTake(wires_i2c_mutex, portMAX_DELAY);
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(WIRES_I2C_NUM, WIRES_I2C_ADDR, ®, 1, buf, 1, (100 / portTICK_PERIOD_MS)));
|
||||
xSemaphoreGive(wires_i2c_mutex);
|
||||
return buf[0];
|
||||
}
|
||||
|
||||
static void receive_wires(void) {
|
||||
uint8_t reg = 2;
|
||||
buf[0] = 0;
|
||||
xSemaphoreTake(wires_i2c_mutex, portMAX_DELAY);
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(WIRES_I2C_NUM, WIRES_I2C_ADDR, ®, 1, buf, 1, (100 / portTICK_PERIOD_MS)));
|
||||
xSemaphoreGive(wires_i2c_mutex);
|
||||
uint8_t new_wires = buf[0];
|
||||
|
||||
|
||||
uint8_t just_cut = ~new_wires & wires_state;
|
||||
wires_cut |= just_cut;
|
||||
|
||||
|
||||
wires_state = new_wires;
|
||||
}
|
||||
|
||||
static void receive_button(void) {
|
||||
uint8_t reg = 3;
|
||||
buf[0] = 0;
|
||||
xSemaphoreTake(wires_i2c_mutex, portMAX_DELAY);
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_read_device(WIRES_I2C_NUM, WIRES_I2C_ADDR, ®, 1, buf, 1, (100 / portTICK_PERIOD_MS)));
|
||||
xSemaphoreGive(wires_i2c_mutex);
|
||||
bool new_button = buf[0] != 0;
|
||||
|
||||
bool just_pressed = new_button & !button_state;
|
||||
|
||||
@ -5,8 +5,6 @@
|
||||
#include <driver/i2c.h>
|
||||
#include <driver/gpio.h>
|
||||
#include <esp_log.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "drivers/char_lcd.h"
|
||||
#include "drivers/game_timer.h"
|
||||
#include "main.h"
|
||||
@ -18,9 +16,6 @@
|
||||
#define WIRES_I2C_NUM I2C_NUM_1
|
||||
#define WIRES_I2C_ADDR 125
|
||||
|
||||
/// The mutex for accessing `I2C_NUM_1` (wires I2C bus).
|
||||
extern SemaphoreHandle_t wires_i2c_mutex;
|
||||
|
||||
#define DELTA_BIT_WIRES 0
|
||||
#define DELTA_BIT_BUTTON 1
|
||||
|
||||
|
||||
148
main/main.cpp
148
main/main.cpp
@ -13,19 +13,102 @@
|
||||
#include "helper.h"
|
||||
|
||||
#include "steps/step0.h"
|
||||
#include "steps/step1.h"
|
||||
#include "steps/step2.h"
|
||||
#include "steps/step3.h"
|
||||
#include "steps/step4.h"
|
||||
#include "steps/step5.h"
|
||||
#include "steps/step6.h"
|
||||
#include "steps/p001_step1.h"
|
||||
#include "steps/p001_step2.h"
|
||||
#include "steps/p001_step3.h"
|
||||
#include "steps/p001_step4.h"
|
||||
#include "steps/p001_step5.h"
|
||||
#include "steps/p001_step6.h"
|
||||
#include "steps/p002_step1.h"
|
||||
#include "steps/p002_step2.h"
|
||||
#include "steps/p002_step3.h"
|
||||
#include "steps/p002_step4.h"
|
||||
#include "steps/p002_step5.h"
|
||||
#include "steps/p002_step6.h"
|
||||
|
||||
static const char *TAG = "main";
|
||||
uint32_t initial_game_time = 90*60*1000 + 1000;
|
||||
uint32_t skip_to_step = 0;
|
||||
uint32_t current_step = 0;
|
||||
uint32_t puzzle = 0;
|
||||
extern uint32_t total_strikes;
|
||||
|
||||
static void do_p001() {
|
||||
set_game_time(initial_game_time);
|
||||
start_game_timer();
|
||||
total_strikes = 0;
|
||||
clean_bomb();
|
||||
current_step = 1;
|
||||
if (skip_to_step <= 1) p001_step1();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 2;
|
||||
if (skip_to_step <= 2) p001_step2();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 3;
|
||||
if (skip_to_step <= 3) p001_step3();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 4;
|
||||
if (skip_to_step <= 4) p001_step4();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 5;
|
||||
if (skip_to_step <= 5) p001_step5();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 6;
|
||||
if (skip_to_step <= 6) p001_step6();
|
||||
start_game_timer();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
|
||||
stop_game_timer();
|
||||
ESP_LOGI(TAG, "Bomb has been diffused. Counter-Terrorists win.");
|
||||
play_clip_wav(MOUNT_POINT "/diffuse.wav", true, false, 3, 0);
|
||||
|
||||
display_game_results();
|
||||
}
|
||||
|
||||
static void do_p002() {
|
||||
set_game_time(initial_game_time);
|
||||
start_game_timer();
|
||||
total_strikes = 0;
|
||||
clean_bomb();
|
||||
current_step = 1;
|
||||
if (skip_to_step <= 1) p002_step1();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 2;
|
||||
if (skip_to_step <= 2) p002_step2();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 3;
|
||||
if (skip_to_step <= 3) p002_step3();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 4;
|
||||
if (skip_to_step <= 4) p002_step4();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 5;
|
||||
if (skip_to_step <= 5) p002_step5();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 6;
|
||||
if (skip_to_step <= 6) p002_step6();
|
||||
start_game_timer();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
|
||||
stop_game_timer();
|
||||
ESP_LOGI(TAG, "Bomb has been diffused. Counter-Terrorists win.");
|
||||
play_clip_wav(MOUNT_POINT "/diffuse.wav", true, false, 3, 0);
|
||||
|
||||
display_game_results();
|
||||
}
|
||||
|
||||
extern "C" void app_main(void) {
|
||||
printf("app_main\n");
|
||||
|
||||
@ -40,49 +123,20 @@ extern "C" void app_main(void) {
|
||||
lcd_do_splash();
|
||||
step0();
|
||||
|
||||
// set_recording_source(stdout, false);
|
||||
FILE* record_file = fopen(MOUNT_POINT "/record.txt", "w");
|
||||
if (record_file == nullptr) {
|
||||
ESP_LOGE("main", "failed to open record.txt");
|
||||
if (puzzle == 1) {
|
||||
do_p001();
|
||||
} else {
|
||||
do_p002();
|
||||
}
|
||||
set_recording_source(record_file, true);
|
||||
start_recording();
|
||||
|
||||
set_game_time(initial_game_time);
|
||||
start_game_timer();
|
||||
total_strikes = 0;
|
||||
clean_bomb();
|
||||
current_step = 1;
|
||||
if (skip_to_step <= 1) step1();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 2;
|
||||
if (skip_to_step <= 2) step2();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 3;
|
||||
if (skip_to_step <= 3) step3();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 4;
|
||||
if (skip_to_step <= 4) step4();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 5;
|
||||
if (skip_to_step <= 5) step5();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
current_step = 6;
|
||||
if (skip_to_step <= 6) step6();
|
||||
start_game_timer();
|
||||
step_finish_times[current_step-1] = get_game_time();
|
||||
clean_bomb();
|
||||
// set_recording_source(stdout, false);
|
||||
// FILE* record_file = fopen(MOUNT_POINT "/record.txt", "w");
|
||||
// if (record_file == nullptr) {
|
||||
// ESP_LOGE("main", "failed to open record.txt");
|
||||
// }
|
||||
// set_recording_source(record_file, true);
|
||||
// start_recording();
|
||||
|
||||
stop_game_timer();
|
||||
ESP_LOGI(TAG, "Bomb has been diffused. Counter-Terrorists win.");
|
||||
play_clip_wav(MOUNT_POINT "/diffuse.wav", true, false, 3, 0);
|
||||
|
||||
display_game_results();
|
||||
stop_recording();
|
||||
// stop_recording();
|
||||
|
||||
}
|
||||
|
||||
@ -1,12 +1,18 @@
|
||||
set(SOURCES
|
||||
"setup_wires.cpp"
|
||||
"step0.cpp"
|
||||
"step1.cpp"
|
||||
"step2.cpp"
|
||||
"step3.cpp"
|
||||
"step4.cpp"
|
||||
"step5.cpp"
|
||||
"step6.cpp"
|
||||
"p001_step1.cpp"
|
||||
"p001_step2.cpp"
|
||||
"p001_step3.cpp"
|
||||
"p001_step4.cpp"
|
||||
"p001_step5.cpp"
|
||||
"p001_step6.cpp"
|
||||
"p002_step1.cpp"
|
||||
"p002_step2.cpp"
|
||||
"p002_step3.cpp"
|
||||
"p002_step4.cpp"
|
||||
"p002_step5.cpp"
|
||||
"p002_step6.cpp"
|
||||
"wires_puzzle.cpp"
|
||||
)
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "step1.h"
|
||||
#include "p001_step1.h"
|
||||
|
||||
__attribute__((unused))
|
||||
static const char *TAG = "step1";
|
||||
@ -199,7 +199,7 @@ static int generate_part(void) {
|
||||
static void update_lcd_count(int times) {
|
||||
char buf[16] = {0};
|
||||
sprintf(buf, "%d/15", times);
|
||||
lcd_print(1, 14, buf);
|
||||
lcd_print(14, 1, buf);
|
||||
}
|
||||
|
||||
static bool play_part(uint32_t time) {
|
||||
@ -275,7 +275,7 @@ static bool play_part(uint32_t time) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void step1(void) {
|
||||
void p001_step1(void) {
|
||||
while (get_switch_flipped(nullptr));
|
||||
|
||||
init_step();
|
||||
10
main/steps/p001_step1.h
Normal file
10
main/steps/p001_step1.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef P001_STEP_1_H
|
||||
#define P001_STEP_1_H
|
||||
|
||||
#include <random>
|
||||
#include "../drivers/all.h"
|
||||
#include "../helper.h"
|
||||
|
||||
void p001_step1(void);
|
||||
|
||||
#endif /* P001_STEP_1_H */
|
||||
@ -1,4 +1,4 @@
|
||||
#include "step2.h"
|
||||
#include "p001_step2.h"
|
||||
|
||||
__attribute__((unused))
|
||||
static const char *TAG = "step2";
|
||||
@ -91,7 +91,7 @@ static void new_puzzle(void) {
|
||||
set_module_sseg_raw(display_map);
|
||||
}
|
||||
|
||||
void step2(void) {
|
||||
void p001_step2(void) {
|
||||
KeypadKey key;
|
||||
int solved_times = 0;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef STEP_2_H
|
||||
#define STEP_2_H
|
||||
#ifndef P001_STEP_2_H
|
||||
#define P001_STEP_2_H
|
||||
|
||||
#include "../drivers/all.h"
|
||||
#include "../helper.h"
|
||||
@ -7,6 +7,6 @@
|
||||
#include <random>
|
||||
#include <map>
|
||||
|
||||
void step2(void);
|
||||
void p001_step2(void);
|
||||
|
||||
#endif /* STEP_2_H */
|
||||
#endif /* P001_STEP_2_H */
|
||||
@ -1,4 +1,4 @@
|
||||
#include "step3.h"
|
||||
#include "p001_step3.h"
|
||||
|
||||
#define ONE_SECOND_TIME 90'000
|
||||
#define THREE_SECOND_TIME 90'000
|
||||
@ -72,7 +72,7 @@ static bool one_second();
|
||||
static bool three_second();
|
||||
static bool six_second();
|
||||
|
||||
void step3(void) {
|
||||
void p001_step3(void) {
|
||||
SemaphoreHandle_t continue_sem = xSemaphoreCreateBinary();
|
||||
if (continue_sem == nullptr) {
|
||||
ESP_LOGE(TAG, "could not create semaphore");
|
||||
10
main/steps/p001_step3.h
Normal file
10
main/steps/p001_step3.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef P001_STEP_3_H
|
||||
#define P001_STEP_3_H
|
||||
|
||||
#include <random>
|
||||
#include "../drivers/all.h"
|
||||
#include "../helper.h"
|
||||
|
||||
void p001_step3(void);
|
||||
|
||||
#endif /* P001_STEP_3_H */
|
||||
@ -1,4 +1,4 @@
|
||||
#include "step4.h"
|
||||
#include "p001_step4.h"
|
||||
|
||||
__attribute__((unused))
|
||||
static const char *TAG = "step4";
|
||||
@ -379,7 +379,7 @@ static void fail() {
|
||||
}
|
||||
}
|
||||
|
||||
void step4() {
|
||||
void p001_step4() {
|
||||
// TODO: extract to helper function
|
||||
SemaphoreHandle_t continue_sem = xSemaphoreCreateBinary();
|
||||
if (continue_sem == nullptr) {
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef STEP_4_H
|
||||
#define STEP_4_H
|
||||
#ifndef P001_STEP_4_H
|
||||
#define P001_STEP_4_H
|
||||
|
||||
#include <random>
|
||||
#include "../drivers/all.h"
|
||||
@ -9,6 +9,6 @@
|
||||
#define TETRIS_USE_FLASH_IMG
|
||||
#define TETRIS_USE_FLASH_BG_IMG
|
||||
|
||||
void step4(void);
|
||||
void p001_step4(void);
|
||||
|
||||
#endif /* STEP_4_H */
|
||||
#endif /* P001_STEP_4_H */
|
||||
@ -1,4 +1,4 @@
|
||||
#include "step5.h"
|
||||
#include "p001_step5.h"
|
||||
|
||||
#define TIME_CLEAR 30'000
|
||||
#define TIME_PLANK 40'000
|
||||
@ -178,7 +178,7 @@ bool submit_6(bool* buttons_cycling, bool button_turned_on, int led_off) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void step5(void) {
|
||||
void p001_step5(void) {
|
||||
SemaphoreHandle_t continue_sem = xSemaphoreCreateBinary();
|
||||
if (continue_sem == nullptr) {
|
||||
ESP_LOGE(TAG, "could not create semaphore");
|
||||
@ -729,7 +729,7 @@ void step5(void) {
|
||||
}
|
||||
|
||||
// display expression
|
||||
lcd_print(2, 1, display_expression.c_str());
|
||||
lcd_print(1, 2, display_expression.c_str());
|
||||
|
||||
// set LEDs
|
||||
const uint32_t COLORS[] = {
|
||||
@ -790,8 +790,8 @@ void step5(void) {
|
||||
|
||||
lcd_clear();
|
||||
lcd_print(1, 1, "What");
|
||||
lcd_print(2, 1, display_expression.c_str());
|
||||
lcd_print(3, 1, entered_string.c_str());
|
||||
lcd_print(1, 2, display_expression.c_str());
|
||||
lcd_print(1, 3, entered_string.c_str());
|
||||
}
|
||||
if (get_module_time() <= 0) {
|
||||
strike("Ran out of time!");
|
||||
@ -849,7 +849,7 @@ void step5(void) {
|
||||
|
||||
// ESP_LOGI(TAG, "color string: %s", color_string.c_str());
|
||||
|
||||
lcd_print(2, 1, color_string.c_str());
|
||||
lcd_print(1, 2, color_string.c_str());
|
||||
|
||||
std::string entered_string;
|
||||
|
||||
@ -880,8 +880,8 @@ void step5(void) {
|
||||
|
||||
lcd_clear();
|
||||
lcd_print(1, 1, "Plink");
|
||||
lcd_print(2, 1, color_string.c_str());
|
||||
lcd_print(3, 1, entered_string.c_str());
|
||||
lcd_print(1, 2, color_string.c_str());
|
||||
lcd_print(1, 3, entered_string.c_str());
|
||||
}
|
||||
if (get_module_time() <= 0) {
|
||||
strike("Ran out of time!");
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef STEP_5_H
|
||||
#define STEP_5_H
|
||||
#ifndef P001_STEP_5_H
|
||||
#define P001_STEP_5_H
|
||||
|
||||
#include "../drivers/all.h"
|
||||
#include "../helper.h"
|
||||
@ -11,6 +11,6 @@
|
||||
#include <cmath>
|
||||
#include <array>
|
||||
|
||||
void step5(void);
|
||||
void p001_step5(void);
|
||||
|
||||
#endif /* STEP_5_H */
|
||||
#endif /* P001_STEP_5_H */
|
||||
@ -1,11 +1,11 @@
|
||||
#include "step6.h"
|
||||
#include "p001_step6.h"
|
||||
|
||||
__attribute__((unused))
|
||||
static const char *TAG = "step6";
|
||||
|
||||
static uint8_t cut_wires = 0;
|
||||
|
||||
void step6(void) {
|
||||
void p001_step6(void) {
|
||||
get_cut_wires();
|
||||
clear_all_pressed_released();
|
||||
|
||||
10
main/steps/p001_step6.h
Normal file
10
main/steps/p001_step6.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef P001_STEP_6_H
|
||||
#define P001_STEP_6_H
|
||||
|
||||
#include "wires_puzzle.h"
|
||||
#include "../drivers/all.h"
|
||||
#include "../helper.h"
|
||||
|
||||
void p001_step6(void);
|
||||
|
||||
#endif /* P001_STEP_6_H */
|
||||
10
main/steps/p002_step1.cpp
Normal file
10
main/steps/p002_step1.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "p002_step1.h"
|
||||
|
||||
__attribute__((unused))
|
||||
static const char *TAG = "step1";
|
||||
|
||||
void p002_step1(void) {
|
||||
// TODO: implement step 1
|
||||
}
|
||||
|
||||
|
||||
8
main/steps/p002_step1.h
Normal file
8
main/steps/p002_step1.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef P002_STEP_1_H
|
||||
#define P002_STEP_1_H
|
||||
|
||||
#include "../drivers/all.h"
|
||||
|
||||
void p002_step1(void);
|
||||
|
||||
#endif /* P002_STEP_1_H */
|
||||
8
main/steps/p002_step2.cpp
Normal file
8
main/steps/p002_step2.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "p002_step2.h"
|
||||
|
||||
__attribute__((unused))
|
||||
static const char *TAG = "step2";
|
||||
|
||||
void p002_step2(void) {
|
||||
// TODO: implement step 2
|
||||
}
|
||||
8
main/steps/p002_step2.h
Normal file
8
main/steps/p002_step2.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef P002_STEP_2_H
|
||||
#define P002_STEP_2_H
|
||||
|
||||
#include "../drivers/all.h"
|
||||
|
||||
void p002_step2(void);
|
||||
|
||||
#endif /* P002_STEP_2_H */
|
||||
8
main/steps/p002_step3.cpp
Normal file
8
main/steps/p002_step3.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "p002_step3.h"
|
||||
|
||||
__attribute__((unused))
|
||||
static const char *TAG = "step3";
|
||||
|
||||
void p002_step3(void) {
|
||||
// TODO: implement step 3
|
||||
}
|
||||
8
main/steps/p002_step3.h
Normal file
8
main/steps/p002_step3.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef P002_STEP_3_H
|
||||
#define P002_STEP_3_H
|
||||
|
||||
#include "../drivers/all.h"
|
||||
|
||||
void p002_step3(void);
|
||||
|
||||
#endif /* P002_STEP_3_H */
|
||||
8
main/steps/p002_step4.cpp
Normal file
8
main/steps/p002_step4.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "p002_step4.h"
|
||||
|
||||
__attribute__((unused))
|
||||
static const char *TAG = "step4";
|
||||
|
||||
void p002_step4(void) {
|
||||
// TODO: implement step 4
|
||||
}
|
||||
8
main/steps/p002_step4.h
Normal file
8
main/steps/p002_step4.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef P002_STEP_4_H
|
||||
#define P002_STEP_4_H
|
||||
|
||||
#include "../drivers/all.h"
|
||||
|
||||
void p002_step4(void);
|
||||
|
||||
#endif /* P002_STEP_4_H */
|
||||
8
main/steps/p002_step5.cpp
Normal file
8
main/steps/p002_step5.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "p002_step5.h"
|
||||
|
||||
__attribute__((unused))
|
||||
static const char *TAG = "step5";
|
||||
|
||||
void p002_step5(void) {
|
||||
// TODO: implement step 5
|
||||
}
|
||||
8
main/steps/p002_step5.h
Normal file
8
main/steps/p002_step5.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef P002_STEP_5_H
|
||||
#define P002_STEP_5_H
|
||||
|
||||
#include "../drivers/all.h"
|
||||
|
||||
void p002_step5(void);
|
||||
|
||||
#endif /* P002_STEP_5_H */
|
||||
8
main/steps/p002_step6.cpp
Normal file
8
main/steps/p002_step6.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "p002_step6.h"
|
||||
|
||||
__attribute__((unused))
|
||||
static const char *TAG = "step6";
|
||||
|
||||
void p002_step6(void) {
|
||||
// TODO: implement step 6
|
||||
}
|
||||
8
main/steps/p002_step6.h
Normal file
8
main/steps/p002_step6.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef P002_STEP_6_H
|
||||
#define P002_STEP_6_H
|
||||
|
||||
#include "../drivers/all.h"
|
||||
|
||||
void p002_step6(void);
|
||||
|
||||
#endif /* P002_STEP_6_H */
|
||||
@ -11,7 +11,7 @@ void print_wires(WireColor* wires, int editing_idx) {
|
||||
lcd_print(1, 1, string_buf);
|
||||
|
||||
cut_to_string(cut, string_buf);
|
||||
lcd_print(2, 1, string_buf);
|
||||
lcd_print(1, 2, string_buf);
|
||||
|
||||
wires_state = get_wires();
|
||||
for (int i = 0; i < NUM_WIRES; i++) {
|
||||
@ -21,10 +21,9 @@ void print_wires(WireColor* wires, int editing_idx) {
|
||||
string_buf[i] = '!';
|
||||
}
|
||||
}
|
||||
lcd_print(3, 1, string_buf);
|
||||
lcd_print(1, 3, string_buf);
|
||||
|
||||
lcd_set_cursor_vis(true);
|
||||
lcd_set_cursor_resting_position(1, editing_idx+1);
|
||||
lcd_set_cursor_pos(editing_idx+1, 1);
|
||||
}
|
||||
|
||||
void setup_wires(void) {
|
||||
|
||||
@ -5,6 +5,7 @@ static const char* TAG = "step0";
|
||||
|
||||
extern uint32_t initial_game_time;
|
||||
extern uint32_t skip_to_step;
|
||||
extern uint32_t puzzle;
|
||||
|
||||
static void set_game_time();
|
||||
static void skip_to_step1() { skip_to_step = 1; }
|
||||
@ -13,12 +14,12 @@ static void skip_to_step3() { skip_to_step = 3; }
|
||||
static void skip_to_step4() { skip_to_step = 4; }
|
||||
static void skip_to_step5() { skip_to_step = 5; }
|
||||
static void skip_to_step6() { skip_to_step = 6; }
|
||||
static void try_step1() { clean_bomb(); step1(); }
|
||||
static void try_step2() { clean_bomb(); step2(); }
|
||||
static void try_step3() { clean_bomb(); step3(); }
|
||||
static void try_step4() { clean_bomb(); step4(); }
|
||||
static void try_step5() { clean_bomb(); step5(); }
|
||||
static void try_step6() { clean_bomb(); step6(); }
|
||||
static void try_step1() { clean_bomb(); p001_step1(); }
|
||||
static void try_step2() { clean_bomb(); p001_step2(); }
|
||||
static void try_step3() { clean_bomb(); p001_step3(); }
|
||||
static void try_step4() { clean_bomb(); p001_step4(); }
|
||||
static void try_step5() { clean_bomb(); p001_step5(); }
|
||||
static void try_step6() { clean_bomb(); p001_step6(); }
|
||||
static void issue_strike() { strike("Strike Issued"); }
|
||||
static void flashbang();
|
||||
static void debug_switches();
|
||||
@ -45,6 +46,13 @@ static void replay_last() {
|
||||
start_playback();
|
||||
}
|
||||
|
||||
static void do_p001() {
|
||||
puzzle = 1;
|
||||
}
|
||||
|
||||
static void do_p002() {
|
||||
puzzle = 2;
|
||||
}
|
||||
|
||||
void step0() {
|
||||
led_set(IndicatorLED::LED_SPEAKER, LEDColor::LED_COLOR_BLUE);
|
||||
@ -59,17 +67,17 @@ void step0() {
|
||||
StarCodeEntry star_codes[] = {
|
||||
{
|
||||
.code = "9819",
|
||||
.display_text = "Diffusal Initiated",
|
||||
.display_text = "Start P001",
|
||||
.delay_us = 2'000'000,
|
||||
.callback = nullptr,
|
||||
.callback = do_p001,
|
||||
.triggered_sem = continue_sem,
|
||||
},
|
||||
{
|
||||
.code = "59860",
|
||||
.display_text = "Hardware Config",
|
||||
.code = "3141",
|
||||
.display_text = "Start P002",
|
||||
.delay_us = 2'000'000,
|
||||
.callback = hardware_config,
|
||||
.triggered_sem = nullptr,
|
||||
.callback = do_p002,
|
||||
.triggered_sem = continue_sem,
|
||||
},
|
||||
{
|
||||
.code = "59861",
|
||||
@ -221,8 +229,7 @@ static void _update_display(uint8_t* digits, uint8_t cursor_pos) {
|
||||
lcd_print(1, 1, str_buf);
|
||||
cursor_pos = MAX(0, MIN(4, cursor_pos));
|
||||
int mapped_cursor_pos = CURSOR_POS_MAP[cursor_pos];
|
||||
|
||||
lcd_set_cursor_resting_position(1, mapped_cursor_pos);
|
||||
lcd_set_cursor_pos(mapped_cursor_pos, 1);
|
||||
}
|
||||
|
||||
static void set_game_time() {
|
||||
@ -343,32 +350,32 @@ static void debug_switches() {
|
||||
while (1) {
|
||||
if (get_button_pressed(&button)) {
|
||||
sprintf(buf, "Button Pressed: %d ", button);
|
||||
lcd_print(3, 0, buf);
|
||||
lcd_print(0, 3, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
if (get_button_released(&button)) {
|
||||
sprintf(buf, "Button Released: %d", button);
|
||||
lcd_print(3, 0, buf);
|
||||
lcd_print(0, 3, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
if (get_switch_flipped_down(&switch_)) {
|
||||
sprintf(buf, "Switch Down: %d ", switch_);
|
||||
lcd_print(3, 0, buf);
|
||||
lcd_print(0, 3, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
if (get_switch_flipped_up(&switch_)) {
|
||||
sprintf(buf, "Switch Up: %d ", switch_);
|
||||
lcd_print(3, 0, buf);
|
||||
lcd_print(0, 3, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
if (get_switch_touch_pressed(&switch_)) {
|
||||
sprintf(buf, "Switch Touch: %d ", switch_);
|
||||
lcd_print(3, 0, buf);
|
||||
lcd_print(0, 3, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
if (get_switch_touch_released(&switch_)) {
|
||||
sprintf(buf, "Switch Un-touch: %d", switch_);
|
||||
lcd_print(3, 0, buf);
|
||||
lcd_print(0, 3, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
|
||||
@ -377,7 +384,7 @@ static void debug_switches() {
|
||||
switch_touch_state = new_switch_touch_state;
|
||||
print_4bin_rev(bin_buf, switch_touch_state);
|
||||
sprintf(buf, "t: %s", bin_buf);
|
||||
lcd_print(0, 1, buf);
|
||||
lcd_print(1, 0, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
|
||||
@ -395,7 +402,7 @@ static void debug_switches() {
|
||||
button_state = new_button_state;
|
||||
print_4bin_rev(bin_buf, button_state);
|
||||
sprintf(buf, "b: %s", bin_buf);
|
||||
lcd_print(2, 1, buf);
|
||||
lcd_print(1, 2, buf);
|
||||
ESP_LOGI(TAG, "%s", buf);
|
||||
}
|
||||
|
||||
|
||||
@ -4,12 +4,12 @@
|
||||
#include "../drivers/all.h"
|
||||
|
||||
#include "setup_wires.h"
|
||||
#include "step1.h"
|
||||
#include "step2.h"
|
||||
#include "step3.h"
|
||||
#include "step4.h"
|
||||
#include "step5.h"
|
||||
#include "step6.h"
|
||||
#include "p001_step1.h"
|
||||
#include "p001_step2.h"
|
||||
#include "p001_step3.h"
|
||||
#include "p001_step4.h"
|
||||
#include "p001_step5.h"
|
||||
#include "p001_step6.h"
|
||||
|
||||
/// Wait for "*9819"
|
||||
void step0(void);
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
#ifndef STEP_1_H
|
||||
#define STEP_1_H
|
||||
|
||||
#include <random>
|
||||
#include "../drivers/all.h"
|
||||
#include "../helper.h"
|
||||
|
||||
void step1(void);
|
||||
|
||||
#endif /* STEP_1_H */
|
||||
@ -1,10 +0,0 @@
|
||||
#ifndef STEP_3_H
|
||||
#define STEP_3_H
|
||||
|
||||
#include <random>
|
||||
#include "../drivers/all.h"
|
||||
#include "../helper.h"
|
||||
|
||||
void step3(void);
|
||||
|
||||
#endif /* STEP_3_H */
|
||||
@ -1,10 +0,0 @@
|
||||
#ifndef STEP_6_H
|
||||
#define STEP_6_H
|
||||
|
||||
#include "wires_puzzle.h"
|
||||
#include "../drivers/all.h"
|
||||
#include "../helper.h"
|
||||
|
||||
void step6(void);
|
||||
|
||||
#endif /* STEP_6_H */
|
||||
105
sdkconfig
105
sdkconfig
@ -1,6 +1,6 @@
|
||||
#
|
||||
# Automatically generated file. DO NOT EDIT.
|
||||
# Espressif IoT Development Framework (ESP-IDF) 5.3.2 Project Configuration
|
||||
# Espressif IoT Development Framework (ESP-IDF) 5.3.5 Project Configuration
|
||||
#
|
||||
CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000
|
||||
CONFIG_SOC_MPU_REGIONS_MAX_NUM=8
|
||||
@ -11,6 +11,7 @@ CONFIG_SOC_PHY_SUPPORTED=y
|
||||
CONFIG_SOC_WIFI_SUPPORTED=y
|
||||
CONFIG_SOC_TWAI_SUPPORTED=y
|
||||
CONFIG_SOC_GDMA_SUPPORTED=y
|
||||
CONFIG_SOC_UHCI_SUPPORTED=y
|
||||
CONFIG_SOC_AHB_GDMA_SUPPORTED=y
|
||||
CONFIG_SOC_GPTIMER_SUPPORTED=y
|
||||
CONFIG_SOC_LCDCAM_SUPPORTED=y
|
||||
@ -64,6 +65,7 @@ CONFIG_SOC_LIGHT_SLEEP_SUPPORTED=y
|
||||
CONFIG_SOC_DEEP_SLEEP_SUPPORTED=y
|
||||
CONFIG_SOC_LP_PERIPH_SHARE_INTERRUPT=y
|
||||
CONFIG_SOC_PM_SUPPORTED=y
|
||||
CONFIG_SOC_SIMD_INSTRUCTION_SUPPORTED=y
|
||||
CONFIG_SOC_XTAL_SUPPORT_40M=y
|
||||
CONFIG_SOC_APPCPU_HAS_CLOCK_GATING_BUG=y
|
||||
CONFIG_SOC_ADC_RTC_CTRL_SUPPORTED=y
|
||||
@ -100,7 +102,8 @@ CONFIG_SOC_CPU_HAS_FPU=y
|
||||
CONFIG_SOC_HP_CPU_HAS_MULTIPLE_CORES=y
|
||||
CONFIG_SOC_CPU_BREAKPOINTS_NUM=2
|
||||
CONFIG_SOC_CPU_WATCHPOINTS_NUM=2
|
||||
CONFIG_SOC_CPU_WATCHPOINT_MAX_REGION_SIZE=64
|
||||
CONFIG_SOC_CPU_WATCHPOINT_MAX_REGION_SIZE=0x40
|
||||
CONFIG_SOC_SIMD_PREFERRED_DATA_ALIGNMENT=16
|
||||
CONFIG_SOC_DS_SIGNATURE_MAX_BIT_LEN=4096
|
||||
CONFIG_SOC_DS_KEY_PARAM_MD_IV_LENGTH=16
|
||||
CONFIG_SOC_DS_KEY_CHECK_MAX_WAIT_US=1100
|
||||
@ -176,7 +179,7 @@ CONFIG_SOC_RMT_CHANNELS_PER_GROUP=8
|
||||
CONFIG_SOC_RMT_MEM_WORDS_PER_CHANNEL=48
|
||||
CONFIG_SOC_RMT_SUPPORT_RX_PINGPONG=y
|
||||
CONFIG_SOC_RMT_SUPPORT_RX_DEMODULATION=y
|
||||
CONFIG_SOC_RMT_SUPPORT_TX_ASYNC_STOP=y
|
||||
CONFIG_SOC_RMT_SUPPORT_ASYNC_STOP=y
|
||||
CONFIG_SOC_RMT_SUPPORT_TX_LOOP_COUNT=y
|
||||
CONFIG_SOC_RMT_SUPPORT_TX_LOOP_AUTO_STOP=y
|
||||
CONFIG_SOC_RMT_SUPPORT_TX_SYNCHRO=y
|
||||
@ -203,7 +206,8 @@ CONFIG_SOC_RTCIO_PIN_COUNT=22
|
||||
CONFIG_SOC_RTCIO_INPUT_OUTPUT_SUPPORTED=y
|
||||
CONFIG_SOC_RTCIO_HOLD_SUPPORTED=y
|
||||
CONFIG_SOC_RTCIO_WAKE_SUPPORTED=y
|
||||
CONFIG_SOC_SDM_GROUPS=y
|
||||
CONFIG_SOC_LP_IO_CLOCK_IS_INDEPENDENT=y
|
||||
CONFIG_SOC_SDM_GROUPS=1
|
||||
CONFIG_SOC_SDM_CHANNELS_PER_GROUP=8
|
||||
CONFIG_SOC_SDM_CLK_SUPPORT_APB=y
|
||||
CONFIG_SOC_SPI_PERIPH_NUM=3
|
||||
@ -243,6 +247,8 @@ CONFIG_SOC_TIMER_GROUP_COUNTER_BIT_WIDTH=54
|
||||
CONFIG_SOC_TIMER_GROUP_SUPPORT_XTAL=y
|
||||
CONFIG_SOC_TIMER_GROUP_SUPPORT_APB=y
|
||||
CONFIG_SOC_TIMER_GROUP_TOTAL_TIMERS=4
|
||||
CONFIG_SOC_LP_TIMER_BIT_WIDTH_LO=32
|
||||
CONFIG_SOC_LP_TIMER_BIT_WIDTH_HI=16
|
||||
CONFIG_SOC_TOUCH_SENSOR_VERSION=2
|
||||
CONFIG_SOC_TOUCH_SENSOR_NUM=15
|
||||
CONFIG_SOC_TOUCH_SUPPORT_SLEEP_WAKEUP=y
|
||||
@ -265,6 +271,7 @@ CONFIG_SOC_UART_SUPPORT_WAKEUP_INT=y
|
||||
CONFIG_SOC_UART_SUPPORT_APB_CLK=y
|
||||
CONFIG_SOC_UART_SUPPORT_RTC_CLK=y
|
||||
CONFIG_SOC_UART_SUPPORT_XTAL_CLK=y
|
||||
CONFIG_SOC_UHCI_NUM=1
|
||||
CONFIG_SOC_USB_OTG_PERIPH_NUM=1
|
||||
CONFIG_SOC_SHA_DMA_MAX_BUFFER_SIZE=3968
|
||||
CONFIG_SOC_SHA_SUPPORT_DMA=y
|
||||
@ -350,6 +357,7 @@ CONFIG_SOC_WIFI_HW_TSF=y
|
||||
CONFIG_SOC_WIFI_FTM_SUPPORT=y
|
||||
CONFIG_SOC_WIFI_GCMP_SUPPORT=y
|
||||
CONFIG_SOC_WIFI_WAPI_SUPPORT=y
|
||||
CONFIG_SOC_WIFI_TXOP_SUPPORT=y
|
||||
CONFIG_SOC_WIFI_CSI_SUPPORT=y
|
||||
CONFIG_SOC_WIFI_MESH_SUPPORT=y
|
||||
CONFIG_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW=y
|
||||
@ -593,7 +601,21 @@ CONFIG_APPTRACE_LOCK_ENABLE=y
|
||||
# Bluetooth
|
||||
#
|
||||
# CONFIG_BT_ENABLED is not set
|
||||
CONFIG_BT_ALARM_MAX_NUM=50
|
||||
|
||||
#
|
||||
# Common Options
|
||||
#
|
||||
|
||||
#
|
||||
# BLE Log
|
||||
#
|
||||
# CONFIG_BLE_LOG_ENABLED is not set
|
||||
# end of BLE Log
|
||||
|
||||
# CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED is not set
|
||||
# CONFIG_BT_BLE_LOG_UHCI_OUT_ENABLED is not set
|
||||
# CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED is not set
|
||||
# end of Common Options
|
||||
# end of Bluetooth
|
||||
|
||||
#
|
||||
@ -617,6 +639,7 @@ CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM=y
|
||||
# Legacy ADC Driver Configuration
|
||||
#
|
||||
# CONFIG_ADC_SUPPRESS_DEPRECATE_WARN is not set
|
||||
# CONFIG_ADC_SKIP_LEGACY_CONFLICT_CHECK is not set
|
||||
|
||||
#
|
||||
# Legacy ADC Calibration Configuration
|
||||
@ -629,42 +652,55 @@ CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM=y
|
||||
# Legacy MCPWM Driver Configurations
|
||||
#
|
||||
# CONFIG_MCPWM_SUPPRESS_DEPRECATE_WARN is not set
|
||||
# CONFIG_MCPWM_SKIP_LEGACY_CONFLICT_CHECK is not set
|
||||
# end of Legacy MCPWM Driver Configurations
|
||||
|
||||
#
|
||||
# Legacy Timer Group Driver Configurations
|
||||
#
|
||||
# CONFIG_GPTIMER_SUPPRESS_DEPRECATE_WARN is not set
|
||||
# CONFIG_GPTIMER_SKIP_LEGACY_CONFLICT_CHECK is not set
|
||||
# end of Legacy Timer Group Driver Configurations
|
||||
|
||||
#
|
||||
# Legacy RMT Driver Configurations
|
||||
#
|
||||
# CONFIG_RMT_SUPPRESS_DEPRECATE_WARN is not set
|
||||
# CONFIG_RMT_SKIP_LEGACY_CONFLICT_CHECK is not set
|
||||
# end of Legacy RMT Driver Configurations
|
||||
|
||||
#
|
||||
# Legacy I2S Driver Configurations
|
||||
#
|
||||
# CONFIG_I2S_SUPPRESS_DEPRECATE_WARN is not set
|
||||
# CONFIG_I2S_SKIP_LEGACY_CONFLICT_CHECK is not set
|
||||
# end of Legacy I2S Driver Configurations
|
||||
|
||||
#
|
||||
# Legacy I2C Driver Configurations
|
||||
#
|
||||
# CONFIG_I2C_SKIP_LEGACY_CONFLICT_CHECK is not set
|
||||
# end of Legacy I2C Driver Configurations
|
||||
|
||||
#
|
||||
# Legacy PCNT Driver Configurations
|
||||
#
|
||||
# CONFIG_PCNT_SUPPRESS_DEPRECATE_WARN is not set
|
||||
# CONFIG_PCNT_SKIP_LEGACY_CONFLICT_CHECK is not set
|
||||
# end of Legacy PCNT Driver Configurations
|
||||
|
||||
#
|
||||
# Legacy SDM Driver Configurations
|
||||
#
|
||||
# CONFIG_SDM_SUPPRESS_DEPRECATE_WARN is not set
|
||||
# CONFIG_SDM_SKIP_LEGACY_CONFLICT_CHECK is not set
|
||||
# end of Legacy SDM Driver Configurations
|
||||
|
||||
#
|
||||
# Legacy Temperature Sensor Driver Configurations
|
||||
#
|
||||
# CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN is not set
|
||||
# CONFIG_TEMP_SENSOR_SKIP_LEGACY_CONFLICT_CHECK is not set
|
||||
# end of Legacy Temperature Sensor Driver Configurations
|
||||
# end of Driver Configurations
|
||||
|
||||
@ -687,6 +723,7 @@ CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y
|
||||
# CONFIG_ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL is not set
|
||||
# CONFIG_ESP_TLS_PSK_VERIFICATION is not set
|
||||
# CONFIG_ESP_TLS_INSECURE is not set
|
||||
CONFIG_ESP_TLS_DYN_BUF_STRATEGY_SUPPORTED=y
|
||||
# end of ESP-TLS
|
||||
|
||||
#
|
||||
@ -724,6 +761,7 @@ CONFIG_ESP_ERR_TO_NAME_LOOKUP=y
|
||||
CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y
|
||||
# CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM is not set
|
||||
# CONFIG_GPTIMER_ISR_IRAM_SAFE is not set
|
||||
CONFIG_GPTIMER_OBJ_CACHE_SAFE=y
|
||||
# CONFIG_GPTIMER_ENABLE_DEBUG_LOG is not set
|
||||
# end of ESP-Driver:GPTimer Configurations
|
||||
|
||||
@ -807,6 +845,14 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y
|
||||
# CONFIG_UART_ISR_IN_IRAM is not set
|
||||
# end of ESP-Driver:UART Configurations
|
||||
|
||||
#
|
||||
# ESP-Driver:UHCI Configurations
|
||||
#
|
||||
# CONFIG_UHCI_ISR_HANDLER_IN_IRAM is not set
|
||||
# CONFIG_UHCI_ISR_CACHE_SAFE is not set
|
||||
# CONFIG_UHCI_ENABLE_DEBUG_LOG is not set
|
||||
# end of ESP-Driver:UHCI Configurations
|
||||
|
||||
#
|
||||
# ESP-Driver:USB Serial/JTAG Configuration
|
||||
#
|
||||
@ -842,6 +888,13 @@ CONFIG_ESP_GDBSTUB_SUPPORT_TASKS=y
|
||||
CONFIG_ESP_GDBSTUB_MAX_TASKS=32
|
||||
# end of GDB Stub
|
||||
|
||||
#
|
||||
# ESP HID
|
||||
#
|
||||
CONFIG_ESPHID_TASK_SIZE_BT=2048
|
||||
CONFIG_ESPHID_TASK_SIZE_BLE=4096
|
||||
# end of ESP HID
|
||||
|
||||
#
|
||||
# ESP HTTP client
|
||||
#
|
||||
@ -1015,7 +1068,11 @@ CONFIG_ESP_PHY_RF_CAL_PARTIAL=y
|
||||
# CONFIG_ESP_PHY_RF_CAL_NONE is not set
|
||||
# CONFIG_ESP_PHY_RF_CAL_FULL is not set
|
||||
CONFIG_ESP_PHY_CALIBRATION_MODE=0
|
||||
CONFIG_ESP_PHY_PLL_TRACK_PERIOD_MS=1000
|
||||
# CONFIG_ESP_PHY_PLL_TRACK_DEBUG is not set
|
||||
# CONFIG_ESP_PHY_RECORD_USED_TIME is not set
|
||||
CONFIG_ESP_PHY_IRAM_OPT=y
|
||||
# CONFIG_ESP_PHY_DEBUG is not set
|
||||
# end of PHY
|
||||
|
||||
#
|
||||
@ -1052,6 +1109,7 @@ CONFIG_SPIRAM_CS_IO=26
|
||||
CONFIG_SPIRAM_SPEED_40M=y
|
||||
CONFIG_SPIRAM_SPEED=40
|
||||
CONFIG_SPIRAM_BOOT_INIT=y
|
||||
CONFIG_SPIRAM_PRE_CONFIGURE_MEMORY_PROTECTION=y
|
||||
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
|
||||
# CONFIG_SPIRAM_USE_MEMMAP is not set
|
||||
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
|
||||
@ -1216,9 +1274,9 @@ CONFIG_ESP_WIFI_ENABLED=y
|
||||
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=10
|
||||
CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=32
|
||||
CONFIG_ESP_WIFI_STATIC_TX_BUFFER=y
|
||||
# CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER is not set
|
||||
CONFIG_ESP_WIFI_TX_BUFFER_TYPE=0
|
||||
CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM=16
|
||||
CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM=32
|
||||
CONFIG_ESP_WIFI_STATIC_RX_MGMT_BUFFER=y
|
||||
# CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER is not set
|
||||
CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF=0
|
||||
@ -1228,7 +1286,6 @@ CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y
|
||||
CONFIG_ESP_WIFI_TX_BA_WIN=6
|
||||
CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y
|
||||
CONFIG_ESP_WIFI_RX_BA_WIN=6
|
||||
# CONFIG_ESP_WIFI_AMSDU_TX_ENABLED is not set
|
||||
CONFIG_ESP_WIFI_NVS_ENABLED=y
|
||||
CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0=y
|
||||
# CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_1 is not set
|
||||
@ -1270,7 +1327,6 @@ CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y
|
||||
# end of WPS Configuration Options
|
||||
|
||||
# CONFIG_ESP_WIFI_DEBUG_PRINT is not set
|
||||
# CONFIG_ESP_WIFI_TESTING_OPTIONS is not set
|
||||
CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=y
|
||||
# CONFIG_ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER is not set
|
||||
# end of Wi-Fi
|
||||
@ -1400,7 +1456,6 @@ CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2
|
||||
CONFIG_HAL_WDT_USE_ROM_IMPL=y
|
||||
CONFIG_HAL_SPI_MASTER_FUNC_IN_IRAM=y
|
||||
CONFIG_HAL_SPI_SLAVE_FUNC_IN_IRAM=y
|
||||
# CONFIG_HAL_ECDSA_GEN_SIG_CM is not set
|
||||
# end of Hardware Abstraction Layer (HAL) and Low Level (LL)
|
||||
|
||||
#
|
||||
@ -1489,6 +1544,7 @@ CONFIG_LWIP_DHCPS=y
|
||||
CONFIG_LWIP_DHCPS_LEASE_UNIT=60
|
||||
CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8
|
||||
CONFIG_LWIP_DHCPS_STATIC_ENTRIES=y
|
||||
CONFIG_LWIP_DHCPS_ADD_DNS=y
|
||||
# end of DHCP server
|
||||
|
||||
# CONFIG_LWIP_AUTOIP is not set
|
||||
@ -1640,6 +1696,7 @@ CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096
|
||||
# CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK is not set
|
||||
# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set
|
||||
CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y
|
||||
# CONFIG_MBEDTLS_SSL_KEYING_MATERIAL_EXPORT is not set
|
||||
CONFIG_MBEDTLS_PKCS7_C=y
|
||||
# end of mbedTLS v3.x related
|
||||
|
||||
@ -1673,6 +1730,7 @@ CONFIG_MBEDTLS_HAVE_TIME=y
|
||||
# CONFIG_MBEDTLS_PLATFORM_TIME_ALT is not set
|
||||
# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set
|
||||
CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y
|
||||
CONFIG_MBEDTLS_SHA1_C=y
|
||||
CONFIG_MBEDTLS_SHA512_C=y
|
||||
# CONFIG_MBEDTLS_SHA3_C is not set
|
||||
CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y
|
||||
@ -1752,6 +1810,7 @@ CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y
|
||||
# CONFIG_MBEDTLS_THREADING_C is not set
|
||||
CONFIG_MBEDTLS_ERROR_STRINGS=y
|
||||
CONFIG_MBEDTLS_FS_IO=y
|
||||
# CONFIG_MBEDTLS_ALLOW_WEAK_CERTIFICATE_VERIFICATION is not set
|
||||
# end of mbedTLS
|
||||
|
||||
#
|
||||
@ -1802,25 +1861,12 @@ CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND=y
|
||||
# CONFIG_OPENTHREAD_ENABLED is not set
|
||||
|
||||
#
|
||||
# Thread Operational Dataset
|
||||
# OpenThread Spinel
|
||||
#
|
||||
CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread-ESP"
|
||||
CONFIG_OPENTHREAD_MESH_LOCAL_PREFIX="fd00:db8:a0:0::/64"
|
||||
CONFIG_OPENTHREAD_NETWORK_CHANNEL=15
|
||||
CONFIG_OPENTHREAD_NETWORK_PANID=0x1234
|
||||
CONFIG_OPENTHREAD_NETWORK_EXTPANID="dead00beef00cafe"
|
||||
CONFIG_OPENTHREAD_NETWORK_MASTERKEY="00112233445566778899aabbccddeeff"
|
||||
CONFIG_OPENTHREAD_NETWORK_PSKC="104810e2315100afd6bc9215a6bfac53"
|
||||
# end of Thread Operational Dataset
|
||||
|
||||
CONFIG_OPENTHREAD_XTAL_ACCURACY=130
|
||||
# CONFIG_OPENTHREAD_SPINEL_ONLY is not set
|
||||
CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE=y
|
||||
# end of OpenThread Spinel
|
||||
|
||||
#
|
||||
# Thread Address Query Config
|
||||
#
|
||||
# end of Thread Address Query Config
|
||||
# CONFIG_OPENTHREAD_DEBUG is not set
|
||||
# end of OpenThread
|
||||
|
||||
#
|
||||
@ -1829,6 +1875,7 @@ CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE=y
|
||||
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0=y
|
||||
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=y
|
||||
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2=y
|
||||
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_PATCH_VERSION=y
|
||||
# end of Protocomm
|
||||
|
||||
#
|
||||
@ -1880,6 +1927,7 @@ CONFIG_SPI_FLASH_SUSPEND_QVL_SUPPORTED=y
|
||||
# CONFIG_SPI_FLASH_AUTO_SUSPEND is not set
|
||||
CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US=50
|
||||
# CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND is not set
|
||||
# CONFIG_SPI_FLASH_FORCE_ENABLE_C6_H2_SUSPEND is not set
|
||||
# end of Optional and Experimental Features (READ DOCS FIRST)
|
||||
# end of Main Flash configuration
|
||||
|
||||
@ -2459,7 +2507,6 @@ CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y
|
||||
CONFIG_ESP32S3_DEBUG_OCDAWARE=y
|
||||
CONFIG_BROWNOUT_DET=y
|
||||
CONFIG_ESP32S3_BROWNOUT_DET=y
|
||||
CONFIG_ESP32S3_BROWNOUT_DET=y
|
||||
CONFIG_BROWNOUT_DET_LVL_SEL_7=y
|
||||
CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_7=y
|
||||
# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set
|
||||
@ -2482,17 +2529,14 @@ CONFIG_ESP32_WIFI_ENABLED=y
|
||||
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10
|
||||
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32
|
||||
CONFIG_ESP32_WIFI_STATIC_TX_BUFFER=y
|
||||
# CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER is not set
|
||||
CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=0
|
||||
CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM=16
|
||||
CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM=32
|
||||
# CONFIG_ESP32_WIFI_CSI_ENABLED is not set
|
||||
CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y
|
||||
CONFIG_ESP32_WIFI_TX_BA_WIN=6
|
||||
CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y
|
||||
CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y
|
||||
CONFIG_ESP32_WIFI_RX_BA_WIN=6
|
||||
CONFIG_ESP32_WIFI_RX_BA_WIN=6
|
||||
# CONFIG_ESP32_WIFI_AMSDU_TX_ENABLED is not set
|
||||
CONFIG_ESP32_WIFI_NVS_ENABLED=y
|
||||
CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y
|
||||
# CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set
|
||||
@ -2513,7 +2557,6 @@ CONFIG_WPA_MBEDTLS_TLS_CLIENT=y
|
||||
# CONFIG_WPA_WPS_SOFTAP_REGISTRAR is not set
|
||||
# CONFIG_WPA_WPS_STRICT is not set
|
||||
# CONFIG_WPA_DEBUG_PRINT is not set
|
||||
# CONFIG_WPA_TESTING_OPTIONS is not set
|
||||
# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set
|
||||
# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set
|
||||
CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y
|
||||
|
||||
Loading…
Reference in New Issue
Block a user