Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae1766b3b0 | ||
|
|
dc0efa74eb | ||
|
|
7cdddb2c83 | ||
|
|
51001d6bc4 | ||
|
|
d0d1a0bb0e |
@@ -4,9 +4,7 @@ set(SOURCES
|
|||||||
"TM1640/TM1640.cpp"
|
"TM1640/TM1640.cpp"
|
||||||
"SparkFunBQ27441/SparkFunBQ27441.cpp"
|
"SparkFunBQ27441/SparkFunBQ27441.cpp"
|
||||||
"esp_lcd_ili9488/esp_lcd_ili9488.c"
|
"esp_lcd_ili9488/esp_lcd_ili9488.c"
|
||||||
# "bottom_half.cpp"
|
"bottom_half.cpp"
|
||||||
"event_based_bottom_half.cpp"
|
|
||||||
"inputs.cpp"
|
|
||||||
"char_lcd.cpp"
|
"char_lcd.cpp"
|
||||||
"game_timer.cpp"
|
"game_timer.cpp"
|
||||||
"i2c_lcd_pcf8574.c"
|
"i2c_lcd_pcf8574.c"
|
||||||
@@ -15,7 +13,6 @@ set(SOURCES
|
|||||||
"sd.cpp"
|
"sd.cpp"
|
||||||
"speaker.cpp"
|
"speaker.cpp"
|
||||||
"sseg.cpp"
|
"sseg.cpp"
|
||||||
"state_tracking.cpp"
|
|
||||||
"tft.cpp"
|
"tft.cpp"
|
||||||
"wires.cpp"
|
"wires.cpp"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ static void init_i2c() {
|
|||||||
|
|
||||||
i2c_config_t conf = {
|
i2c_config_t conf = {
|
||||||
.mode = I2C_MODE_MASTER,
|
.mode = I2C_MODE_MASTER,
|
||||||
.sda_io_num = PIN_I2C_SDA,
|
.sda_io_num = GPIO_NUM_5,
|
||||||
.scl_io_num = PIN_I2C_SCL,
|
.scl_io_num = GPIO_NUM_6,
|
||||||
.sda_pullup_en = GPIO_PULLUP_DISABLE,
|
.sda_pullup_en = GPIO_PULLUP_DISABLE,
|
||||||
.scl_pullup_en = GPIO_PULLUP_DISABLE,
|
.scl_pullup_en = GPIO_PULLUP_DISABLE,
|
||||||
// .sda_pullup_en = GPIO_PULLUP_ENABLE,
|
// .sda_pullup_en = GPIO_PULLUP_ENABLE,
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
#ifndef ALL_H
|
#ifndef ALL_H
|
||||||
#define ALL_H
|
#define ALL_H
|
||||||
|
|
||||||
#define PIN_I2C_SDA GPIO_NUM_7
|
|
||||||
#define PIN_I2C_SCL GPIO_NUM_15
|
|
||||||
|
|
||||||
#include "char_lcd.h"
|
#include "char_lcd.h"
|
||||||
#include "bottom_half.h"
|
#include "bottom_half.h"
|
||||||
#include "sd.h"
|
#include "sd.h"
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "bottom_half.h"
|
#include "bottom_half.h"
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
#include "state_tracking.h"
|
|
||||||
|
|
||||||
static const char *TAG = "bottom_half";
|
static const char *TAG = "bottom_half";
|
||||||
|
|
||||||
@@ -30,11 +29,6 @@ static void receive_keypad();
|
|||||||
static void receive_button_switch();
|
static void receive_button_switch();
|
||||||
static void receive_touch();
|
static void receive_touch();
|
||||||
|
|
||||||
static bool replay_handler(const char* event, char* arg) {
|
|
||||||
// no reply neccesary
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: add intrupt on bottom half delta pin
|
// TODO: add intrupt on bottom half delta pin
|
||||||
// static void IRAM_ATTR gpio_isr_handler(void* arg)
|
// static void IRAM_ATTR gpio_isr_handler(void* arg)
|
||||||
// {
|
// {
|
||||||
@@ -62,8 +56,6 @@ void init_bottom_half() {
|
|||||||
|
|
||||||
xTaskCreate(poll_bottom_task, "poll_bottom", 4096, NULL, 10, NULL);
|
xTaskCreate(poll_bottom_task, "poll_bottom", 4096, NULL, 10, NULL);
|
||||||
|
|
||||||
register_replay_fn(replay_handler);
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Bottom half initialized!");
|
ESP_LOGI(TAG, "Bottom half initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,19 +75,9 @@ static void receive_keypad(void) {
|
|||||||
|
|
||||||
uint16_t just_pressed = new_keypad_state & ~keypad_state;
|
uint16_t just_pressed = new_keypad_state & ~keypad_state;
|
||||||
keypad_pressed |= just_pressed;
|
keypad_pressed |= just_pressed;
|
||||||
if (is_state_tracking() && just_pressed) {
|
|
||||||
char buf[6];
|
|
||||||
sprintf(buf, "%d", just_pressed);
|
|
||||||
event_occured("KP_PRESS", buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t just_released = ~new_keypad_state & keypad_state;
|
uint16_t just_released = ~new_keypad_state & keypad_state;
|
||||||
keypad_released |= just_released;
|
keypad_released |= just_released;
|
||||||
if (is_state_tracking() && just_released) {
|
|
||||||
char buf[6];
|
|
||||||
sprintf(buf, "%d", just_released);
|
|
||||||
event_occured("KP_RELEASE", buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
keypad_state = new_keypad_state;
|
keypad_state = new_keypad_state;
|
||||||
}
|
}
|
||||||
@@ -110,57 +92,27 @@ static void receive_button_switch(void) {
|
|||||||
// button
|
// button
|
||||||
uint8_t just_pressed = new_button_state & ~button_state;
|
uint8_t just_pressed = new_button_state & ~button_state;
|
||||||
button_pressed |= just_pressed;
|
button_pressed |= just_pressed;
|
||||||
if (is_state_tracking() && just_pressed) {
|
|
||||||
char buf[4];
|
|
||||||
sprintf(buf, "%d", just_pressed);
|
|
||||||
event_occured("BTN_PRESS", buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t just_released = ~new_button_state & button_state;
|
uint8_t just_released = ~new_button_state & button_state;
|
||||||
button_released |= just_released;
|
button_released |= just_released;
|
||||||
if (is_state_tracking() && just_released) {
|
|
||||||
char buf[4];
|
|
||||||
sprintf(buf, "%d", just_released);
|
|
||||||
event_occured("BTN_RELEASE", buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
button_state = new_button_state;
|
button_state = new_button_state;
|
||||||
|
|
||||||
// switch
|
// switch
|
||||||
uint8_t just_flipped_up = new_switch_state & ~switch_state;
|
uint8_t just_flipped_up = new_switch_state & ~switch_state;
|
||||||
switch_flipped_up |= just_flipped_up;
|
switch_flipped_up |= just_flipped_up;
|
||||||
if (is_state_tracking() && just_flipped_up) {
|
|
||||||
char buf[4];
|
|
||||||
sprintf(buf, "%d", just_flipped_up);
|
|
||||||
event_occured("SW_UP", buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t just_flipped_down = ~new_switch_state & switch_state;
|
uint8_t just_flipped_down = ~new_switch_state & switch_state;
|
||||||
switch_flipped_down |= just_flipped_down;
|
switch_flipped_down |= just_flipped_down;
|
||||||
if (is_state_tracking() && just_flipped_down) {
|
|
||||||
char buf[4];
|
|
||||||
sprintf(buf, "%d", just_flipped_down);
|
|
||||||
event_occured("SW_DOWN", buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_state = new_switch_state;
|
switch_state = new_switch_state;
|
||||||
|
|
||||||
// switch touch
|
// switch touch
|
||||||
uint8_t touch_just_pressed = new_switch_touch_state & ~switch_touch_state;
|
uint8_t touch_just_pressed = new_switch_touch_state & ~switch_touch_state;
|
||||||
switch_touch_pressed |= touch_just_pressed;
|
switch_touch_pressed |= touch_just_pressed;
|
||||||
if (is_state_tracking() && touch_just_pressed) {
|
|
||||||
char buf[4];
|
|
||||||
sprintf(buf, "%d", touch_just_pressed);
|
|
||||||
event_occured("SW_TOUCH", buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t touch_just_released = ~new_switch_touch_state & switch_touch_state;
|
uint8_t touch_just_released = ~new_switch_touch_state & switch_touch_state;
|
||||||
switch_touch_released |= touch_just_released;
|
switch_touch_released |= touch_just_released;
|
||||||
if (is_state_tracking() && touch_just_released) {
|
|
||||||
char buf[4];
|
|
||||||
sprintf(buf, "%d", touch_just_released);
|
|
||||||
event_occured("SW_UNTOUCH", buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_touch_state = new_switch_touch_state;
|
switch_touch_state = new_switch_touch_state;
|
||||||
}
|
}
|
||||||
@@ -173,15 +125,9 @@ static void receive_touch(void) {
|
|||||||
|
|
||||||
bool just_pressed = new_touch_state & !touch_state;
|
bool just_pressed = new_touch_state & !touch_state;
|
||||||
touch_pressed |= just_pressed;
|
touch_pressed |= just_pressed;
|
||||||
if (is_state_tracking() && just_pressed) {
|
|
||||||
event_occured("FINGER_TOUCHED", NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool just_released = (!new_touch_state) & touch_state;
|
bool just_released = (!new_touch_state) & touch_state;
|
||||||
touch_released |= just_released;
|
touch_released |= just_released;
|
||||||
if (is_state_tracking() && just_released) {
|
|
||||||
event_occured("FINGER_UNTOUCHED", NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
touch_state = new_touch_state;
|
touch_state = new_touch_state;
|
||||||
}
|
}
|
||||||
@@ -190,12 +136,10 @@ static void poll_bottom_task(void *arg) {
|
|||||||
// TODO: if using an interupt, switch this to use a queue
|
// TODO: if using an interupt, switch this to use a queue
|
||||||
while (1) {
|
while (1) {
|
||||||
bool new_data = gpio_get_level(BOTTOM_PIN_INTERUPT) == 0;
|
bool new_data = gpio_get_level(BOTTOM_PIN_INTERUPT) == 0;
|
||||||
// bool new_data = 1;
|
|
||||||
if (new_data) {
|
if (new_data) {
|
||||||
uint8_t delta = receive_delta();
|
uint8_t delta = receive_delta();
|
||||||
// ESP_LOGI(_TAG, "delta: %d", delta);
|
// ESP_LOGI(_TAG, "delta: %d", delta);
|
||||||
// if (delta == 0) ESP_LOGW(TAG, "delta pin was low, but delta register returned 0");
|
if (delta == 0) ESP_LOGW(TAG, "delta pin was low, but delta register returned 0");
|
||||||
if (delta != 0) ESP_LOGI(TAG, "delta!");
|
|
||||||
|
|
||||||
if (delta & (1 << DELTA_BIT_KP)) receive_keypad();
|
if (delta & (1 << DELTA_BIT_KP)) receive_keypad();
|
||||||
if (delta & (1 << DELTA_BIT_BUTTON_SWITCH)) receive_button_switch();
|
if (delta & (1 << DELTA_BIT_BUTTON_SWITCH)) receive_button_switch();
|
||||||
@@ -363,6 +307,7 @@ uint8_t get_switch_touch_state(){
|
|||||||
return switch_touch_state;
|
return switch_touch_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool get_touch_state(void) {
|
bool get_touch_state(void) {
|
||||||
return touch_state;
|
return touch_state;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#define BOTTOM_I2C_NUM I2C_NUM_0
|
#define BOTTOM_I2C_NUM I2C_NUM_0
|
||||||
#define BOTTOM_I2C_ADDR 126
|
#define BOTTOM_I2C_ADDR 126
|
||||||
#define BOTTOM_PIN_INTERUPT GPIO_NUM_13
|
#define BOTTOM_PIN_INTERUPT GPIO_NUM_0
|
||||||
|
|
||||||
#define DELTA_BIT_KP 0
|
#define DELTA_BIT_KP 0
|
||||||
#define DELTA_BIT_BUTTON_SWITCH 1
|
#define DELTA_BIT_BUTTON_SWITCH 1
|
||||||
|
|||||||
+3
-153
@@ -2,92 +2,11 @@
|
|||||||
|
|
||||||
#include "./i2c_lcd_pcf8574.h"
|
#include "./i2c_lcd_pcf8574.h"
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
#include "state_tracking.h"
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
i2c_lcd_pcf8574_handle_t lcd;
|
i2c_lcd_pcf8574_handle_t lcd;
|
||||||
|
|
||||||
static const char *TAG = "char_lcd";
|
static const char *TAG = "char_lcd";
|
||||||
|
|
||||||
static char buf[65];
|
|
||||||
|
|
||||||
static bool replay_handler(const char* event, char* arg) {
|
|
||||||
if (strcmp(event, "LCD_CLEAR") == 0) {
|
|
||||||
lcd_clear();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "LCD_CURSOR_VIS") == 0) {
|
|
||||||
lcd_set_cursor_vis(strcmp(arg, "true") == 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "LCD_CURSOR_BLINK") == 0) {
|
|
||||||
lcd_set_cursor_blink(strcmp(arg, "true") == 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "LCD_SCROLL_DISPLAY_LEFT") == 0) {
|
|
||||||
lcd_scroll_display_left();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "LCD_SCROLL_DISPLAY_RIGHT") == 0) {
|
|
||||||
lcd_scroll_display_right();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "LCD_LEFT_TO_RIGHT") == 0) {
|
|
||||||
lcd_left_to_right();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "LCD_RIGHT_TO_LEFT") == 0) {
|
|
||||||
lcd_right_to_left();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "LCD_AUTOSCROLL") == 0) {
|
|
||||||
lcd_set_autoscroll(strcmp(arg, "true") == 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "LCD_BACKLIGHT") == 0) {
|
|
||||||
uint32_t brightness = atoi(arg);
|
|
||||||
lcd_set_backlight(brightness);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "LCD_CREATE_CHAR") == 0) {
|
|
||||||
char* location_str = strtok(arg, ",");
|
|
||||||
uint8_t location = atoi(location_str);
|
|
||||||
|
|
||||||
uint8_t charmap[8];
|
|
||||||
for (int i = 0; i < 8; i++) {
|
|
||||||
char* str = strtok(NULL, ",");
|
|
||||||
charmap[i] = atoi(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
lcd_create_char(location, charmap);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "LCD_WRITE") == 0) {
|
|
||||||
uint8_t value = atoi(arg);
|
|
||||||
lcd_write(value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "LCD_PRINT") == 0) {
|
|
||||||
// TODO: handle \r and \n
|
|
||||||
lcd_print(arg);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_lcd() {
|
void init_lcd() {
|
||||||
ESP_LOGI(TAG, "Initializing LCD...");
|
ESP_LOGI(TAG, "Initializing LCD...");
|
||||||
|
|
||||||
@@ -96,34 +15,20 @@ void init_lcd() {
|
|||||||
|
|
||||||
lcd_set_backlight(&lcd, 255);
|
lcd_set_backlight(&lcd, 255);
|
||||||
|
|
||||||
register_replay_fn(replay_handler);
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "LCD initialized!");
|
ESP_LOGI(TAG, "LCD initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void lcd_clear() {
|
void lcd_clear() {
|
||||||
lcd_clear(&lcd);
|
lcd_clear(&lcd);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("LCD_CLEAR", NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_cursor_home() {
|
void lcd_cursor_home() {
|
||||||
lcd_home(&lcd);
|
lcd_home(&lcd);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("LCD_CURSOR", "0,0");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_set_cursor_pos(uint8_t col, uint8_t row) {
|
void lcd_set_cursor_pos(uint8_t col, uint8_t row) {
|
||||||
lcd_set_cursor(&lcd, col, 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) {
|
void lcd_set_display(bool display) {
|
||||||
@@ -132,10 +37,6 @@ void lcd_set_display(bool display) {
|
|||||||
} else {
|
} else {
|
||||||
lcd_no_display(&lcd);
|
lcd_no_display(&lcd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("LCD_SET_DISPLAY", display ? "true" : "false");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_set_cursor_vis(bool cursor) {
|
void lcd_set_cursor_vis(bool cursor) {
|
||||||
@@ -144,10 +45,6 @@ void lcd_set_cursor_vis(bool cursor) {
|
|||||||
} else {
|
} else {
|
||||||
lcd_no_cursor(&lcd);
|
lcd_no_cursor(&lcd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("LCD_CURSOR_VIS", cursor ? "true" : "false");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_set_cursor_blink(bool blink) {
|
void lcd_set_cursor_blink(bool blink) {
|
||||||
@@ -156,40 +53,20 @@ void lcd_set_cursor_blink(bool blink) {
|
|||||||
} else {
|
} else {
|
||||||
lcd_no_blink(&lcd);
|
lcd_no_blink(&lcd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("LCD_CURSOR_BLINK", blink ? "true" : "false");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_scroll_display_left() {
|
void lcd_scroll_display_left() {
|
||||||
lcd_scroll_display_left(&lcd);
|
lcd_scroll_display_left(&lcd);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("LCD_SCROLL_DISPLAY_LEFT", NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void lcd_scroll_display_right() {
|
void lcd_scroll_display_right() {
|
||||||
lcd_scroll_display_right(&lcd);
|
lcd_scroll_display_right(&lcd);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("LCD_SCROLL_DISPLAY_RIGHT", NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_left_to_right() {
|
void lcd_left_to_right() {
|
||||||
lcd_left_to_right(&lcd);
|
lcd_left_to_right(&lcd);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("LCD_LEFT_TO_RIGHT", NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void lcd_right_to_left() {
|
void lcd_right_to_left() {
|
||||||
lcd_right_to_left(&lcd);
|
lcd_right_to_left(&lcd);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("LCD_RIGHT_TO_LEFT", NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_set_autoscroll(bool autoscroll) {
|
void lcd_set_autoscroll(bool autoscroll) {
|
||||||
@@ -198,52 +75,25 @@ void lcd_set_autoscroll(bool autoscroll) {
|
|||||||
} else {
|
} else {
|
||||||
lcd_no_autoscroll(&lcd);
|
lcd_no_autoscroll(&lcd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("LCD_AUTOSCROLL", autoscroll ? "true" : "false");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_set_backlight(uint8_t brightness) {
|
void lcd_set_backlight(uint8_t brightness) {
|
||||||
lcd_set_backlight(&lcd, brightness);
|
lcd_set_backlight(&lcd, brightness);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
sprintf(buf, "%d", brightness);
|
|
||||||
event_occured("LCD_BACKLIGHT", buf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_create_char(uint8_t location, uint8_t* charmap) {
|
void lcd_create_char(uint8_t location, uint8_t charmap[]) {
|
||||||
lcd_create_char(&lcd, location, charmap);
|
lcd_create_char(&lcd, location, charmap);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
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]
|
|
||||||
);
|
|
||||||
event_occured("LCD_CREATE_CHAR", buf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_write(uint8_t value) {
|
void lcd_write(uint8_t value) {
|
||||||
lcd_write(&lcd, value);
|
lcd_write(&lcd, value);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
sprintf(buf, "%d", value);
|
|
||||||
event_occured("LCD_WRITE", buf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_print(const char* str) {
|
void lcd_print(const char* str) {
|
||||||
lcd_print(&lcd, str);
|
lcd_print(&lcd, str);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
// TODO: handle \r and \n
|
|
||||||
event_occured("LCD_PRINT", str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_print(uint8_t col, uint8_t row, const char* str) {
|
void lcd_print(uint8_t col, uint8_t row, const char* str) {
|
||||||
lcd_set_cursor_pos(col, row);
|
lcd_set_cursor_pos(col, row);
|
||||||
lcd_print(str);
|
lcd_print(&lcd, str);
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ static esp_err_t panel_ili9488_init(esp_lcd_panel_t *panel)
|
|||||||
// ORIGINAL
|
// ORIGINAL
|
||||||
lcd_init_cmd_t ili9488_init[] =
|
lcd_init_cmd_t ili9488_init[] =
|
||||||
{
|
{
|
||||||
#if CONFIG_USE_NEW_DISPLAY || 1
|
#if CONFIG_USE_NEW_DISPLAY
|
||||||
{ ILI9488_POSITIVE_GAMMA_CTL, { 0x00, 0x08, 0x0c, 0x02, 0x0e, 0x04, 0x30, 0x45, 0x47, 0x04, 0x0C, 0x0a, 0x2e, 0x34, 0x0F }, 15 },
|
{ ILI9488_POSITIVE_GAMMA_CTL, { 0x00, 0x08, 0x0c, 0x02, 0x0e, 0x04, 0x30, 0x45, 0x47, 0x04, 0x0C, 0x0a, 0x2e, 0x34, 0x0F }, 15 },
|
||||||
{ ILI9488_NEGATIVE_GAMMA_CTL, { 0x00, 0x11, 0x0d, 0x01, 0x0f, 0x05, 0x39, 0x36, 0x51, 0x06, 0x0f, 0x0d, 0x33, 0x37, 0x0F }, 15 },
|
{ ILI9488_NEGATIVE_GAMMA_CTL, { 0x00, 0x11, 0x0d, 0x01, 0x0f, 0x05, 0x39, 0x36, 0x51, 0x06, 0x0f, 0x0d, 0x33, 0x37, 0x0F }, 15 },
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -1,326 +0,0 @@
|
|||||||
#include "bottom_half.h"
|
|
||||||
#include "inputs.hpp"
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
static uint8_t reverse_4_bits(uint8_t value) {
|
|
||||||
return static_cast<uint8_t>(((value & 0x1) << 3) |
|
|
||||||
((value & 0x2) << 1) |
|
|
||||||
((value & 0x4) >> 1) |
|
|
||||||
((value & 0x8) >> 3));
|
|
||||||
}
|
|
||||||
|
|
||||||
static KeypadKey map_input_keypad_key(InputKeypadKey key) {
|
|
||||||
switch (key) {
|
|
||||||
case InputKeypadKey::K0: return KeypadKey::k0;
|
|
||||||
case InputKeypadKey::K1: return KeypadKey::k1;
|
|
||||||
case InputKeypadKey::K2: return KeypadKey::k2;
|
|
||||||
case InputKeypadKey::K3: return KeypadKey::k3;
|
|
||||||
case InputKeypadKey::K4: return KeypadKey::k4;
|
|
||||||
case InputKeypadKey::K5: return KeypadKey::k5;
|
|
||||||
case InputKeypadKey::K6: return KeypadKey::k6;
|
|
||||||
case InputKeypadKey::K7: return KeypadKey::k7;
|
|
||||||
case InputKeypadKey::K8: return KeypadKey::k8;
|
|
||||||
case InputKeypadKey::K9: return KeypadKey::k9;
|
|
||||||
case InputKeypadKey::A: return KeypadKey::ka;
|
|
||||||
case InputKeypadKey::B: return KeypadKey::kb;
|
|
||||||
case InputKeypadKey::C: return KeypadKey::kc;
|
|
||||||
case InputKeypadKey::D: return KeypadKey::kd;
|
|
||||||
case InputKeypadKey::STAR: return KeypadKey::star;
|
|
||||||
case InputKeypadKey::POUND: return KeypadKey::pound;
|
|
||||||
default: return KeypadKey::k0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t get_fingerprint_touch_state() {
|
|
||||||
InputsState current = InputsController::get_input_state();
|
|
||||||
return static_cast<uint8_t>((current.touch_state >> 4) & 0x1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool touch_state_initialized = false;
|
|
||||||
static bool touch_state_last = false;
|
|
||||||
|
|
||||||
static bool update_fingerprint_transition(bool want_pressed) {
|
|
||||||
bool current = get_fingerprint_touch_state();
|
|
||||||
if (!touch_state_initialized) {
|
|
||||||
touch_state_last = current;
|
|
||||||
touch_state_initialized = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool transition = want_pressed ? (current && !touch_state_last)
|
|
||||||
: (!current && touch_state_last);
|
|
||||||
touch_state_last = current;
|
|
||||||
return transition;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::array<SwitchFlip, 8> pending_switch_flips;
|
|
||||||
static size_t pending_switch_flip_count = 0;
|
|
||||||
|
|
||||||
static void push_pending_switch_flip(const SwitchFlip& event) {
|
|
||||||
if (pending_switch_flip_count < pending_switch_flips.size()) {
|
|
||||||
pending_switch_flips[pending_switch_flip_count++] = event;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drop the oldest event if the buffer is full.
|
|
||||||
for (size_t i = 1; i < pending_switch_flips.size(); ++i) {
|
|
||||||
pending_switch_flips[i - 1] = pending_switch_flips[i];
|
|
||||||
}
|
|
||||||
pending_switch_flips.back() = event;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool pop_pending_switch_flip(bool want_up, SwitchFlip& out) {
|
|
||||||
for (size_t i = 0; i < pending_switch_flip_count; ++i) {
|
|
||||||
if (pending_switch_flips[i].is_up() == want_up) {
|
|
||||||
out = pending_switch_flips[i];
|
|
||||||
for (size_t j = i + 1; j < pending_switch_flip_count; ++j) {
|
|
||||||
pending_switch_flips[j - 1] = pending_switch_flips[j];
|
|
||||||
}
|
|
||||||
--pending_switch_flip_count;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void clear_pending_switch_flips() {
|
|
||||||
pending_switch_flip_count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::array<SwitchTouch, 8> pending_switch_touches;
|
|
||||||
static size_t pending_switch_touch_count = 0;
|
|
||||||
|
|
||||||
static void push_pending_switch_touch(const SwitchTouch& event) {
|
|
||||||
if (pending_switch_touch_count < pending_switch_touches.size()) {
|
|
||||||
pending_switch_touches[pending_switch_touch_count++] = event;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 1; i < pending_switch_touches.size(); ++i) {
|
|
||||||
pending_switch_touches[i - 1] = pending_switch_touches[i];
|
|
||||||
}
|
|
||||||
pending_switch_touches.back() = event;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool pop_pending_switch_touch(bool want_touched, SwitchTouch& out) {
|
|
||||||
for (size_t i = 0; i < pending_switch_touch_count; ++i) {
|
|
||||||
if (pending_switch_touches[i].is_touched() == want_touched) {
|
|
||||||
out = pending_switch_touches[i];
|
|
||||||
for (size_t j = i + 1; j < pending_switch_touch_count; ++j) {
|
|
||||||
pending_switch_touches[j - 1] = pending_switch_touches[j];
|
|
||||||
}
|
|
||||||
--pending_switch_touch_count;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void clear_pending_switch_touches() {
|
|
||||||
pending_switch_touch_count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_bottom_half() {
|
|
||||||
init_expander();
|
|
||||||
clear_all_pressed_released();
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear_all_pressed_released() {
|
|
||||||
InputsController::clear_all_events();
|
|
||||||
clear_pending_switch_flips();
|
|
||||||
clear_pending_switch_touches();
|
|
||||||
touch_state_initialized = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_keypad_pressed(KeypadKey* kp) {
|
|
||||||
auto opt = InputsController::get_keypad_press();
|
|
||||||
if (!opt.has_value()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kp != nullptr) {
|
|
||||||
*kp = map_input_keypad_key(opt.value());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_keypad_released(KeypadKey* kp) {
|
|
||||||
auto opt = InputsController::get_keypad_release();
|
|
||||||
if (!opt.has_value()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kp != nullptr) {
|
|
||||||
*kp = map_input_keypad_key(opt.value());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
char char_of_keypad_key(KeypadKey kp) {
|
|
||||||
switch (kp) {
|
|
||||||
case KeypadKey::k1: return '1';
|
|
||||||
case KeypadKey::k2: return '2';
|
|
||||||
case KeypadKey::k3: return '3';
|
|
||||||
case KeypadKey::k4: return '4';
|
|
||||||
case KeypadKey::k5: return '5';
|
|
||||||
case KeypadKey::k6: return '6';
|
|
||||||
case KeypadKey::k7: return '7';
|
|
||||||
case KeypadKey::k8: return '8';
|
|
||||||
case KeypadKey::k9: return '9';
|
|
||||||
case KeypadKey::k0: return '0';
|
|
||||||
case KeypadKey::ka: return 'A';
|
|
||||||
case KeypadKey::kb: return 'B';
|
|
||||||
case KeypadKey::kc: return 'C';
|
|
||||||
case KeypadKey::kd: return 'D';
|
|
||||||
case KeypadKey::star: return '*';
|
|
||||||
case KeypadKey::pound: return '#';
|
|
||||||
default: return ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool take_button(ButtonKey* button, std::optional<Button> opt) {
|
|
||||||
if (!opt.has_value()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (button != nullptr) {
|
|
||||||
*button = static_cast<ButtonKey>(static_cast<uint8_t>(opt.value()));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_button_pressed(ButtonKey* button) {
|
|
||||||
return take_button(button, InputsController::get_button_press());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_button_released(ButtonKey* button) {
|
|
||||||
return take_button(button, InputsController::get_button_release());
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t get_button_state() {
|
|
||||||
return reverse_4_bits(InputsController::button_state() & 0xF);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool take_switch_key(SwitchKey* switch_, const SwitchFlip& event) {
|
|
||||||
if (switch_ != nullptr) {
|
|
||||||
*switch_ = static_cast<SwitchKey>(static_cast<uint8_t>(event.get_switch()));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_switch_flipped_up(SwitchKey* switch_) {
|
|
||||||
SwitchFlip event;
|
|
||||||
if (pop_pending_switch_flip(true, event)) {
|
|
||||||
return take_switch_key(switch_, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
auto opt = InputsController::get_switch_flip();
|
|
||||||
if (!opt.has_value()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (opt->is_up()) {
|
|
||||||
return take_switch_key(switch_, *opt);
|
|
||||||
}
|
|
||||||
push_pending_switch_flip(*opt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_switch_flipped_down(SwitchKey* switch_) {
|
|
||||||
SwitchFlip event;
|
|
||||||
if (pop_pending_switch_flip(false, event)) {
|
|
||||||
return take_switch_key(switch_, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
auto opt = InputsController::get_switch_flip();
|
|
||||||
if (!opt.has_value()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!opt->is_up()) {
|
|
||||||
return take_switch_key(switch_, *opt);
|
|
||||||
}
|
|
||||||
push_pending_switch_flip(*opt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_switch_flipped(SwitchKey* switch_) {
|
|
||||||
if (pending_switch_flip_count > 0) {
|
|
||||||
SwitchFlip event = pending_switch_flips[0];
|
|
||||||
for (size_t i = 1; i < pending_switch_flip_count; ++i) {
|
|
||||||
pending_switch_flips[i - 1] = pending_switch_flips[i];
|
|
||||||
}
|
|
||||||
--pending_switch_flip_count;
|
|
||||||
return take_switch_key(switch_, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto opt = InputsController::get_switch_flip();
|
|
||||||
if (!opt.has_value()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return take_switch_key(switch_, *opt);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t get_switch_state() {
|
|
||||||
return reverse_4_bits(InputsController::switch_state() & 0xF);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool take_switch_touch(SwitchKey* switch_, const SwitchTouch& event) {
|
|
||||||
if (switch_ != nullptr) {
|
|
||||||
*switch_ = static_cast<SwitchKey>(static_cast<uint8_t>(event.get_switch()));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_switch_touch_pressed(SwitchKey* switch_) {
|
|
||||||
SwitchTouch event;
|
|
||||||
if (pop_pending_switch_touch(true, event)) {
|
|
||||||
return take_switch_touch(switch_, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
auto opt = InputsController::get_switch_touch();
|
|
||||||
if (!opt.has_value()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (opt->is_touched()) {
|
|
||||||
return take_switch_touch(switch_, *opt);
|
|
||||||
}
|
|
||||||
push_pending_switch_touch(*opt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_switch_touch_released(SwitchKey* switch_) {
|
|
||||||
SwitchTouch event;
|
|
||||||
if (pop_pending_switch_touch(false, event)) {
|
|
||||||
return take_switch_touch(switch_, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
auto opt = InputsController::get_switch_touch();
|
|
||||||
if (!opt.has_value()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!opt->is_touched()) {
|
|
||||||
return take_switch_touch(switch_, *opt);
|
|
||||||
}
|
|
||||||
push_pending_switch_touch(*opt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t get_switch_touch_state() {
|
|
||||||
return reverse_4_bits(InputsController::switch_touch_state() & 0xF);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_touch_state() {
|
|
||||||
return get_fingerprint_touch_state() != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_touch_pressed() {
|
|
||||||
return update_fingerprint_transition(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_touch_released() {
|
|
||||||
return update_fingerprint_transition(false);
|
|
||||||
}
|
|
||||||
@@ -1,475 +0,0 @@
|
|||||||
#include "inputs.hpp"
|
|
||||||
#include "pins.h"
|
|
||||||
#include "driver/i2c.h"
|
|
||||||
#include "driver/gpio.h"
|
|
||||||
#include "freertos/FreeRTOS.h"
|
|
||||||
#include "freertos/task.h"
|
|
||||||
#include "esp_log.h"
|
|
||||||
#include "esp_err.h"
|
|
||||||
|
|
||||||
static const char *TAG = "INPUTS";
|
|
||||||
|
|
||||||
static TaskHandle_t expander_task_handle = NULL;
|
|
||||||
|
|
||||||
const static uint8_t REG_WHOAMI = 0x01;
|
|
||||||
const static uint8_t REG_SW_VERSION = 0x02;
|
|
||||||
const static uint8_t REG_EVENT_QUEUE_POP = 0x10;
|
|
||||||
const static uint8_t REG_EVENT_QUEUE_LEN = 0x11;
|
|
||||||
const static uint8_t REG_STATE_BUTTONS = 0x20;
|
|
||||||
const static uint8_t REG_STATE_SWITCHES = 0x21;
|
|
||||||
const static uint8_t REG_STATE_KEYPAD = 0x22;
|
|
||||||
const static uint8_t REG_STATE_TOUCH = 0x23;
|
|
||||||
const static uint8_t REG_STATE_RFID = 0x24;
|
|
||||||
const static uint8_t REG_STATE_HALL = 0x25;
|
|
||||||
const static uint8_t REG_STATE_CLOSE = 0x26;
|
|
||||||
const static uint8_t REG_RESET = 0x30;
|
|
||||||
const static uint8_t REG_HALL_SENSITIVITY = 0x31;
|
|
||||||
const static uint8_t REG_CLOSE_SENSITIVITY = 0x32;
|
|
||||||
const static uint8_t REG_SWITCH_TOUCH_EVENT = 0x33;
|
|
||||||
|
|
||||||
/// The global data for the expander peripheral.
|
|
||||||
class ExpanderPeripheral {
|
|
||||||
// TODO: change these to private
|
|
||||||
// or even make this class hidden
|
|
||||||
public:
|
|
||||||
SemaphoreHandle_t state_mutex;
|
|
||||||
InputsState state;
|
|
||||||
|
|
||||||
// channels
|
|
||||||
QueueHandle_t button_press_events;
|
|
||||||
QueueHandle_t button_release_events;
|
|
||||||
QueueHandle_t switch_flip_events;
|
|
||||||
QueueHandle_t switch_touch_events;
|
|
||||||
QueueHandle_t touch_events;
|
|
||||||
QueueHandle_t keypad_press_events;
|
|
||||||
QueueHandle_t keypad_release_events;
|
|
||||||
};
|
|
||||||
|
|
||||||
ExpanderPeripheral expander_peripheral_singleton;
|
|
||||||
|
|
||||||
// forward declarations
|
|
||||||
static void get_events();
|
|
||||||
static void handle_event(uint8_t event);
|
|
||||||
static void handle_button_switch_event(uint8_t event);
|
|
||||||
static void handle_keypad_event(uint8_t event);
|
|
||||||
static void handle_touch_event(uint8_t event);
|
|
||||||
static void handle_rfid_event(uint8_t event);
|
|
||||||
static void handle_close_hal_event(uint8_t event);
|
|
||||||
static void expander_task(void *arg);
|
|
||||||
|
|
||||||
// ISR handler
|
|
||||||
static void IRAM_ATTR expander_isr_handler(void *arg) {
|
|
||||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
|
||||||
|
|
||||||
if (expander_task_handle != NULL) {
|
|
||||||
vTaskNotifyGiveFromISR(expander_task_handle, &xHigherPriorityTaskWoken);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xHigherPriorityTaskWoken == pdTRUE) {
|
|
||||||
portYIELD_FROM_ISR();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_expander() {
|
|
||||||
ESP_LOGI(TAG, "Initializing expander...");
|
|
||||||
|
|
||||||
// legacy I2C driver: use the shared I2C_NUM_0 bus already configured elsewhere.
|
|
||||||
// TODO: replace all these ESP_ERROR_CHECK with proper error handling that doesn't just crash the program
|
|
||||||
|
|
||||||
// setup interrupt on PIN_EXPANDER_INT
|
|
||||||
gpio_config_t io_conf = {
|
|
||||||
.pin_bit_mask = (1ULL << PIN_EXPANDER_INT),
|
|
||||||
.mode = GPIO_MODE_INPUT,
|
|
||||||
.pull_up_en = GPIO_PULLUP_ENABLE,
|
|
||||||
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
|
||||||
.intr_type = GPIO_INTR_NEGEDGE
|
|
||||||
};
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(gpio_config(&io_conf));
|
|
||||||
|
|
||||||
// Install ISR service (only call once in your program)
|
|
||||||
ESP_ERROR_CHECK(gpio_install_isr_service(0));
|
|
||||||
|
|
||||||
// Attach the ISR to the expander pin
|
|
||||||
ESP_ERROR_CHECK(gpio_isr_handler_add(PIN_EXPANDER_INT, expander_isr_handler, NULL));
|
|
||||||
|
|
||||||
// verify the expander connection status by reading the WHOAMI register
|
|
||||||
uint8_t read_buf[2] = {0};
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(i2c_master_write_read_device(I2C_NUM_0, EXPANDER_I2C_ADDR, ®_WHOAMI, 1, read_buf, 1, pdMS_TO_TICKS(EXPANDER_TIMEOUT_MS)));
|
|
||||||
|
|
||||||
if (read_buf[0] != EXPANDER_WHOAMI_VALUE) {
|
|
||||||
ESP_LOGE(TAG, "WHOAMI mismatch, expected 0x%02X, got 0x%02X", EXPANDER_WHOAMI_VALUE, read_buf[0]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Expander WHOAMI check passed");
|
|
||||||
|
|
||||||
ESP_ERROR_CHECK(i2c_master_write_read_device(I2C_NUM_0, EXPANDER_I2C_ADDR, ®_SW_VERSION, 1, read_buf, 2, pdMS_TO_TICKS(EXPANDER_TIMEOUT_MS)));
|
|
||||||
|
|
||||||
// init the peripheral struct
|
|
||||||
expander_peripheral_singleton.state_mutex = xSemaphoreCreateMutex();
|
|
||||||
expander_peripheral_singleton.button_press_events= xQueueCreate(EXPANDER_EVENT_QUEUE_SIZE, sizeof(Button));
|
|
||||||
expander_peripheral_singleton.button_release_events= xQueueCreate(EXPANDER_EVENT_QUEUE_SIZE, sizeof(Button));
|
|
||||||
expander_peripheral_singleton.switch_flip_events= xQueueCreate(EXPANDER_EVENT_QUEUE_SIZE, sizeof(SwitchFlip));
|
|
||||||
expander_peripheral_singleton.switch_touch_events= xQueueCreate(EXPANDER_EVENT_QUEUE_SIZE, sizeof(SwitchTouch));
|
|
||||||
expander_peripheral_singleton.touch_events= xQueueCreate(EXPANDER_EVENT_QUEUE_SIZE, sizeof(TouchedReleased));
|
|
||||||
expander_peripheral_singleton.keypad_press_events= xQueueCreate(EXPANDER_KEYPAD_QUEUE_SIZE, sizeof(InputKeypadKey));
|
|
||||||
expander_peripheral_singleton.keypad_release_events= xQueueCreate(EXPANDER_KEYPAD_QUEUE_SIZE, sizeof(InputKeypadKey));
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Expander initialized! SW version: v%d.%d", read_buf[0], read_buf[1]);
|
|
||||||
|
|
||||||
// Create the expander background worker task
|
|
||||||
BaseType_t task_created = xTaskCreate(
|
|
||||||
expander_task,
|
|
||||||
"expander_task",
|
|
||||||
4096,
|
|
||||||
NULL,
|
|
||||||
tskIDLE_PRIORITY + 1,
|
|
||||||
&expander_task_handle
|
|
||||||
);
|
|
||||||
|
|
||||||
if (task_created != pdPASS) {
|
|
||||||
ESP_LOGE(TAG, "Failed to create expander task");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void expander_task(void *arg) {
|
|
||||||
(void)arg;
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
get_events();
|
|
||||||
|
|
||||||
// Wait for interrupt notification (signal is sent when INT falls)
|
|
||||||
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void get_events() {
|
|
||||||
uint8_t recv;
|
|
||||||
while (gpio_get_level(PIN_EXPANDER_INT) == 0) {
|
|
||||||
ESP_ERROR_CHECK(i2c_master_write_read_device(I2C_NUM_0, EXPANDER_I2C_ADDR, ®_EVENT_QUEUE_POP, 1, &recv, 1, pdMS_TO_TICKS(EXPANDER_TIMEOUT_MS)));
|
|
||||||
handle_event(recv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_event(uint8_t event) {
|
|
||||||
const uint8_t BUTTON_SWITCH = 0b000;
|
|
||||||
const uint8_t KEYPAD = 0b001;
|
|
||||||
const uint8_t TOUCH = 0b010;
|
|
||||||
const uint8_t RFID = 0b011;
|
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Expander event: 0b%08b (0x%02X)", event, event);
|
|
||||||
|
|
||||||
if (event == 0) {
|
|
||||||
ESP_LOGE(TAG, "We read from event queue while it was empty!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t type_bits = event >> 5;
|
|
||||||
|
|
||||||
switch (type_bits) {
|
|
||||||
case BUTTON_SWITCH:
|
|
||||||
handle_button_switch_event(event);
|
|
||||||
break;
|
|
||||||
case KEYPAD:
|
|
||||||
handle_keypad_event(event);
|
|
||||||
break;
|
|
||||||
case TOUCH:
|
|
||||||
handle_touch_event(event);
|
|
||||||
break;
|
|
||||||
case RFID:
|
|
||||||
handle_rfid_event(event);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
handle_close_hal_event(event);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_button_switch_event(uint8_t event) {
|
|
||||||
const uint8_t PRESSED_NOT_RELEASED_BIT = 0b10000;
|
|
||||||
const uint8_t SWITCH_NOT_BUTTON_BIT = 0b01000;
|
|
||||||
const uint8_t SWITCH_UP_NOT_DOWN_BIT = 0b00100;
|
|
||||||
const uint8_t NUMBER_MASK = 0b00011;
|
|
||||||
|
|
||||||
bool pressed = (event & PRESSED_NOT_RELEASED_BIT) != 0;
|
|
||||||
uint8_t number = event & NUMBER_MASK;
|
|
||||||
|
|
||||||
if ((event & SWITCH_NOT_BUTTON_BIT) != 0) {
|
|
||||||
// For now, we support two position switches by only looking at the switch up events
|
|
||||||
bool switch_up = (event & SWITCH_UP_NOT_DOWN_BIT) != 0;
|
|
||||||
if (!switch_up) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Switch sw = static_cast<Switch>(number);
|
|
||||||
SwitchFlip sw_flip = SwitchFlip(sw, pressed);
|
|
||||||
xQueueSendToBack(expander_peripheral_singleton.switch_flip_events, &sw_flip, 0);
|
|
||||||
xSemaphoreTake(expander_peripheral_singleton.state_mutex, portMAX_DELAY);
|
|
||||||
if (pressed) {
|
|
||||||
// set
|
|
||||||
expander_peripheral_singleton.state.switch_state |= 1 << number;
|
|
||||||
} else {
|
|
||||||
// clear
|
|
||||||
expander_peripheral_singleton.state.switch_state &= ~(1 << number);
|
|
||||||
}
|
|
||||||
xSemaphoreGive(expander_peripheral_singleton.state_mutex);
|
|
||||||
} else {
|
|
||||||
// button
|
|
||||||
Button button = static_cast<Button>(number);
|
|
||||||
if (pressed) {
|
|
||||||
xQueueSendToBack(expander_peripheral_singleton.button_press_events, &button, 0);
|
|
||||||
xSemaphoreTake(expander_peripheral_singleton.state_mutex, portMAX_DELAY);
|
|
||||||
expander_peripheral_singleton.state.button_state |= 1 << number;
|
|
||||||
xSemaphoreGive(expander_peripheral_singleton.state_mutex);
|
|
||||||
} else {
|
|
||||||
xQueueSendToBack(expander_peripheral_singleton.button_release_events, &button, 0);
|
|
||||||
xSemaphoreTake(expander_peripheral_singleton.state_mutex, portMAX_DELAY);
|
|
||||||
expander_peripheral_singleton.state.button_state &= ~(1 << number);
|
|
||||||
xSemaphoreGive(expander_peripheral_singleton.state_mutex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_keypad_event(uint8_t event) {
|
|
||||||
const uint8_t PRESSED_NOT_RELEASED_BIT = 0b10000;
|
|
||||||
const uint8_t KEY_MASK = 0b1111;
|
|
||||||
|
|
||||||
bool pressed = (event & PRESSED_NOT_RELEASED_BIT) != 0;
|
|
||||||
uint8_t number = event & KEY_MASK;
|
|
||||||
InputKeypadKey key = static_cast<InputKeypadKey>(number);
|
|
||||||
|
|
||||||
// starcode system gets first dibs
|
|
||||||
// TODO: do starcode inbetweener
|
|
||||||
// if starcode_handle_keypad(key, pressed).await {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (pressed) {
|
|
||||||
xQueueSendToBack(expander_peripheral_singleton.keypad_press_events, &key, 0);
|
|
||||||
xSemaphoreTake(expander_peripheral_singleton.state_mutex, portMAX_DELAY);
|
|
||||||
expander_peripheral_singleton.state.keypad_state |= 1 << number;
|
|
||||||
xSemaphoreGive(expander_peripheral_singleton.state_mutex);
|
|
||||||
} else {
|
|
||||||
xQueueSendToBack(expander_peripheral_singleton.keypad_release_events, &key, 0);
|
|
||||||
xSemaphoreTake(expander_peripheral_singleton.state_mutex, portMAX_DELAY);
|
|
||||||
expander_peripheral_singleton.state.keypad_state &= ~(1 << number);
|
|
||||||
xSemaphoreGive(expander_peripheral_singleton.state_mutex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_touch_event(uint8_t event) {
|
|
||||||
const uint8_t TOUCHED_NOT_UNTOUCHED_BIT = 0b10000;
|
|
||||||
const uint8_t SENSOR_MASK = 0b0111;
|
|
||||||
const uint8_t FINGERPRINT_BIT = 0b0100;
|
|
||||||
|
|
||||||
bool touched = (event & TOUCHED_NOT_UNTOUCHED_BIT) != 0;
|
|
||||||
uint8_t sensor = event & SENSOR_MASK;
|
|
||||||
|
|
||||||
if ((sensor & FINGERPRINT_BIT) != 0) {
|
|
||||||
TouchedReleased touch_state = static_cast<TouchedReleased>(touched);
|
|
||||||
xQueueSendToBack(expander_peripheral_singleton.touch_events, &touch_state, 0);
|
|
||||||
} else {
|
|
||||||
Switch sw = static_cast<Switch>(sensor);
|
|
||||||
SwitchTouch sw_touch = SwitchTouch(sw, touched);
|
|
||||||
xQueueSendToBack(expander_peripheral_singleton.switch_touch_events, &sw_touch, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
xSemaphoreTake(expander_peripheral_singleton.state_mutex, portMAX_DELAY);
|
|
||||||
if (touched) {
|
|
||||||
expander_peripheral_singleton.state.touch_state |= 1 << sensor;
|
|
||||||
} else {
|
|
||||||
expander_peripheral_singleton.state.touch_state &= ~(1 << sensor);
|
|
||||||
}
|
|
||||||
xSemaphoreGive(expander_peripheral_singleton.state_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_rfid_event(uint8_t event) {
|
|
||||||
// TODO: impl
|
|
||||||
(void)event;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_close_hal_event(uint8_t event) {
|
|
||||||
// TODO: impl
|
|
||||||
(void)event;
|
|
||||||
}
|
|
||||||
|
|
||||||
// InputsController implementations
|
|
||||||
|
|
||||||
/// Clears all events waiting in the queues.
|
|
||||||
void InputsController::clear_all_events() {
|
|
||||||
xQueueReset(expander_peripheral_singleton.button_press_events);
|
|
||||||
xQueueReset(expander_peripheral_singleton.button_release_events);
|
|
||||||
xQueueReset(expander_peripheral_singleton.switch_flip_events);
|
|
||||||
xQueueReset(expander_peripheral_singleton.switch_touch_events);
|
|
||||||
xQueueReset(expander_peripheral_singleton.touch_events);
|
|
||||||
xQueueReset(expander_peripheral_singleton.keypad_press_events);
|
|
||||||
xQueueReset(expander_peripheral_singleton.keypad_release_events);
|
|
||||||
}
|
|
||||||
|
|
||||||
InputsState InputsController::get_input_state() {
|
|
||||||
xSemaphoreTake(expander_peripheral_singleton.state_mutex, portMAX_DELAY);
|
|
||||||
InputsState state_copy = expander_peripheral_singleton.state;
|
|
||||||
xSemaphoreGive(expander_peripheral_singleton.state_mutex);
|
|
||||||
return state_copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns `true` iff there is a button press event waiting.
|
|
||||||
bool InputsController::has_button_press() {
|
|
||||||
return uxQueueMessagesWaiting(expander_peripheral_singleton.button_press_events) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the next button press event (if any).
|
|
||||||
std::optional<Button> InputsController::get_button_press() {
|
|
||||||
Button b;
|
|
||||||
if (xQueueReceive(expander_peripheral_singleton.button_press_events, &b, 0) == pdTRUE) {
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the next button press event, waiting if neccesary.
|
|
||||||
Button InputsController::wait_button_press() {
|
|
||||||
Button b;
|
|
||||||
xQueueReceive(expander_peripheral_singleton.button_press_events, &b, portMAX_DELAY);
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the current state of the buttons.
|
|
||||||
uint8_t InputsController::button_state() {
|
|
||||||
xSemaphoreTake(expander_peripheral_singleton.state_mutex, portMAX_DELAY);
|
|
||||||
uint8_t value = expander_peripheral_singleton.state.button_state;
|
|
||||||
xSemaphoreGive(expander_peripheral_singleton.state_mutex);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns `true` iff there is a button release event waiting.
|
|
||||||
bool InputsController::has_button_release() {
|
|
||||||
return uxQueueMessagesWaiting(expander_peripheral_singleton.button_release_events) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the next button release event (if any).
|
|
||||||
std::optional<Button> InputsController::get_button_release() {
|
|
||||||
Button b;
|
|
||||||
if (xQueueReceive(expander_peripheral_singleton.button_release_events, &b, 0) == pdTRUE) {
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the next button release event, waiting if neccesary.
|
|
||||||
Button InputsController::wait_button_release() {
|
|
||||||
Button b;
|
|
||||||
xQueueReceive(expander_peripheral_singleton.button_release_events, &b, portMAX_DELAY);
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns `true` iff there is a switch flip event waiting.
|
|
||||||
bool InputsController::has_switch_flip() {
|
|
||||||
return uxQueueMessagesWaiting(expander_peripheral_singleton.switch_flip_events) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the next switch flip event (if any).
|
|
||||||
std::optional<SwitchFlip> InputsController::get_switch_flip() {
|
|
||||||
SwitchFlip s;
|
|
||||||
if (xQueueReceive(expander_peripheral_singleton.switch_flip_events, &s, 0) == pdTRUE) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the next switch flip event, waiting if neccesary.
|
|
||||||
SwitchFlip InputsController::wait_switch_flip() {
|
|
||||||
SwitchFlip s;
|
|
||||||
xQueueReceive(expander_peripheral_singleton.switch_flip_events, &s, portMAX_DELAY);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the current state of the switches.
|
|
||||||
uint8_t InputsController::switch_state() {
|
|
||||||
xSemaphoreTake(expander_peripheral_singleton.state_mutex, portMAX_DELAY);
|
|
||||||
uint8_t value = expander_peripheral_singleton.state.switch_state;
|
|
||||||
xSemaphoreGive(expander_peripheral_singleton.state_mutex);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns `true` iff there is a switch touch event waiting.
|
|
||||||
bool InputsController::has_switch_touch() {
|
|
||||||
return uxQueueMessagesWaiting(expander_peripheral_singleton.switch_touch_events) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the next switch touch event (if any).
|
|
||||||
std::optional<SwitchTouch> InputsController::get_switch_touch() {
|
|
||||||
SwitchTouch s;
|
|
||||||
if (xQueueReceive(expander_peripheral_singleton.switch_touch_events, &s, 0) == pdTRUE) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the next switch touch event, waiting if neccesary.
|
|
||||||
SwitchTouch InputsController::wait_switch_touch() {
|
|
||||||
SwitchTouch s;
|
|
||||||
xQueueReceive(expander_peripheral_singleton.switch_touch_events, &s, portMAX_DELAY);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the current state of the touch sensors.
|
|
||||||
uint8_t InputsController::switch_touch_state() {
|
|
||||||
xSemaphoreTake(expander_peripheral_singleton.state_mutex, portMAX_DELAY);
|
|
||||||
uint8_t value = expander_peripheral_singleton.state.touch_state;
|
|
||||||
xSemaphoreGive(expander_peripheral_singleton.state_mutex);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns `true` iff there is a keypad press event waiting.
|
|
||||||
bool InputsController::has_keypad_press() {
|
|
||||||
return uxQueueMessagesWaiting(expander_peripheral_singleton.keypad_press_events) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the next keypad press event (if any).
|
|
||||||
std::optional<InputKeypadKey> InputsController::get_keypad_press() {
|
|
||||||
InputKeypadKey k;
|
|
||||||
if (xQueueReceive(expander_peripheral_singleton.keypad_press_events, &k, 0) == pdTRUE) {
|
|
||||||
return k;
|
|
||||||
}
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the next keypad press event, waiting if neccesary.
|
|
||||||
InputKeypadKey InputsController::wait_keypad_press() {
|
|
||||||
InputKeypadKey k;
|
|
||||||
xQueueReceive(expander_peripheral_singleton.keypad_press_events, &k, portMAX_DELAY);
|
|
||||||
return k;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns `true` iff there is a keypad release event waiting.
|
|
||||||
bool InputsController::has_keypad_release() {
|
|
||||||
return uxQueueMessagesWaiting(expander_peripheral_singleton.keypad_release_events) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the next keypad release event (if any).
|
|
||||||
std::optional<InputKeypadKey> InputsController::get_keypad_release() {
|
|
||||||
InputKeypadKey k;
|
|
||||||
if (xQueueReceive(expander_peripheral_singleton.keypad_release_events, &k, 0) == pdTRUE) {
|
|
||||||
return k;
|
|
||||||
}
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the next keypad release event, waiting if neccesary.
|
|
||||||
InputKeypadKey InputsController::wait_keypad_release() {
|
|
||||||
InputKeypadKey k;
|
|
||||||
xQueueReceive(expander_peripheral_singleton.keypad_release_events, &k, portMAX_DELAY);
|
|
||||||
return k;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the current state of the keypad.
|
|
||||||
uint16_t InputsController::keypad_state() {
|
|
||||||
xSemaphoreTake(expander_peripheral_singleton.state_mutex, portMAX_DELAY);
|
|
||||||
uint16_t value = expander_peripheral_singleton.state.keypad_state;
|
|
||||||
xSemaphoreGive(expander_peripheral_singleton.state_mutex);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,275 +0,0 @@
|
|||||||
#ifndef INPUTS_H
|
|
||||||
#define INPUTS_H
|
|
||||||
|
|
||||||
#include <freertos/FreeRTOS.h>
|
|
||||||
#include <freertos/queue.h>
|
|
||||||
#include <freertos/semphr.h>
|
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
#define EXPANDER_I2C_ADDR (0x7E)
|
|
||||||
#define EXPANDER_I2C_SPEED (400000)
|
|
||||||
// the actual transaction takes ~0.3ms, but for some reason a timout of ~10 or lower causes issues.
|
|
||||||
#define EXPANDER_TIMEOUT_MS (100)
|
|
||||||
|
|
||||||
#define EXPANDER_WHOAMI_VALUE (0x85)
|
|
||||||
|
|
||||||
// queue sizes
|
|
||||||
#define EXPANDER_EVENT_QUEUE_SIZE 4
|
|
||||||
#define EXPANDER_KEYPAD_QUEUE_SIZE 16
|
|
||||||
|
|
||||||
void init_expander();
|
|
||||||
|
|
||||||
/// The four buttons on the bottom half.
|
|
||||||
enum class Button: uint8_t {
|
|
||||||
B1 = 0,
|
|
||||||
B2 = 1,
|
|
||||||
B3 = 2,
|
|
||||||
B4 = 3,
|
|
||||||
GREEN = 0,
|
|
||||||
RED = 1,
|
|
||||||
YELLOW = 2,
|
|
||||||
BLUE = 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr uint8_t raw_value(Button v) { return static_cast<uint8_t>(v); }
|
|
||||||
constexpr Button button_from_raw(uint8_t raw) { return static_cast<Button>(raw & 0b11); }
|
|
||||||
|
|
||||||
/// The four switches on the bottom half.
|
|
||||||
enum class Switch: uint8_t {
|
|
||||||
S1 = 0,
|
|
||||||
S2 = 1,
|
|
||||||
S3 = 2,
|
|
||||||
S4 = 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr uint8_t raw_value(Switch v) { return static_cast<uint8_t>(v); }
|
|
||||||
constexpr Switch switch_from_raw(uint8_t raw) { return static_cast<Switch>(raw & 0b11); }
|
|
||||||
|
|
||||||
enum class TouchedReleased: uint8_t {
|
|
||||||
Released = 0,
|
|
||||||
Touched = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr uint8_t raw_value(TouchedReleased v) { return static_cast<uint8_t>(v); }
|
|
||||||
constexpr TouchedReleased touched_released_from_raw(uint8_t raw) { return static_cast<TouchedReleased>(raw & 0b1); }
|
|
||||||
|
|
||||||
/// One of the keys on the keypad.
|
|
||||||
enum class InputKeypadKey: uint8_t {
|
|
||||||
K0 = 0,
|
|
||||||
K1 = 1,
|
|
||||||
K2 = 2,
|
|
||||||
K3 = 3,
|
|
||||||
K4 = 4,
|
|
||||||
K5 = 5,
|
|
||||||
K6 = 6,
|
|
||||||
K7 = 7,
|
|
||||||
K8 = 8,
|
|
||||||
K9 = 9,
|
|
||||||
A = 10,
|
|
||||||
B = 11,
|
|
||||||
C = 12,
|
|
||||||
D = 13,
|
|
||||||
STAR = 14,
|
|
||||||
POUND = 15,
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr uint8_t raw_value(InputKeypadKey v) { return static_cast<uint8_t>(v); }
|
|
||||||
constexpr InputKeypadKey keypad_key_from_raw(uint8_t raw) { return static_cast<InputKeypadKey>(raw & 0b1111); }
|
|
||||||
|
|
||||||
constexpr char keypad_key_to_char(InputKeypadKey key) {
|
|
||||||
static constexpr char lookup[16] = {
|
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
|
||||||
'8', '9', 'A', 'B', 'C', 'D', '*', '#'
|
|
||||||
};
|
|
||||||
return lookup[static_cast<uint8_t>(key) & 0b1111];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct SwitchFlip {
|
|
||||||
private:
|
|
||||||
// [bit2: up] [bit1-0: switch]
|
|
||||||
uint8_t data;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
SwitchFlip(Switch sw, bool up)
|
|
||||||
: data((static_cast<uint8_t>(sw) & 0b11) |
|
|
||||||
((up ? 1 : 0) << 2)) {}
|
|
||||||
|
|
||||||
// Default constructor
|
|
||||||
SwitchFlip() : data(0) {}
|
|
||||||
|
|
||||||
// Raw value constructor
|
|
||||||
explicit SwitchFlip(uint8_t raw_data) : data(raw_data) {}
|
|
||||||
|
|
||||||
// Raw value getter
|
|
||||||
uint8_t raw() const { return data; }
|
|
||||||
|
|
||||||
// Getters
|
|
||||||
Switch get_switch() const {
|
|
||||||
return static_cast<Switch>(data & 0b11);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_up() const {
|
|
||||||
return (data >> 2) & 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setters
|
|
||||||
void set_switch(Switch sw) {
|
|
||||||
data = (data & ~0b11) | (static_cast<uint8_t>(sw) & 0b11);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_up(bool up) {
|
|
||||||
data = (data & ~(1 << 2)) | ((up ? 1 : 0) << 2);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
static_assert(sizeof(SwitchFlip) == 1);
|
|
||||||
|
|
||||||
struct SwitchTouch {
|
|
||||||
private:
|
|
||||||
// [bit2: touched] [bit1-0: switch]
|
|
||||||
uint8_t data;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
SwitchTouch(Switch sw, bool touched)
|
|
||||||
: data((static_cast<uint8_t>(sw) & 0b11) |
|
|
||||||
((touched ? 1 : 0) << 2)) {}
|
|
||||||
|
|
||||||
// Default constructor
|
|
||||||
SwitchTouch() : data(0) {}
|
|
||||||
|
|
||||||
// Raw value constructor
|
|
||||||
explicit SwitchTouch(uint8_t raw_data) : data(raw_data) {}
|
|
||||||
|
|
||||||
// Raw value getter
|
|
||||||
uint8_t raw() const { return data; }
|
|
||||||
|
|
||||||
// Getters
|
|
||||||
Switch get_switch() const {
|
|
||||||
return static_cast<Switch>(data & 0b11);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_touched() const {
|
|
||||||
return (data >> 2) & 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setters
|
|
||||||
void set_switch(Switch sw) {
|
|
||||||
data = (data & ~0b11) | (static_cast<uint8_t>(sw) & 0b11);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_touched(bool touched) {
|
|
||||||
data = (data & ~(1 << 2)) | ((touched ? 1 : 0) << 2);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
static_assert(sizeof(SwitchTouch) == 1);
|
|
||||||
|
|
||||||
struct ButtonOrSwitch {
|
|
||||||
private:
|
|
||||||
// [bit2: is_switch] [bit1-0: number]
|
|
||||||
uint8_t data;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Constructor
|
|
||||||
ButtonOrSwitch(uint8_t number, bool is_switch)
|
|
||||||
: data((number & 0b11) |
|
|
||||||
((is_switch ? 1 : 0) << 2)) {}
|
|
||||||
|
|
||||||
ButtonOrSwitch() : data(0) {}
|
|
||||||
|
|
||||||
// Raw value constructor
|
|
||||||
explicit ButtonOrSwitch(uint8_t raw_data) : data(raw_data) {}
|
|
||||||
|
|
||||||
// Raw value getter
|
|
||||||
uint8_t raw() const { return data; }
|
|
||||||
|
|
||||||
// Getters
|
|
||||||
uint8_t number() const {
|
|
||||||
return data & 0b11;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_switch() const {
|
|
||||||
return (data >> 2) & 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setters
|
|
||||||
void set_number(uint8_t number) {
|
|
||||||
data = (data & ~0b11) | (number & 0b11);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_is_switch(bool is_switch) {
|
|
||||||
data = (data & ~(1 << 2)) | ((is_switch ? 1 : 0) << 2);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
static_assert(sizeof(ButtonOrSwitch) == 1);
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief The state of the bottom half of the box.
|
|
||||||
struct InputsState {
|
|
||||||
/// The touch state of the switches in the lower 4 bits.
|
|
||||||
/// The touch pad state in bit 4.
|
|
||||||
uint8_t touch_state;
|
|
||||||
/// The current state of the buttons in the lower 4 bits.
|
|
||||||
uint8_t button_state;
|
|
||||||
/// The current state of the switches. Up switches are stored
|
|
||||||
/// in the lower 4 bits, switches that are down are stored in
|
|
||||||
/// the upper 4 bits. If switches are in the middle, the
|
|
||||||
/// corresponding bit will be `0` in the upper and lower 4.
|
|
||||||
uint8_t switch_state;
|
|
||||||
/// The state of the keypad.
|
|
||||||
uint16_t keypad_state;
|
|
||||||
/// The sensitivity of the `hal` value to auto update.
|
|
||||||
uint16_t hal_sense;
|
|
||||||
/// The sensitivity of the `close_hal` value to auto update.
|
|
||||||
uint16_t close_hal_sense;
|
|
||||||
/// A non-exact hal value reading.
|
|
||||||
/// This only gets updated when it changes by `hal_sense`
|
|
||||||
uint16_t hal;
|
|
||||||
/// A non-exact hal value reading.
|
|
||||||
/// This only gets updated when it changes by `close_hal_sense`
|
|
||||||
uint16_t close_hal;
|
|
||||||
/// The RFID card that was presented last.
|
|
||||||
uint32_t rfid_state;
|
|
||||||
|
|
||||||
InputsState() : touch_state(0), button_state(0), switch_state(0), keypad_state(0), hal_sense(0), close_hal_sense(0), hal(0), close_hal(0), rfid_state(0) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class InputsController {
|
|
||||||
public:
|
|
||||||
static void clear_all_events();
|
|
||||||
|
|
||||||
static InputsState get_input_state();
|
|
||||||
|
|
||||||
static bool has_button_press();
|
|
||||||
static std::optional<Button> get_button_press();
|
|
||||||
static Button wait_button_press();
|
|
||||||
static uint8_t button_state();
|
|
||||||
|
|
||||||
static bool has_button_release();
|
|
||||||
static std::optional<Button> get_button_release();
|
|
||||||
static Button wait_button_release();
|
|
||||||
|
|
||||||
static bool has_switch_flip();
|
|
||||||
static std::optional<SwitchFlip> get_switch_flip();
|
|
||||||
static SwitchFlip wait_switch_flip();
|
|
||||||
static uint8_t switch_state();
|
|
||||||
|
|
||||||
static bool has_switch_touch();
|
|
||||||
static std::optional<SwitchTouch> get_switch_touch();
|
|
||||||
static SwitchTouch wait_switch_touch();
|
|
||||||
static uint8_t switch_touch_state();
|
|
||||||
|
|
||||||
static bool has_keypad_press();
|
|
||||||
static std::optional<InputKeypadKey> get_keypad_press();
|
|
||||||
static InputKeypadKey wait_keypad_press();
|
|
||||||
|
|
||||||
static bool has_keypad_release();
|
|
||||||
static std::optional<InputKeypadKey> get_keypad_release();
|
|
||||||
static InputKeypadKey wait_keypad_release();
|
|
||||||
static uint16_t keypad_state();
|
|
||||||
|
|
||||||
// TODO: impl and add the hal and RFID stuff
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // INPUTS_H
|
|
||||||
+2
-40
@@ -1,33 +1,11 @@
|
|||||||
#include "leds.h"
|
#include "leds.h"
|
||||||
#include "led_strip.h"
|
#include "led_strip.h"
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
#include "state_tracking.h"
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
static const char* TAG = "leds";
|
static const char* TAG = "leds";
|
||||||
|
|
||||||
static led_strip_handle_t leds;
|
static led_strip_handle_t leds;
|
||||||
|
|
||||||
static bool replay_handler(const char* event, char* arg) {
|
|
||||||
if (strcmp(event, "LED_SET") == 0) {
|
|
||||||
uint32_t led = atoi(strtok(arg, ","));
|
|
||||||
uint32_t color = atoi(strtok(NULL, ","));
|
|
||||||
ESP_LOGI("leds", "color: %ld", color);
|
|
||||||
led_set(led, color);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "LED_FLUSH") == 0) {
|
|
||||||
leds_flush();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "LED_CLR") == 0) {
|
|
||||||
leds_clear();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_leds() {
|
void init_leds() {
|
||||||
ESP_LOGI(TAG, "Initializing LEDs...");
|
ESP_LOGI(TAG, "Initializing LEDs...");
|
||||||
|
|
||||||
@@ -46,20 +24,11 @@ void init_leds() {
|
|||||||
|
|
||||||
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &leds));
|
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &leds));
|
||||||
|
|
||||||
register_replay_fn(replay_handler);
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "LEDs initialized!");
|
ESP_LOGI(TAG, "LEDs initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_set(uint32_t led, uint8_t r, uint8_t g, uint8_t b) {
|
void led_set(uint32_t led, uint8_t r, uint8_t g, uint8_t b) {
|
||||||
led_strip_set_pixel(leds, led, r, g, b);
|
led_strip_set_pixel(leds, led, r, g, b);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
char buf[32];
|
|
||||||
uint32_t color = (r << 16) | (g << 8) | b;
|
|
||||||
sprintf(buf, "%ld,%ld", led, color);
|
|
||||||
event_occured("LED_SET", buf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_set(uint32_t led, uint32_t color) {
|
void led_set(uint32_t led, uint32_t color) {
|
||||||
@@ -68,16 +37,9 @@ void led_set(uint32_t led, uint32_t color) {
|
|||||||
|
|
||||||
void leds_flush() {
|
void leds_flush() {
|
||||||
led_strip_refresh(leds);
|
led_strip_refresh(leds);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("LED_FLUSH", NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void leds_clear() {
|
void leds_clear()
|
||||||
|
{
|
||||||
led_strip_clear(leds);
|
led_strip_clear(leds);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("LED_CLR", NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-14
@@ -1,23 +1,10 @@
|
|||||||
#ifndef LEDS_H
|
#ifndef LEDS_H
|
||||||
#define LEDS_H
|
#define LEDS_H
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define LED_COUNT 21
|
#define LED_COUNT 21
|
||||||
|
#define NEOPIXEL_PIN GPIO_NUM_7
|
||||||
#ifdef CONTROL_REV_2_0
|
|
||||||
#define NEOPIXEL_PIN GPIO_NUM_0
|
|
||||||
#endif
|
|
||||||
#ifdef CONTROL_REV_2_1
|
|
||||||
#define NEOPIXEL_PIN GPIO_NUM_21
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CONTROL_REV_2_0
|
|
||||||
#ifndef CONTROL_REV_2_1
|
|
||||||
#error "define rev2.0 or rev2.1"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
// 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution)
|
// 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution)
|
||||||
#define LED_STRIP_RMT_RES_HZ (10 * 1000 * 1000)
|
#define LED_STRIP_RMT_RES_HZ (10 * 1000 * 1000)
|
||||||
|
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
#ifndef PINS_H
|
|
||||||
#define PINS_H
|
|
||||||
|
|
||||||
#include "driver/gpio.h"
|
|
||||||
|
|
||||||
// ONLY INPUTS.HPP uses this file
|
|
||||||
|
|
||||||
#define PIN_SDA (GPIO_NUM_7)
|
|
||||||
#define PIN_SCL (GPIO_NUM_15)
|
|
||||||
|
|
||||||
#define PIN_LCD_MISO (GPIO_NUM_16)
|
|
||||||
#define PIN_LCD_MOSI (GPIO_NUM_17)
|
|
||||||
#define PIN_LCD_CLK (GPIO_NUM_18)
|
|
||||||
#define PIN_LCD_RS (GPIO_NUM_8)
|
|
||||||
#define PIN_LCD_RST (GPIO_NUM_9)
|
|
||||||
|
|
||||||
#define PIN_USB_DM (GPIO_NUM_19)
|
|
||||||
#define PIN_USB_DP (GPIO_NUM_20)
|
|
||||||
|
|
||||||
#define PIN_I2S_DAT (GPIO_NUM_3)
|
|
||||||
#define PIN_I2S_BCLK (GPIO_NUM_11)
|
|
||||||
#define PIN_I2S_LRCLK (GPIO_NUM_12)
|
|
||||||
|
|
||||||
#define PIN_SSEG_DAT (GPIO_NUM_46)
|
|
||||||
#define PIN_SSEG_CLK (GPIO_NUM_48)
|
|
||||||
|
|
||||||
#define PIN_MPU_INT (GPIO_NUM_10)
|
|
||||||
#define PIN_EXPANDER_INT (GPIO_NUM_13)
|
|
||||||
|
|
||||||
#define PIN_IR_RCV (GPIO_NUM_14)
|
|
||||||
|
|
||||||
// #define PIN_NEOPIXEL (GPIO_NUM_21) // Rev 2.1
|
|
||||||
#define PIN_NEOPIXEL (GPIO_NUM_0) // Rev 2.0
|
|
||||||
|
|
||||||
#define PIN_SD_DAT0 (GPIO_NUM_38)
|
|
||||||
#define PIN_SD_DAT1 (GPIO_NUM_47)
|
|
||||||
#define PIN_SD_DAT2 (GPIO_NUM_42)
|
|
||||||
#define PIN_SD_DAT3 (GPIO_NUM_41)
|
|
||||||
#define PIN_SD_CMD (GPIO_NUM_40)
|
|
||||||
#define PIN_SD_CLK (GPIO_NUM_39)
|
|
||||||
|
|
||||||
#define PIN_PERH0 (GPIO_NUM_6)
|
|
||||||
#define PIN_PERH1 (GPIO_NUM_5)
|
|
||||||
#define PIN_PERH2 (GPIO_NUM_4)
|
|
||||||
#define PIN_PERH3 (GPIO_NUM_2)
|
|
||||||
#define PIN_PERH4 (GPIO_NUM_1)
|
|
||||||
|
|
||||||
#endif // PINS_H
|
|
||||||
+6
-13
@@ -1,7 +1,6 @@
|
|||||||
#ifndef SD_H
|
#ifndef SD_H
|
||||||
#define SD_H
|
#define SD_H
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/unistd.h>
|
#include <sys/unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@@ -13,18 +12,12 @@
|
|||||||
|
|
||||||
extern sdmmc_card_t *card;
|
extern sdmmc_card_t *card;
|
||||||
|
|
||||||
#define SD_PIN_CLK GPIO_NUM_39
|
#define SD_PIN_CLK GPIO_NUM_48
|
||||||
#define SD_PIN_CMD GPIO_NUM_40
|
#define SD_PIN_CMD GPIO_NUM_45
|
||||||
#define SD_PIN_D0 GPIO_NUM_38
|
#define SD_PIN_D0 GPIO_NUM_47
|
||||||
#define SD_PIN_D2 GPIO_NUM_42
|
#define SD_PIN_D1 GPIO_NUM_21
|
||||||
#define SD_PIN_D3 GPIO_NUM_41
|
#define SD_PIN_D2 GPIO_NUM_39
|
||||||
|
#define SD_PIN_D3 GPIO_NUM_38
|
||||||
#ifdef CONTROL_REV_2_0
|
|
||||||
#define SD_PIN_D1 GPIO_NUM_45
|
|
||||||
#endif
|
|
||||||
#ifdef CONTROL_REV_2_1
|
|
||||||
#define SD_PIN_D1 GPIO_NUM_47
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// @brief Initializes the SD card
|
/// @brief Initializes the SD card
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "speaker.h"
|
#include "speaker.h"
|
||||||
#include "state_tracking.h"
|
|
||||||
|
|
||||||
static const char *TAG = "speaker";
|
static const char *TAG = "speaker";
|
||||||
|
|
||||||
@@ -30,27 +29,6 @@ QueueHandle_t play_clip_queue;
|
|||||||
/// The clips that are currently playing
|
/// The clips that are currently playing
|
||||||
std::vector<playing_audio_clip_t> playing_clips;
|
std::vector<playing_audio_clip_t> playing_clips;
|
||||||
|
|
||||||
static bool replay_handler(const char* event, char* arg) {
|
|
||||||
if (strcmp(event, "PLAY_WAV") == 0) {
|
|
||||||
char* file_name = strtok(arg, ":");
|
|
||||||
char* play_immediately_str = strtok(NULL, ":");
|
|
||||||
char* repeat_str = strtok(NULL, ":");
|
|
||||||
char* prescaler_str = strtok(NULL, ":");
|
|
||||||
|
|
||||||
bool play_immediately = strcmp(play_immediately_str, "true") == 0;
|
|
||||||
bool repeat = strcmp(repeat_str, "true") == 0;
|
|
||||||
uint8_t prescaler = atoi(prescaler_str);
|
|
||||||
play_clip_wav(file_name, play_immediately, repeat, prescaler, 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "STOP_WAV") == 0) {
|
|
||||||
stop_clip(arg, 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool push_clip(audio_clip_t clip) {
|
static bool push_clip(audio_clip_t clip) {
|
||||||
ESP_LOGD(TAG, "playing %s", clip.file_name);
|
ESP_LOGD(TAG, "playing %s", clip.file_name);
|
||||||
FILE* fh = fopen(clip.file_name, "rb");
|
FILE* fh = fopen(clip.file_name, "rb");
|
||||||
@@ -178,7 +156,7 @@ static void speaker_task(void* arg) {
|
|||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool play_clip_wav(const char* file_name, bool play_immediately, bool repeat, uint8_t prescaler, TickType_t ticks_to_wait) {
|
bool play_clip_wav(const char* file_name, bool play_immediatly, bool repeat, uint8_t prescaler, TickType_t ticks_to_wait) {
|
||||||
// clone the passed in string to the heap.
|
// clone the passed in string to the heap.
|
||||||
size_t len = strlen(file_name);
|
size_t len = strlen(file_name);
|
||||||
char* dynamic_file_name = (char*) malloc(len+1);
|
char* dynamic_file_name = (char*) malloc(len+1);
|
||||||
@@ -188,16 +166,10 @@ bool play_clip_wav(const char* file_name, bool play_immediately, bool repeat, ui
|
|||||||
.file_name = dynamic_file_name,
|
.file_name = dynamic_file_name,
|
||||||
.prescaler = prescaler,
|
.prescaler = prescaler,
|
||||||
.repeat = repeat,
|
.repeat = repeat,
|
||||||
.play_immediatly = play_immediately,
|
.play_immediatly = play_immediatly,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
if (play_immediatly) {
|
||||||
char buf[64];
|
|
||||||
sprintf(buf, "%s:%d:%d:%d", file_name, play_immediately, repeat, prescaler);
|
|
||||||
event_occured("PLAY_WAV", buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (play_immediately) {
|
|
||||||
return xQueueSendToFront(play_clip_queue, &clip, ticks_to_wait) == pdTRUE;
|
return xQueueSendToFront(play_clip_queue, &clip, ticks_to_wait) == pdTRUE;
|
||||||
}
|
}
|
||||||
return xQueueSend(play_clip_queue, &clip, ticks_to_wait) == pdTRUE;
|
return xQueueSend(play_clip_queue, &clip, ticks_to_wait) == pdTRUE;
|
||||||
@@ -209,10 +181,6 @@ bool stop_clip(const char* file_name, TickType_t ticks_to_wait) {
|
|||||||
char* dynamic_file_name = (char*) malloc(len+1);
|
char* dynamic_file_name = (char*) malloc(len+1);
|
||||||
strcpy(dynamic_file_name, file_name);
|
strcpy(dynamic_file_name, file_name);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("STOP_WAV", file_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return xQueueSend(stop_clip_queue, &dynamic_file_name, ticks_to_wait) == pdTRUE;
|
return xQueueSend(stop_clip_queue, &dynamic_file_name, ticks_to_wait) == pdTRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,9 +221,7 @@ void init_speaker(void) {
|
|||||||
// start task
|
// start task
|
||||||
xTaskCreate(speaker_task, "play_audio", 4096, NULL, 5, NULL);
|
xTaskCreate(speaker_task, "play_audio", 4096, NULL, 5, NULL);
|
||||||
|
|
||||||
play_clip_wav(MOUNT_POINT "/startup.wav", true, false, 4, 0);
|
play_clip_wav(MOUNT_POINT "/startup.wav", true, false, 3, 0);
|
||||||
|
|
||||||
register_replay_fn(replay_handler);
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Speaker initialized!");
|
ESP_LOGI(TAG, "Speaker initialized!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "sd.h"
|
#include "sd.h"
|
||||||
|
|
||||||
#define SPEAKER_PIN_BCLK GPIO_NUM_11
|
#define SPEAKER_PIN_BCLK GPIO_NUM_46
|
||||||
#define SPEAKER_PIN_WS GPIO_NUM_12
|
#define SPEAKER_PIN_WS GPIO_NUM_9
|
||||||
#define SPEAKER_PIN_DOUT GPIO_NUM_3
|
#define SPEAKER_PIN_DOUT GPIO_NUM_3
|
||||||
#define SAMPLE_RATE 44100
|
#define SAMPLE_RATE 44100
|
||||||
// The maximum number of clips that can be queued at one time.
|
// The maximum number of clips that can be queued at one time.
|
||||||
@@ -52,7 +52,7 @@ void init_speaker();
|
|||||||
/// loud. Useful for loud audio files.
|
/// loud. Useful for loud audio files.
|
||||||
/// @param ticks_to_wait The number of ticks to wait if the queue is full.
|
/// @param ticks_to_wait The number of ticks to wait if the queue is full.
|
||||||
/// @return true if the clip was added to the queue.
|
/// @return true if the clip was added to the queue.
|
||||||
bool play_clip_wav(const char* file_name, bool play_immediately, bool repeat, uint8_t prescaler, TickType_t ticks_to_wait);
|
bool play_clip_wav(const char* file_name, bool play_immediatly, bool repeat, uint8_t prescaler, TickType_t ticks_to_wait);
|
||||||
|
|
||||||
/// @brief Stops an audio clip from playing.
|
/// @brief Stops an audio clip from playing.
|
||||||
/// @param file_name The file name of the audio clip that was played.
|
/// @param file_name The file name of the audio clip that was played.
|
||||||
|
|||||||
+1
-82
@@ -1,62 +1,15 @@
|
|||||||
#include "sseg.h"
|
#include "sseg.h"
|
||||||
#include <esp_log.h>
|
#include "esp_log.h"
|
||||||
#include "state_tracking.h"
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
TM1640* sseg = nullptr;
|
TM1640* sseg = nullptr;
|
||||||
|
|
||||||
static const char *TAG = "sseg";
|
static const char *TAG = "sseg";
|
||||||
|
|
||||||
static bool replay_handler(const char* event, char* arg) {
|
|
||||||
if (strcmp(event, "SSEG_G_RAW") == 0) {
|
|
||||||
uint8_t segments[4];
|
|
||||||
segments[0] = atoi(strtok(arg, ","));
|
|
||||||
for (int i = 1; i < 4; i++) {
|
|
||||||
segments[i] = atoi(strtok(NULL, ","));
|
|
||||||
}
|
|
||||||
set_game_sseg_raw(segments);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "SSEG_G_CLR") == 0) {
|
|
||||||
clear_game_sseg();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "SSEG_M_RAW") == 0) {
|
|
||||||
uint8_t segments[4];
|
|
||||||
segments[0] = atoi(strtok(arg, ","));
|
|
||||||
for (int i = 1; i < 4; i++) {
|
|
||||||
segments[i] = atoi(strtok(NULL, ","));
|
|
||||||
}
|
|
||||||
set_module_sseg_raw(segments);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "SSEG_M_CLR") == 0) {
|
|
||||||
clear_module_sseg();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "SSEG_G") == 0) {
|
|
||||||
uint32_t value = atoi(strtok(arg, ","));
|
|
||||||
uint8_t dot_pos = atoi(strtok(NULL, ","));
|
|
||||||
set_game_sseg_num(value, dot_pos);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strcmp(event, "SSEG_M") == 0) {
|
|
||||||
uint32_t value = atoi(strtok(arg, ","));
|
|
||||||
uint8_t dot_pos = atoi(strtok(NULL, ","));
|
|
||||||
set_module_sseg_num(value, dot_pos);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_sseg() {
|
void init_sseg() {
|
||||||
ESP_LOGI(TAG, "Initializing sseg...");
|
ESP_LOGI(TAG, "Initializing sseg...");
|
||||||
|
|
||||||
sseg = new TM1640(SSEG_PIN_DATA, SSEG_PIN_CLK, 8);
|
sseg = new TM1640(SSEG_PIN_DATA, SSEG_PIN_CLK, 8);
|
||||||
|
|
||||||
register_replay_fn(replay_handler);
|
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Sseg initialized!");
|
ESP_LOGI(TAG, "Sseg initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,22 +18,12 @@ void set_game_sseg_raw(const uint8_t* segments) {
|
|||||||
sseg->setSegments(segments[1], 1);
|
sseg->setSegments(segments[1], 1);
|
||||||
sseg->setSegments(segments[2], 2);
|
sseg->setSegments(segments[2], 2);
|
||||||
sseg->setSegments(segments[3], 3);
|
sseg->setSegments(segments[3], 3);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
char buf[32];
|
|
||||||
sprintf(buf, "%d,%d,%d,%d", segments[0], segments[1], segments[2], segments[3]);
|
|
||||||
event_occured("SSEG_G_RAW", buf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void clear_game_sseg() {
|
void clear_game_sseg() {
|
||||||
sseg->setSegments(0, 0);
|
sseg->setSegments(0, 0);
|
||||||
sseg->setSegments(0, 1);
|
sseg->setSegments(0, 1);
|
||||||
sseg->setSegments(0, 2);
|
sseg->setSegments(0, 2);
|
||||||
sseg->setSegments(0, 3);
|
sseg->setSegments(0, 3);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("SSEG_G_CLR", NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_module_sseg_raw(const uint8_t* segments) {
|
void set_module_sseg_raw(const uint8_t* segments) {
|
||||||
@@ -88,12 +31,6 @@ void set_module_sseg_raw(const uint8_t* segments) {
|
|||||||
sseg->setSegments(segments[1], 5);
|
sseg->setSegments(segments[1], 5);
|
||||||
sseg->setSegments(segments[2], 6);
|
sseg->setSegments(segments[2], 6);
|
||||||
sseg->setSegments(segments[3], 7);
|
sseg->setSegments(segments[3], 7);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
char buf[32];
|
|
||||||
sprintf(buf, "%d,%d,%d,%d", segments[0], segments[1], segments[2], segments[3]);
|
|
||||||
event_occured("SSEG_M_RAW", buf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_module_sseg() {
|
void clear_module_sseg() {
|
||||||
@@ -101,38 +38,20 @@ void clear_module_sseg() {
|
|||||||
sseg->setSegments(0, 5);
|
sseg->setSegments(0, 5);
|
||||||
sseg->setSegments(0, 6);
|
sseg->setSegments(0, 6);
|
||||||
sseg->setSegments(0, 7);
|
sseg->setSegments(0, 7);
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
event_occured("SSEG_M_CLR", NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_game_sseg_num(uint32_t value, uint8_t dot_pos) {
|
void set_game_sseg_num(uint32_t value, uint8_t dot_pos) {
|
||||||
uint32_t initial_value = value;
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
auto idx = value % 10;
|
auto idx = value % 10;
|
||||||
sseg->sendChar(3-i, TM16XX_NUMBER_FONT[idx], i == dot_pos);
|
sseg->sendChar(3-i, TM16XX_NUMBER_FONT[idx], i == dot_pos);
|
||||||
value = value / 10;
|
value = value / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
char buf[16];
|
|
||||||
sprintf(buf, "%ld,%d", initial_value, dot_pos);
|
|
||||||
event_occured("SSEG_G", buf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_module_sseg_num(uint32_t value, uint8_t dot_pos) {
|
void set_module_sseg_num(uint32_t value, uint8_t dot_pos) {
|
||||||
uint32_t initial_value = value;
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
auto idx = value % 10;
|
auto idx = value % 10;
|
||||||
sseg->sendChar(7-i, TM16XX_NUMBER_FONT[idx], i == dot_pos);
|
sseg->sendChar(7-i, TM16XX_NUMBER_FONT[idx], i == dot_pos);
|
||||||
value = value / 10;
|
value = value / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
char buf[16];
|
|
||||||
sprintf(buf, "%ld,%d", initial_value, dot_pos);
|
|
||||||
event_occured("SSEG_M", buf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -4,8 +4,8 @@
|
|||||||
#include "TM1640/TM1640.h"
|
#include "TM1640/TM1640.h"
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
|
|
||||||
#define SSEG_PIN_DATA GPIO_NUM_46
|
#define SSEG_PIN_DATA GPIO_NUM_10
|
||||||
#define SSEG_PIN_CLK GPIO_NUM_48
|
#define SSEG_PIN_CLK GPIO_NUM_11
|
||||||
|
|
||||||
extern TM1640* sseg;
|
extern TM1640* sseg;
|
||||||
|
|
||||||
|
|||||||
@@ -1,223 +0,0 @@
|
|||||||
#include "state_tracking.h"
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
static const char* PLAYBACK_TAG = "playback";
|
|
||||||
|
|
||||||
enum state_t {
|
|
||||||
STATE_IDLE = 0,
|
|
||||||
STATE_RECORDING = 1,
|
|
||||||
STATE_PLAYBACK = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::vector<bool(*)(const char*, char*)> replay_fns;
|
|
||||||
|
|
||||||
static bool should_close_recording_stream;
|
|
||||||
static FILE* recording_stream;
|
|
||||||
static uint32_t recording_start_time;
|
|
||||||
TaskHandle_t flush_file_task_handle;
|
|
||||||
|
|
||||||
static bool should_close_playback_stream;
|
|
||||||
static FILE* playback_stream;
|
|
||||||
static uint32_t playback_start_time;
|
|
||||||
TaskHandle_t playback_task_handle;
|
|
||||||
|
|
||||||
static volatile state_t state = STATE_IDLE;
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Periodically flushes and syncs (if neccesary) the output stream.
|
|
||||||
/// @param arg unused.
|
|
||||||
static void flush_file_task(void* arg) {
|
|
||||||
while (state == STATE_RECORDING && recording_stream != nullptr) {
|
|
||||||
fflush(recording_stream);
|
|
||||||
|
|
||||||
int fd = fileno(recording_stream);
|
|
||||||
if (fd != -1) {
|
|
||||||
fsync(fd);
|
|
||||||
}
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(5000));
|
|
||||||
}
|
|
||||||
|
|
||||||
flush_file_task_handle = NULL;
|
|
||||||
vTaskDelete(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void playback_task(void* arg) {
|
|
||||||
const size_t size = 16*1024;
|
|
||||||
char* buf = (char*) malloc(size*sizeof(char));
|
|
||||||
if (buf == nullptr) {
|
|
||||||
ESP_LOGE(PLAYBACK_TAG, "buf alloc failure");
|
|
||||||
vTaskDelete(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (state == STATE_PLAYBACK && playback_stream != nullptr) {
|
|
||||||
char* ret = fgets(buf, size, playback_stream);
|
|
||||||
if (ret == nullptr) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (buf[0] == '\0') {
|
|
||||||
ESP_LOGI(PLAYBACK_TAG, "playback done");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// get rid of the '\n' and possibly '\r' in the string
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
if (buf[i] == '\0') break;
|
|
||||||
if (buf[i] == '\r' || buf[i] == '\n') {
|
|
||||||
buf[i] = '\0';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ESP_LOGI(PLAYBACK_TAG, "handling: %s", buf);
|
|
||||||
|
|
||||||
// look for a comma, indicating the end of the "ticks" part
|
|
||||||
// TODO: replace with strtok
|
|
||||||
size_t comma_pos = 0;
|
|
||||||
for (int i = 0; i < 11; i++) {
|
|
||||||
if (buf[i] == ',') {
|
|
||||||
comma_pos = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (comma_pos == 0) {
|
|
||||||
ESP_LOGE(PLAYBACK_TAG, "Failed to find comma in playback line");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf[comma_pos] = '\0';
|
|
||||||
uint32_t tick = atoi(buf);
|
|
||||||
|
|
||||||
// now look for the colon to indicate the end of the event name
|
|
||||||
size_t colon_pos = 0;
|
|
||||||
int i = comma_pos + 1; // start looking right after the comma
|
|
||||||
while (i < size) {
|
|
||||||
if (buf[i] == ':') {
|
|
||||||
colon_pos = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
if (colon_pos == 0) {
|
|
||||||
ESP_LOGE(PLAYBACK_TAG, "Failed to find colon in playback line");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf[colon_pos] = '\0';
|
|
||||||
char* event_name = buf + (comma_pos + 1);
|
|
||||||
char* arg = buf + (colon_pos + 1);
|
|
||||||
|
|
||||||
int32_t ticks_to_wait = ((int32_t) tick) - (int32_t)(xTaskGetTickCount() - playback_start_time);
|
|
||||||
|
|
||||||
if (ticks_to_wait < 0) {
|
|
||||||
ESP_LOGW(PLAYBACK_TAG, "Playback is behind by %ld ticks!", ticks_to_wait);
|
|
||||||
}
|
|
||||||
if (ticks_to_wait > 0) {
|
|
||||||
vTaskDelay(ticks_to_wait);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool matched = false;
|
|
||||||
for (const auto& fn : replay_fns) {
|
|
||||||
matched = (fn)(event_name, arg);
|
|
||||||
if (matched) break;
|
|
||||||
}
|
|
||||||
if (!matched) {
|
|
||||||
ESP_LOGW(PLAYBACK_TAG, "Failed to match event: %s!", event_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(buf);
|
|
||||||
playback_task_handle = NULL;
|
|
||||||
|
|
||||||
stop_playback();
|
|
||||||
vTaskDelete(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void register_replay_fn(bool (*replay_fn)(const char*, char*)) {
|
|
||||||
replay_fns.push_back(replay_fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
void event_occured(const char* name, const char* arg) {
|
|
||||||
if (state != STATE_RECORDING) return;
|
|
||||||
if (name == nullptr) return;
|
|
||||||
if (recording_stream == nullptr) {
|
|
||||||
ESP_LOGE("state_tracking", "We are in state recording, but recording stream is null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
arg = (arg == nullptr) ? "" : arg;
|
|
||||||
uint32_t ticks = xTaskGetTickCount() - recording_start_time;
|
|
||||||
fprintf(recording_stream, "%ld,%s:%s\n", ticks, name, (arg == nullptr) ? "" : arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool set_recording_source(FILE* stream, bool should_close) {
|
|
||||||
if (state == STATE_RECORDING) return false;
|
|
||||||
|
|
||||||
recording_stream = stream;
|
|
||||||
should_close_recording_stream = should_close;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool set_playback_source(FILE* stream, bool should_close) {
|
|
||||||
if (state == STATE_PLAYBACK) return false;
|
|
||||||
|
|
||||||
playback_stream = stream;
|
|
||||||
should_close_playback_stream = should_close;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool start_recording() {
|
|
||||||
if (state != STATE_IDLE) return false;
|
|
||||||
if (recording_stream == nullptr) return false;
|
|
||||||
|
|
||||||
state = STATE_RECORDING;
|
|
||||||
recording_start_time = xTaskGetTickCount();
|
|
||||||
xTaskCreate(flush_file_task, "flush_recording", 2048, NULL, 2, &flush_file_task_handle);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool stop_recording() {
|
|
||||||
if (state != STATE_RECORDING) return false;
|
|
||||||
|
|
||||||
state = STATE_IDLE;
|
|
||||||
fflush(recording_stream);
|
|
||||||
if (should_close_recording_stream) {
|
|
||||||
fclose(recording_stream);
|
|
||||||
recording_stream = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flush_file_task_handle != nullptr) {
|
|
||||||
vTaskDelete(flush_file_task_handle);
|
|
||||||
flush_file_task_handle = NULL;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool start_playback() {
|
|
||||||
if (state != STATE_IDLE) return false;
|
|
||||||
if (playback_stream == nullptr) return false;
|
|
||||||
|
|
||||||
state = STATE_PLAYBACK;
|
|
||||||
playback_start_time = xTaskGetTickCount();
|
|
||||||
xTaskCreate(playback_task, "playback", 4096, NULL, 2, &playback_task_handle);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool stop_playback() {
|
|
||||||
if (state != STATE_PLAYBACK) return false;
|
|
||||||
|
|
||||||
state = STATE_IDLE;
|
|
||||||
if (should_close_playback_stream) {
|
|
||||||
fclose(playback_stream);
|
|
||||||
playback_stream = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (playback_task_handle != nullptr) {
|
|
||||||
// TODO: NO!! This leaks the malloc. Instead, use a queue to request a graceful stop
|
|
||||||
vTaskDelete(playback_task_handle);
|
|
||||||
playback_task_handle = NULL;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_state_tracking() {
|
|
||||||
return state == STATE_RECORDING;
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
#ifndef STATE_TRACKING_H
|
|
||||||
#define STATE_TRACKING_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "esp_vfs_fat.h"
|
|
||||||
|
|
||||||
/// @brief Registers function to be called on replay.
|
|
||||||
/// @param replay_callback A function to call to playback the event.
|
|
||||||
void register_replay_fn(bool (*replay_fn)(const char*, char*));
|
|
||||||
|
|
||||||
// TODO: add one for generically responding to all events.
|
|
||||||
|
|
||||||
/// @brief Call this to indicate that the bomb state has transitioned.
|
|
||||||
/// @param name The name of the event that has occured.
|
|
||||||
/// @param arg The serialized data associated with the event.
|
|
||||||
/// This must not contain newline characters such as '\n' or '\r'
|
|
||||||
void event_occured(const char* name, const char* arg);
|
|
||||||
|
|
||||||
/// @brief Sets the recording source.
|
|
||||||
/// @param stream The stream to record to.
|
|
||||||
/// @param should_close whether or not the stream should be closed when finished.
|
|
||||||
/// @return true if the source was updated.
|
|
||||||
bool set_recording_source(FILE* stream, bool should_close);
|
|
||||||
|
|
||||||
/// @brief Sets the playback source.
|
|
||||||
/// @param stream The stream to playback from.
|
|
||||||
/// @param should_close whether or not the stream should be closed when finished.
|
|
||||||
/// @return true if the source was updated.
|
|
||||||
bool set_playback_source(FILE* stream, bool should_close);
|
|
||||||
|
|
||||||
/// @brief Starts recording to the stream specified by `set_recording_source()`.
|
|
||||||
/// @return true if starting recording is successful.
|
|
||||||
bool start_recording();
|
|
||||||
|
|
||||||
/// @brief Stops recording the state.
|
|
||||||
/// @return true if stopping the recording is successful.
|
|
||||||
bool stop_recording();
|
|
||||||
|
|
||||||
/// @brief Starts playing back the recording specified by `set_playback_source()`.
|
|
||||||
/// @return true if starting playback is successful.
|
|
||||||
bool start_playback();
|
|
||||||
|
|
||||||
/// @brief Stops playing back the recording.
|
|
||||||
/// @return true if stopping the playback is successful.
|
|
||||||
bool stop_playback();
|
|
||||||
|
|
||||||
/// @brief Gets weather or not we are tracking the state
|
|
||||||
/// This can be helpful to conditionally do extra computation only
|
|
||||||
/// when we are tracking the state.
|
|
||||||
/// @return
|
|
||||||
bool is_state_tracking();
|
|
||||||
|
|
||||||
#endif /* STATE_TRACKING_H */
|
|
||||||
+11
-55
@@ -1,5 +1,4 @@
|
|||||||
#include "tft.h"
|
#include "tft.h"
|
||||||
#include "state_tracking.h"
|
|
||||||
|
|
||||||
static const char* TAG = "tft";
|
static const char* TAG = "tft";
|
||||||
|
|
||||||
@@ -17,10 +16,6 @@ static lv_style_t style_screen;
|
|||||||
|
|
||||||
SemaphoreHandle_t xGuiSemaphore;
|
SemaphoreHandle_t xGuiSemaphore;
|
||||||
|
|
||||||
static bool replay_handler(const char* event, char* arg) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool notify_lvgl_flush_ready(
|
static bool notify_lvgl_flush_ready(
|
||||||
esp_lcd_panel_io_handle_t panel_io,
|
esp_lcd_panel_io_handle_t panel_io,
|
||||||
esp_lcd_panel_io_event_data_t *edata,
|
esp_lcd_panel_io_event_data_t *edata,
|
||||||
@@ -31,14 +26,6 @@ static bool notify_lvgl_flush_ready(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char base64_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
||||||
/// Base 64 encodes a u16... sort of. This doesn't do any of the fancy padding stuff.
|
|
||||||
static void encode_base64(char* buf, size_t start_idx, uint16_t value) {
|
|
||||||
buf[start_idx+0] = base64_chars[(value >> 10) & 0x3F];
|
|
||||||
buf[start_idx+1] = base64_chars[(value >> 4) & 0x3F];
|
|
||||||
buf[start_idx+2] = base64_chars[(value << 2) & 0x3F];
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map) {
|
static void lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map) {
|
||||||
esp_lcd_panel_handle_t panel_handle = (esp_lcd_panel_handle_t) drv->user_data;
|
esp_lcd_panel_handle_t panel_handle = (esp_lcd_panel_handle_t) drv->user_data;
|
||||||
|
|
||||||
@@ -46,46 +33,7 @@ static void lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t
|
|||||||
int offsetx2 = area->x2;
|
int offsetx2 = area->x2;
|
||||||
int offsety1 = area->y1;
|
int offsety1 = area->y1;
|
||||||
int offsety2 = area->y2;
|
int offsety2 = area->y2;
|
||||||
|
|
||||||
esp_lcd_panel_draw_bitmap(panel_handle, offsetx1, offsety1, offsetx2 + 1, offsety2 + 1, color_map);
|
esp_lcd_panel_draw_bitmap(panel_handle, offsetx1, offsety1, offsetx2 + 1, offsety2 + 1, color_map);
|
||||||
|
|
||||||
// TODO: change this to be a kconfig value
|
|
||||||
#if false
|
|
||||||
|
|
||||||
if (is_state_tracking()) {
|
|
||||||
size_t size = (offsetx2 + 1 - offsetx1) * (offsety2 + 1 - offsety1) + 1;
|
|
||||||
// if (size > 1024) {
|
|
||||||
// ESP_LOGW("tft_track_state", "Write too big (%d)! truncating to 1024!", size);
|
|
||||||
// }
|
|
||||||
// size = MIN(1024, size);
|
|
||||||
|
|
||||||
|
|
||||||
// 24 bytes for the offsets
|
|
||||||
// 3 bytes per encoded color
|
|
||||||
// 1 byte for null terminator
|
|
||||||
size_t alloc_size = 24 + size * 3 + 1;
|
|
||||||
char* buf = (char*)malloc(alloc_size);
|
|
||||||
|
|
||||||
if (buf != nullptr) {
|
|
||||||
size_t initial_offset = sprintf(buf, "%d,%d,%d,%d:", offsetx1, offsety1, offsetx2 + 1, offsety2 + 1);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < size; i++) {
|
|
||||||
size_t index = initial_offset + i * 3;
|
|
||||||
|
|
||||||
// we assume that the size of the color data is 16b
|
|
||||||
static_assert(sizeof(lv_color_t) == sizeof(uint16_t), "lv_color_t must be 16b wide");
|
|
||||||
encode_base64(buf, index, color_map[i].full);
|
|
||||||
}
|
|
||||||
buf[initial_offset + (size-1) * 3 + 1] = '\0';
|
|
||||||
|
|
||||||
event_occured("TFT_W", buf);
|
|
||||||
free(buf);
|
|
||||||
} else {
|
|
||||||
ESP_LOGE("tft_track_state", "buffer alloc failed!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void IRAM_ATTR lv_tick_task(void *param) {
|
static void IRAM_ATTR lv_tick_task(void *param) {
|
||||||
@@ -202,10 +150,10 @@ static void guiTask(void *pvParameter) {
|
|||||||
ESP_ERROR_CHECK(esp_timer_create(&lvgl_tick_timer_args, &periodic_timer));
|
ESP_ERROR_CHECK(esp_timer_create(&lvgl_tick_timer_args, &periodic_timer));
|
||||||
ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, LVGL_UPDATE_PERIOD_MS * 1000));
|
ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, LVGL_UPDATE_PERIOD_MS * 1000));
|
||||||
|
|
||||||
screen = lv_scr_act();
|
screen = lv_disp_get_scr_act(NULL);
|
||||||
lv_style_init(&style_screen);
|
lv_style_init(&style_screen);
|
||||||
lv_style_set_bg_color(&style_screen, lv_color_black());
|
lv_style_set_bg_color(&style_screen, lv_color_black());
|
||||||
lv_obj_add_style(screen, &style_screen, LV_STATE_DEFAULT);
|
lv_obj_add_style(lv_scr_act(), &style_screen, LV_STATE_DEFAULT);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* Delay 1 tick (assumes FreeRTOS tick is 10ms */
|
/* Delay 1 tick (assumes FreeRTOS tick is 10ms */
|
||||||
@@ -221,6 +169,14 @@ static void guiTask(void *pvParameter) {
|
|||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tick_timer_task(void* arg) {
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
lv_task_handler();
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void init_tft() {
|
void init_tft() {
|
||||||
ESP_LOGI(TAG, "Initializing TFT...");
|
ESP_LOGI(TAG, "Initializing TFT...");
|
||||||
|
|
||||||
@@ -228,7 +184,7 @@ void init_tft() {
|
|||||||
initialize_display();
|
initialize_display();
|
||||||
xTaskCreatePinnedToCore(guiTask, "gui", 4096*2, NULL, 5, NULL, 1);
|
xTaskCreatePinnedToCore(guiTask, "gui", 4096*2, NULL, 5, NULL, 1);
|
||||||
|
|
||||||
register_replay_fn(replay_handler);
|
// xTaskCreatePinnedToCore(tick_timer_task, "tick_lvgl", 4096, NULL, 5, NULL, 1);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "TFT initialized!");
|
ESP_LOGI(TAG, "TFT initialized!");
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -44,11 +44,11 @@
|
|||||||
#define SPI_MAX_TRANSFER_SIZE 32768
|
#define SPI_MAX_TRANSFER_SIZE 32768
|
||||||
|
|
||||||
#define TFT_PIN_MOSI GPIO_NUM_17
|
#define TFT_PIN_MOSI GPIO_NUM_17
|
||||||
#define TFT_PIN_MISO GPIO_NUM_16
|
#define TFT_PIN_MISO GPIO_NUM_18
|
||||||
#define TFT_PIN_CLK GPIO_NUM_18
|
#define TFT_PIN_CLK GPIO_NUM_16
|
||||||
#define TFT_PIN_CS GPIO_NUM_NC
|
#define TFT_PIN_CS GPIO_NUM_NC
|
||||||
#define TFT_PIN_DC GPIO_NUM_8
|
#define TFT_PIN_DC GPIO_NUM_15
|
||||||
#define TFT_PIN_RESET GPIO_NUM_9
|
#define TFT_PIN_RESET GPIO_NUM_8
|
||||||
|
|
||||||
#define TFT_INVERT_COLOR false
|
#define TFT_INVERT_COLOR false
|
||||||
|
|
||||||
|
|||||||
+5
-12
@@ -1,14 +1,10 @@
|
|||||||
#include "wires.h"
|
#include "wires.h"
|
||||||
|
|
||||||
extern uint32_t current_step;
|
|
||||||
|
|
||||||
uint32_t total_strikes;
|
uint32_t total_strikes;
|
||||||
uint32_t step_strikes[N_STEPS] = {0};
|
|
||||||
uint32_t step_finish_times[N_STEPS] = {0};
|
|
||||||
|
|
||||||
static const char *TAG = "wires";
|
static const char *TAG = "wires";
|
||||||
|
|
||||||
const uint32_t STRIKE_TIME_PENALTY = 30'000;
|
static const uint32_t STRIKE_TIME_PENALTY = 30'000;
|
||||||
|
|
||||||
static bool button_state;
|
static bool button_state;
|
||||||
static bool button_pressed;
|
static bool button_pressed;
|
||||||
@@ -26,8 +22,8 @@ static void receive_button(void);
|
|||||||
void init_wires(void) {
|
void init_wires(void) {
|
||||||
i2c_config_t wires_conf = {
|
i2c_config_t wires_conf = {
|
||||||
.mode = I2C_MODE_MASTER,
|
.mode = I2C_MODE_MASTER,
|
||||||
.sda_io_num = PIN_WIRES_SDA,
|
.sda_io_num = GPIO_NUM_41,
|
||||||
.scl_io_num = PIN_WIRES_SCL,
|
.scl_io_num = GPIO_NUM_42,
|
||||||
.sda_pullup_en = GPIO_PULLUP_ENABLE,
|
.sda_pullup_en = GPIO_PULLUP_ENABLE,
|
||||||
.scl_pullup_en = GPIO_PULLUP_ENABLE,
|
.scl_pullup_en = GPIO_PULLUP_ENABLE,
|
||||||
.master = {
|
.master = {
|
||||||
@@ -35,8 +31,8 @@ void init_wires(void) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
gpio_reset_pin(PIN_WIRES_SDA);
|
gpio_reset_pin(GPIO_NUM_41);
|
||||||
gpio_reset_pin(PIN_WIRES_SCL);
|
gpio_reset_pin(GPIO_NUM_42);
|
||||||
|
|
||||||
ESP_ERROR_CHECK(i2c_param_config(WIRES_I2C_NUM, &wires_conf));
|
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));
|
ESP_ERROR_CHECK(i2c_driver_install(WIRES_I2C_NUM, wires_conf.mode, 0, 0, 0));
|
||||||
@@ -87,10 +83,7 @@ void strike(const char* reason) {
|
|||||||
ESP_LOGW("strike!", "%s", reason);
|
ESP_LOGW("strike!", "%s", reason);
|
||||||
lcd_print(0, 3, reason);
|
lcd_print(0, 3, reason);
|
||||||
time_penalty(STRIKE_TIME_PENALTY);
|
time_penalty(STRIKE_TIME_PENALTY);
|
||||||
if (current_step > 0 && current_step <= N_STEPS) {
|
|
||||||
total_strikes += 1;
|
total_strikes += 1;
|
||||||
step_strikes[current_step - 1] += 1;
|
|
||||||
}
|
|
||||||
uint8_t reg = 6;
|
uint8_t reg = 6;
|
||||||
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_to_device(WIRES_I2C_NUM, WIRES_I2C_ADDR, ®, 1, (100 / portTICK_PERIOD_MS)));
|
ESP_ERROR_CHECK_WITHOUT_ABORT(i2c_master_write_to_device(WIRES_I2C_NUM, WIRES_I2C_ADDR, ®, 1, (100 / portTICK_PERIOD_MS)));
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-15
@@ -7,28 +7,14 @@
|
|||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
#include "drivers/char_lcd.h"
|
#include "drivers/char_lcd.h"
|
||||||
#include "drivers/game_timer.h"
|
#include "drivers/game_timer.h"
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
|
#define WIRES_PIN_DELTA GPIO_NUM_2
|
||||||
#define PIN_PERH0 GPIO_NUM_6
|
|
||||||
#define PIN_PERH1 GPIO_NUM_5
|
|
||||||
#define PIN_PERH2 GPIO_NUM_4
|
|
||||||
#define PIN_PERH3 GPIO_NUM_2
|
|
||||||
#define PIN_PERH4 GPIO_NUM_1
|
|
||||||
|
|
||||||
#define WIRES_PIN_DELTA PIN_PERH3
|
|
||||||
#define PIN_WIRES_SDA PIN_PERH1
|
|
||||||
#define PIN_WIRES_SCL PIN_PERH2
|
|
||||||
#define WIRES_I2C_NUM I2C_NUM_1
|
#define WIRES_I2C_NUM I2C_NUM_1
|
||||||
#define WIRES_I2C_ADDR 125
|
#define WIRES_I2C_ADDR 125
|
||||||
|
|
||||||
#define DELTA_BIT_WIRES 0
|
#define DELTA_BIT_WIRES 0
|
||||||
#define DELTA_BIT_BUTTON 1
|
#define DELTA_BIT_BUTTON 1
|
||||||
|
|
||||||
extern const uint32_t STRIKE_TIME_PENALTY;
|
|
||||||
extern uint32_t step_strikes[N_STEPS];
|
|
||||||
extern uint32_t step_finish_times[N_STEPS];
|
|
||||||
|
|
||||||
extern uint32_t total_strikes;
|
extern uint32_t total_strikes;
|
||||||
|
|
||||||
void init_wires(void);
|
void init_wires(void);
|
||||||
|
|||||||
+19
-85
@@ -89,106 +89,40 @@ void do_star_codes(StarCodeHandler* star_codes, int star_codes_len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static lv_obj_t* old_scr;
|
|
||||||
static lv_obj_t* scr;
|
|
||||||
|
|
||||||
static lv_style_t game_results_style;
|
static lv_style_t game_results_style;
|
||||||
static lv_obj_t* overall_results_label;
|
static lv_obj_t* game_results_label;
|
||||||
static lv_obj_t* breakdown_results_label;
|
|
||||||
static lv_obj_t* strike_numbers_label;
|
|
||||||
static lv_obj_t* step_times_label;
|
|
||||||
|
|
||||||
static void write_time(char* buf, int32_t game_time) {
|
|
||||||
char minus[2] = "\0";
|
|
||||||
if (game_time < 0) {
|
|
||||||
minus[0] = '-';
|
|
||||||
game_time = -game_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
static char str_buf[10] = {0};
|
||||||
|
static char* write_time(uint32_t game_time) {
|
||||||
uint8_t hours = (game_time / (1000*60*60)) % 10;
|
uint8_t hours = (game_time / (1000*60*60)) % 10;
|
||||||
uint8_t minutes = (game_time / (1000*60)) % 60;
|
uint8_t minutes = (game_time / (1000*60)) % 60;
|
||||||
uint8_t seconds = (game_time / (1000)) % 60;
|
uint8_t seconds = (game_time / (1000)) % 60;
|
||||||
|
|
||||||
sprintf(buf, "%s%d:%02d:%02d", minus, hours, minutes, seconds);
|
sprintf(str_buf, "%d:%02d:%02d", hours, minutes, seconds);
|
||||||
|
return str_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern uint32_t initial_game_time;
|
extern uint32_t initial_game_time;
|
||||||
void display_game_results(void) {
|
void display_game_results(void) {
|
||||||
while (xSemaphoreTake(xGuiSemaphore, portMAX_DELAY) == pdFALSE) vTaskDelay(pdMS_TO_TICKS(10));
|
if (xSemaphoreTake(xGuiSemaphore, portMAX_DELAY) == pdTRUE) {
|
||||||
scr = lv_obj_create(NULL);
|
|
||||||
lv_obj_set_style_bg_color(scr, lv_color_black(), LV_STATE_DEFAULT);
|
|
||||||
|
|
||||||
lv_style_init(&game_results_style);
|
lv_style_init(&game_results_style);
|
||||||
lv_style_set_text_color(&game_results_style, lv_color_white());
|
lv_style_set_text_color(&game_results_style, lv_color_white());
|
||||||
// lv_style_set_bg_color(&game_results_style, lv_color_black());
|
lv_style_set_bg_color(&game_results_style, lv_color_black());
|
||||||
lv_style_set_text_align(&game_results_style, LV_TEXT_ALIGN_LEFT);
|
lv_style_set_bg_opa(&game_results_style, LV_OPA_100);
|
||||||
|
lv_style_set_text_align(&game_results_style, LV_TEXT_ALIGN_CENTER);
|
||||||
|
|
||||||
overall_results_label = lv_label_create(scr);
|
game_results_label = lv_label_create(lv_scr_act());
|
||||||
lv_obj_align(overall_results_label, LV_ALIGN_TOP_LEFT, 20, 20);
|
lv_obj_align(game_results_label, LV_ALIGN_CENTER, 0, 0);
|
||||||
lv_obj_set_size(overall_results_label, 460, 140);
|
lv_obj_add_style(game_results_label, &game_results_style, LV_STATE_DEFAULT);
|
||||||
lv_obj_add_style(overall_results_label, &game_results_style, LV_STATE_DEFAULT);
|
|
||||||
|
|
||||||
breakdown_results_label = lv_label_create(scr);
|
char buf[100] = {0};
|
||||||
lv_obj_align(breakdown_results_label, LV_ALIGN_BOTTOM_LEFT, 20, 0);
|
int32_t time_s = get_game_time();
|
||||||
lv_obj_set_size(breakdown_results_label, 460, 140);
|
int32_t time_spent = initial_game_time - time_s;
|
||||||
lv_obj_add_style(breakdown_results_label, &game_results_style, LV_STATE_DEFAULT);
|
char* time = write_time(time_spent);
|
||||||
|
sprintf(buf, "Finished!\nTotal Time (w/ penalties): %s\nTotal Strikes: %ld", time, total_strikes);
|
||||||
|
|
||||||
strike_numbers_label = lv_label_create(scr);
|
lv_label_set_text(game_results_label, buf);
|
||||||
lv_obj_align(strike_numbers_label, LV_ALIGN_BOTTOM_LEFT, 90, 0);
|
|
||||||
lv_obj_set_size(strike_numbers_label, 60, 140);
|
|
||||||
lv_obj_add_style(strike_numbers_label, &game_results_style, LV_STATE_DEFAULT);
|
|
||||||
lv_obj_set_style_text_align(strike_numbers_label, LV_TEXT_ALIGN_RIGHT, LV_STATE_DEFAULT);
|
|
||||||
|
|
||||||
step_times_label = lv_label_create(scr);
|
|
||||||
lv_obj_align(step_times_label, LV_ALIGN_BOTTOM_LEFT, 140, 0);
|
|
||||||
lv_obj_set_size(step_times_label, 80, 140);
|
|
||||||
lv_obj_add_style(step_times_label, &game_results_style, LV_STATE_DEFAULT);
|
|
||||||
lv_obj_set_style_text_align(step_times_label, LV_TEXT_ALIGN_RIGHT, LV_STATE_DEFAULT);
|
|
||||||
|
|
||||||
char buf[1024] = {0};
|
|
||||||
|
|
||||||
char time_buf_1[32] = {0};
|
|
||||||
char time_buf_2[32] = {0};
|
|
||||||
char time_buf_3[32] = {0};
|
|
||||||
char time_buf_4[32] = {0};
|
|
||||||
char time_buf_5[32] = {0};
|
|
||||||
char time_buf_6[32] = {0};
|
|
||||||
|
|
||||||
int32_t time_left = get_game_time();
|
|
||||||
int32_t time_spent = initial_game_time - time_left;
|
|
||||||
int32_t true_time_spent = time_spent - (total_strikes * STRIKE_TIME_PENALTY);
|
|
||||||
write_time(time_buf_1, time_left);
|
|
||||||
write_time(time_buf_2, time_spent);
|
|
||||||
write_time(time_buf_3, true_time_spent);
|
|
||||||
|
|
||||||
sprintf(buf,
|
|
||||||
"Finished!\n\tTotal Strikes: %ld\n\tTime Left (w/ penalties): %s\n\tTime Spent (w/ penalties): %s\n\tTrue Time Spent: %s\n\n",
|
|
||||||
total_strikes, time_buf_1, time_buf_2, time_buf_3
|
|
||||||
);
|
|
||||||
lv_label_set_text(overall_results_label, buf);
|
|
||||||
|
|
||||||
lv_label_set_text(breakdown_results_label, "Step Breakdown:\n\tStep 1: \n\tStep 2:\n\tStep 3:\n\tStep 4:\n\tStep 5:\n\tStep 6:");
|
|
||||||
|
|
||||||
sprintf(buf,
|
|
||||||
"\n%ld strikes\n%ld strikes\n%ld strikes\n%ld strikes\n%ld strikes\n%ld strikes",
|
|
||||||
step_strikes[0], step_strikes[1], step_strikes[2], step_strikes[3], step_strikes[4], step_strikes[5]
|
|
||||||
);
|
|
||||||
lv_label_set_text(strike_numbers_label, buf);
|
|
||||||
|
|
||||||
write_time(time_buf_1, initial_game_time - step_finish_times[0]);
|
|
||||||
write_time(time_buf_2, step_finish_times[0] - step_finish_times[1]);
|
|
||||||
write_time(time_buf_3, step_finish_times[1] - step_finish_times[2]);
|
|
||||||
write_time(time_buf_4, step_finish_times[2] - step_finish_times[3]);
|
|
||||||
write_time(time_buf_5, step_finish_times[3] - step_finish_times[4]);
|
|
||||||
write_time(time_buf_6, step_finish_times[4] - step_finish_times[5]);
|
|
||||||
sprintf(buf,
|
|
||||||
"\n%s\n%s\n%s\n%s\n%s\n%s",
|
|
||||||
time_buf_1, time_buf_2, time_buf_3, time_buf_4, time_buf_5, time_buf_6
|
|
||||||
);
|
|
||||||
lv_label_set_text(step_times_label, buf);
|
|
||||||
|
|
||||||
old_scr = lv_scr_act();
|
|
||||||
lv_scr_load(scr);
|
|
||||||
|
|
||||||
xSemaphoreGive(xGuiSemaphore);
|
xSemaphoreGive(xGuiSemaphore);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
+28
-104
@@ -1,115 +1,24 @@
|
|||||||
#include "main.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "esp_rom_gpio.h"
|
#include "esp_rom_gpio.h"
|
||||||
#include "esp_heap_caps.h"
|
|
||||||
|
|
||||||
#include "drivers/all.h"
|
#include "drivers/all.h"
|
||||||
#include "drivers/state_tracking.h"
|
|
||||||
|
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
|
|
||||||
#include "steps/step0.h"
|
#include "steps/step0.h"
|
||||||
#include "steps/p001_step1.h"
|
#include "steps/step1.h"
|
||||||
#include "steps/p001_step2.h"
|
#include "steps/step2.h"
|
||||||
#include "steps/p001_step3.h"
|
#include "steps/step3.h"
|
||||||
#include "steps/p001_step4.h"
|
#include "steps/step4.h"
|
||||||
#include "steps/p001_step5.h"
|
#include "steps/step5.h"
|
||||||
#include "steps/p001_step6.h"
|
#include "steps/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"
|
|
||||||
|
|
||||||
bool play_modified;
|
|
||||||
|
|
||||||
static const char *TAG = "main";
|
static const char *TAG = "main";
|
||||||
uint32_t initial_game_time = 90*60*1000 + 1000;
|
uint32_t initial_game_time = 90*60*1000;
|
||||||
uint32_t skip_to_step = 0;
|
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) {
|
extern "C" void app_main(void) {
|
||||||
printf("app_main\n");
|
printf("app_main\n");
|
||||||
@@ -119,14 +28,29 @@ extern "C" void app_main(void) {
|
|||||||
// TODO: get wires out of the drivers
|
// TODO: get wires out of the drivers
|
||||||
// TODO: generify the strike system out of wires
|
// TODO: generify the strike system out of wires
|
||||||
init_wires();
|
init_wires();
|
||||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
||||||
|
|
||||||
clean_bomb();
|
clean_bomb();
|
||||||
step0();
|
step0();
|
||||||
|
set_game_time(initial_game_time + 1000);
|
||||||
|
start_game_timer();
|
||||||
|
clean_bomb();
|
||||||
|
if (skip_to_step <= 1) step1();
|
||||||
|
clean_bomb();
|
||||||
|
if (skip_to_step <= 2) step2();
|
||||||
|
clean_bomb();
|
||||||
|
if (skip_to_step <= 3) step3();
|
||||||
|
clean_bomb();
|
||||||
|
if (skip_to_step <= 4) step4();
|
||||||
|
clean_bomb();
|
||||||
|
if (skip_to_step <= 5) step5();
|
||||||
|
clean_bomb();
|
||||||
|
if (skip_to_step <= 6) step6();
|
||||||
|
clean_bomb();
|
||||||
|
|
||||||
if (puzzle == 1) {
|
stop_game_timer();
|
||||||
do_p001();
|
ESP_LOGI(TAG, "Bomb has been diffused. Counter-Terrorists win.");
|
||||||
} else {
|
play_clip_wav(MOUNT_POINT "/diffuse.wav", true, false, 3, 0);
|
||||||
do_p002();
|
|
||||||
}
|
display_game_results();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
#ifndef MAIN_H
|
|
||||||
#define MAIN_H
|
|
||||||
|
|
||||||
#define CONTROL_REV_2_0
|
|
||||||
// #define CONTROL_REV_2_1
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
extern bool play_modified;
|
|
||||||
|
|
||||||
constexpr size_t N_STEPS = 6;
|
|
||||||
|
|
||||||
#endif /* MAIN_H */
|
|
||||||
@@ -1,18 +1,12 @@
|
|||||||
set(SOURCES
|
set(SOURCES
|
||||||
"setup_wires.cpp"
|
"setup_wires.cpp"
|
||||||
"step0.cpp"
|
"step0.cpp"
|
||||||
"p001_step1.cpp"
|
"step1.cpp"
|
||||||
"p001_step2.cpp"
|
"step2.cpp"
|
||||||
"p001_step3.cpp"
|
"step3.cpp"
|
||||||
"p001_step4.cpp"
|
"step4.cpp"
|
||||||
"p001_step5.cpp"
|
"step5.cpp"
|
||||||
"p001_step6.cpp"
|
"step6.cpp"
|
||||||
"p002_step1.cpp"
|
|
||||||
"p002_step2.cpp"
|
|
||||||
"p002_step3.cpp"
|
|
||||||
"p002_step4.cpp"
|
|
||||||
"p002_step5.cpp"
|
|
||||||
"p002_step6.cpp"
|
|
||||||
"wires_puzzle.cpp"
|
"wires_puzzle.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
#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,10 +0,0 @@
|
|||||||
#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,10 +0,0 @@
|
|||||||
#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 */
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#include "p002_step1.h"
|
|
||||||
|
|
||||||
__attribute__((unused))
|
|
||||||
static const char *TAG = "step1";
|
|
||||||
|
|
||||||
void p002_step1(void) {
|
|
||||||
// TODO: implement step 1
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#ifndef P002_STEP_1_H
|
|
||||||
#define P002_STEP_1_H
|
|
||||||
|
|
||||||
#include "../drivers/all.h"
|
|
||||||
|
|
||||||
void p002_step1(void);
|
|
||||||
|
|
||||||
#endif /* P002_STEP_1_H */
|
|
||||||
@@ -1,272 +0,0 @@
|
|||||||
#include "p002_step2.h"
|
|
||||||
#include "helper.h"
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstring>
|
|
||||||
#include <random>
|
|
||||||
|
|
||||||
__attribute__((unused))
|
|
||||||
static const char *TAG = "step2";
|
|
||||||
|
|
||||||
static const uint8_t BOARD_COUNT = 9;
|
|
||||||
static const uint8_t BOARD_SIZE = 6;
|
|
||||||
static const uint8_t PART_SHOTS[3] = {20, 15, 12};
|
|
||||||
static const char *PART_LABELS[3] = {"Alpha", "Bravo", "Charlie"};
|
|
||||||
static const char ROW_LABELS[BOARD_SIZE] = {'A', 'B', 'C', 'D', 'E', 'F'};
|
|
||||||
|
|
||||||
static std::random_device random_device;
|
|
||||||
static std::mt19937 random_engine(random_device());
|
|
||||||
static std::uniform_int_distribution<int> random_board(0, BOARD_COUNT - 1);
|
|
||||||
|
|
||||||
static const uint8_t ALL_BOARDS[BOARD_COUNT][BOARD_SIZE][BOARD_SIZE] = {
|
|
||||||
{
|
|
||||||
{0,0,0,0,0,0},
|
|
||||||
{0,0,1,1,1,1},
|
|
||||||
{0,1,0,0,0,0},
|
|
||||||
{0,1,0,1,1,0},
|
|
||||||
{0,1,0,0,0,0},
|
|
||||||
{0,0,0,1,0,0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{0,1,0,0,0,0},
|
|
||||||
{0,1,0,1,1,0},
|
|
||||||
{0,1,0,0,0,0},
|
|
||||||
{0,0,0,1,0,0},
|
|
||||||
{0,0,0,0,0,0},
|
|
||||||
{1,1,1,1,0,0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{0,0,1,1,1,1},
|
|
||||||
{0,1,0,0,0,0},
|
|
||||||
{0,1,0,0,0,0},
|
|
||||||
{0,1,0,0,0,0},
|
|
||||||
{0,0,1,0,0,0},
|
|
||||||
{1,0,1,0,0,0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{1,0,0,0,0,0},
|
|
||||||
{1,0,0,0,0,0},
|
|
||||||
{1,0,0,0,0,1},
|
|
||||||
{1,0,0,0,0,1},
|
|
||||||
{0,0,0,0,1,0},
|
|
||||||
{0,1,1,1,0,0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{1,1,0,1,0,0},
|
|
||||||
{0,0,0,1,0,0},
|
|
||||||
{0,1,0,1,0,0},
|
|
||||||
{0,0,0,0,0,0},
|
|
||||||
{0,1,1,1,1,0},
|
|
||||||
{0,0,0,0,0,0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{0,0,1,0,1,0},
|
|
||||||
{1,0,1,0,1,0},
|
|
||||||
{0,0,1,0,1,0},
|
|
||||||
{0,0,1,0,0,0},
|
|
||||||
{0,0,0,0,0,0},
|
|
||||||
{1,1,0,0,0,0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{0,0,0,0,0,1},
|
|
||||||
{1,1,0,0,0,0},
|
|
||||||
{0,0,0,0,1,0},
|
|
||||||
{1,1,1,0,1,0},
|
|
||||||
{0,0,0,0,1,0},
|
|
||||||
{0,0,0,0,1,0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{0,1,1,0,0,0},
|
|
||||||
{0,0,0,0,1,0},
|
|
||||||
{0,0,0,0,1,0},
|
|
||||||
{0,0,1,0,1,0},
|
|
||||||
{0,0,0,0,0,0},
|
|
||||||
{1,1,1,1,0,0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{0,0,0,0,0,0},
|
|
||||||
{1,0,0,0,0,0},
|
|
||||||
{0,1,0,0,1,1},
|
|
||||||
{0,1,0,1,0,0},
|
|
||||||
{0,1,0,1,0,0},
|
|
||||||
{0,1,0,1,0,0},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool row_from_button_state(uint8_t state, uint8_t *row) {
|
|
||||||
switch (state) {
|
|
||||||
case 0b1100: *row = 0; return true; // B1 + B2 -> A
|
|
||||||
case 0b1010: *row = 1; return true; // B1 + B3 -> B
|
|
||||||
case 0b1001: *row = 2; return true; // B1 + B4 -> C
|
|
||||||
case 0b0110: *row = 3; return true; // B2 + B3 -> D
|
|
||||||
case 0b0101: *row = 4; return true; // B2 + B4 -> E
|
|
||||||
case 0b0011: *row = 5; return true; // B3 + B4 -> F
|
|
||||||
default: return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool column_from_switch_state(uint8_t state, uint8_t *col) {
|
|
||||||
uint8_t value = state & 0xF;
|
|
||||||
if (value >= 1 && value <= 6) {
|
|
||||||
*col = value - 1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int count_ship_segments(const uint8_t board[BOARD_SIZE][BOARD_SIZE]) {
|
|
||||||
int count = 0;
|
|
||||||
for (uint8_t row = 0; row < BOARD_SIZE; ++row) {
|
|
||||||
for (uint8_t col = 0; col < BOARD_SIZE; ++col) {
|
|
||||||
if (board[row][col] == 1) {
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void copy_board(uint8_t dest[BOARD_SIZE][BOARD_SIZE], const uint8_t src[BOARD_SIZE][BOARD_SIZE]) {
|
|
||||||
memcpy(dest, src, BOARD_SIZE * BOARD_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void render_status(const char *part_name,
|
|
||||||
int shots_left,
|
|
||||||
int hits,
|
|
||||||
int misses,
|
|
||||||
int row,
|
|
||||||
int col,
|
|
||||||
const char *info) {
|
|
||||||
char line0[21] = {0};
|
|
||||||
char line1[21] = {0};
|
|
||||||
char line2[21] = {0};
|
|
||||||
char line3[21] = {0};
|
|
||||||
|
|
||||||
snprintf(line0, sizeof(line0), "%s Shots:%2d", part_name, shots_left);
|
|
||||||
if (row >= 0 && col >= 0) {
|
|
||||||
snprintf(line1, sizeof(line1), "Row %c Col %d", ROW_LABELS[row], col + 1);
|
|
||||||
} else {
|
|
||||||
snprintf(line1, sizeof(line1), "Row - Col -");
|
|
||||||
}
|
|
||||||
snprintf(line2, sizeof(line2), "Hits:%2d Misses:%2d", hits, misses);
|
|
||||||
snprintf(line3, sizeof(line3), "%s", info);
|
|
||||||
|
|
||||||
lcd_clear();
|
|
||||||
lcd_print(0, 0, line0);
|
|
||||||
lcd_print(0, 1, line1);
|
|
||||||
lcd_print(0, 2, line2);
|
|
||||||
lcd_print(0, 3, line3);
|
|
||||||
}
|
|
||||||
|
|
||||||
void p002_step2(void) {
|
|
||||||
clean_bomb();
|
|
||||||
|
|
||||||
for (int part = 0; part < 3; ++part) {
|
|
||||||
const char *part_name = PART_LABELS[part];
|
|
||||||
const int max_shots = PART_SHOTS[part];
|
|
||||||
bool completed = false;
|
|
||||||
|
|
||||||
while (!completed) {
|
|
||||||
uint8_t board[BOARD_SIZE][BOARD_SIZE];
|
|
||||||
copy_board(board, ALL_BOARDS[random_board(random_engine)]);
|
|
||||||
|
|
||||||
int shots_taken = 0;
|
|
||||||
int hits = 0;
|
|
||||||
int misses = 0;
|
|
||||||
int current_row = -1;
|
|
||||||
int current_col = -1;
|
|
||||||
const char *status = "Hold 2 buttons + set switches";
|
|
||||||
|
|
||||||
render_status(part_name, max_shots - shots_taken, hits, misses, -1, -1, status);
|
|
||||||
clean_bomb();
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
uint8_t button_state = get_button_state();
|
|
||||||
uint8_t switch_state = get_switch_state();
|
|
||||||
uint8_t row = 0;
|
|
||||||
uint8_t col = 0;
|
|
||||||
bool row_valid = row_from_button_state(button_state, &row);
|
|
||||||
bool col_valid = column_from_switch_state(switch_state, &col);
|
|
||||||
|
|
||||||
if (row_valid) {
|
|
||||||
current_row = row;
|
|
||||||
} else {
|
|
||||||
current_row = -1;
|
|
||||||
}
|
|
||||||
if (col_valid) {
|
|
||||||
current_col = col;
|
|
||||||
} else {
|
|
||||||
current_col = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
KeypadKey key;
|
|
||||||
if (get_keypad_pressed(&key)) {
|
|
||||||
if (key == KeypadKey::k5) {
|
|
||||||
if (!row_valid) {
|
|
||||||
status = "Invalid row selection";
|
|
||||||
} else if (!col_valid) {
|
|
||||||
status = "Invalid column value";
|
|
||||||
} else {
|
|
||||||
uint8_t cell = board[row][col];
|
|
||||||
if (cell == 2 || cell == 3) {
|
|
||||||
status = "Already fired there";
|
|
||||||
} else {
|
|
||||||
shots_taken += 1;
|
|
||||||
if (cell == 1) {
|
|
||||||
board[row][col] = 3;
|
|
||||||
hits += 1;
|
|
||||||
status = "Hit!";
|
|
||||||
led_set(IndicatorLED::LED_LCD, LEDColor::LED_COLOR_RED);
|
|
||||||
} else {
|
|
||||||
board[row][col] = 2;
|
|
||||||
misses += 1;
|
|
||||||
status = "Miss!";
|
|
||||||
led_set(IndicatorLED::LED_LCD, LEDColor::LED_COLOR_WHITE);
|
|
||||||
}
|
|
||||||
leds_flush();
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(250));
|
|
||||||
led_set(IndicatorLED::LED_LCD, LEDColor::LED_COLOR_OFF);
|
|
||||||
leds_flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render_status(part_name,
|
|
||||||
max_shots - shots_taken,
|
|
||||||
hits,
|
|
||||||
misses,
|
|
||||||
current_row,
|
|
||||||
current_col,
|
|
||||||
status);
|
|
||||||
|
|
||||||
if (count_ship_segments(board) == 0) {
|
|
||||||
completed = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shots_taken >= max_shots) {
|
|
||||||
strike("Out of shots!");
|
|
||||||
status = "Out of shots! Retry";
|
|
||||||
render_status(part_name,
|
|
||||||
0,
|
|
||||||
hits,
|
|
||||||
misses,
|
|
||||||
current_row,
|
|
||||||
current_col,
|
|
||||||
status);
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(2000));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(50));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (part < 2)
|
|
||||||
play_clip_wav(MOUNT_POINT "/partdone.wav", true, false, 0, 0);
|
|
||||||
clean_bomb();
|
|
||||||
}
|
|
||||||
|
|
||||||
play_clip_wav(MOUNT_POINT "/stepdone.wav", true, false, 1, 0);
|
|
||||||
lcd_clear();
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#ifndef P002_STEP_2_H
|
|
||||||
#define P002_STEP_2_H
|
|
||||||
|
|
||||||
#include "../drivers/all.h"
|
|
||||||
|
|
||||||
void p002_step2(void);
|
|
||||||
|
|
||||||
#endif /* P002_STEP_2_H */
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#include "p002_step3.h"
|
|
||||||
|
|
||||||
__attribute__((unused))
|
|
||||||
static const char *TAG = "step3";
|
|
||||||
|
|
||||||
void p002_step3(void) {
|
|
||||||
// TODO: implement step 3
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#ifndef P002_STEP_3_H
|
|
||||||
#define P002_STEP_3_H
|
|
||||||
|
|
||||||
#include "../drivers/all.h"
|
|
||||||
|
|
||||||
void p002_step3(void);
|
|
||||||
|
|
||||||
#endif /* P002_STEP_3_H */
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#include "p002_step4.h"
|
|
||||||
|
|
||||||
__attribute__((unused))
|
|
||||||
static const char *TAG = "step4";
|
|
||||||
|
|
||||||
void p002_step4(void) {
|
|
||||||
// TODO: implement step 4
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#ifndef P002_STEP_4_H
|
|
||||||
#define P002_STEP_4_H
|
|
||||||
|
|
||||||
#include "../drivers/all.h"
|
|
||||||
|
|
||||||
void p002_step4(void);
|
|
||||||
|
|
||||||
#endif /* P002_STEP_4_H */
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#include "p002_step5.h"
|
|
||||||
|
|
||||||
__attribute__((unused))
|
|
||||||
static const char *TAG = "step5";
|
|
||||||
|
|
||||||
void p002_step5(void) {
|
|
||||||
// TODO: implement step 5
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#ifndef P002_STEP_5_H
|
|
||||||
#define P002_STEP_5_H
|
|
||||||
|
|
||||||
#include "../drivers/all.h"
|
|
||||||
|
|
||||||
void p002_step5(void);
|
|
||||||
|
|
||||||
#endif /* P002_STEP_5_H */
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#include "p002_step6.h"
|
|
||||||
|
|
||||||
__attribute__((unused))
|
|
||||||
static const char *TAG = "step6";
|
|
||||||
|
|
||||||
void p002_step6(void) {
|
|
||||||
// TODO: implement step 6
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#ifndef P002_STEP_6_H
|
|
||||||
#define P002_STEP_6_H
|
|
||||||
|
|
||||||
#include "../drivers/all.h"
|
|
||||||
|
|
||||||
void p002_step6(void);
|
|
||||||
|
|
||||||
#endif /* P002_STEP_6_H */
|
|
||||||
@@ -30,7 +30,7 @@ void setup_wires(void) {
|
|||||||
clear_all_pressed_released();
|
clear_all_pressed_released();
|
||||||
get_cut_wires();
|
get_cut_wires();
|
||||||
lcd_clear();
|
lcd_clear();
|
||||||
lcd_set_cursor_vis(true);
|
lcd_set_cursor_vis(false);
|
||||||
|
|
||||||
WireColor wires[NUM_WIRES];
|
WireColor wires[NUM_WIRES];
|
||||||
load_wires_from_sd_card(wires);
|
load_wires_from_sd_card(wires);
|
||||||
|
|||||||
+9
-53
@@ -1,11 +1,9 @@
|
|||||||
#include "step0.h"
|
#include "step0.h"
|
||||||
#include "drivers/state_tracking.h"
|
|
||||||
|
|
||||||
static const char* TAG = "step0";
|
static const char* TAG = "step0";
|
||||||
|
|
||||||
extern uint32_t initial_game_time;
|
extern uint32_t initial_game_time;
|
||||||
extern uint32_t skip_to_step;
|
extern uint32_t skip_to_step;
|
||||||
extern uint32_t puzzle;
|
|
||||||
|
|
||||||
static void set_game_time();
|
static void set_game_time();
|
||||||
static void skip_to_step1() { skip_to_step = 1; }
|
static void skip_to_step1() { skip_to_step = 1; }
|
||||||
@@ -14,12 +12,12 @@ static void skip_to_step3() { skip_to_step = 3; }
|
|||||||
static void skip_to_step4() { skip_to_step = 4; }
|
static void skip_to_step4() { skip_to_step = 4; }
|
||||||
static void skip_to_step5() { skip_to_step = 5; }
|
static void skip_to_step5() { skip_to_step = 5; }
|
||||||
static void skip_to_step6() { skip_to_step = 6; }
|
static void skip_to_step6() { skip_to_step = 6; }
|
||||||
static void try_step1() { clean_bomb(); p001_step1(); }
|
static void try_step1() { clean_bomb(); step1(); }
|
||||||
static void try_step2() { clean_bomb(); p001_step2(); }
|
static void try_step2() { clean_bomb(); step2(); }
|
||||||
static void try_step3() { clean_bomb(); p001_step3(); }
|
static void try_step3() { clean_bomb(); step3(); }
|
||||||
static void try_step4() { clean_bomb(); p001_step4(); }
|
static void try_step4() { clean_bomb(); step4(); }
|
||||||
static void try_step5() { clean_bomb(); p001_step5(); }
|
static void try_step5() { clean_bomb(); step5(); }
|
||||||
static void try_step6() { clean_bomb(); p001_step6(); }
|
static void try_step6() { clean_bomb(); step6(); }
|
||||||
static void issue_strike() { strike("Strike Issued"); }
|
static void issue_strike() { strike("Strike Issued"); }
|
||||||
static void flashbang();
|
static void flashbang();
|
||||||
static void debug_switches();
|
static void debug_switches();
|
||||||
@@ -36,30 +34,6 @@ static void battery_stats() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove. This is temperary
|
|
||||||
static void replay_last() {
|
|
||||||
FILE* record_file = fopen(MOUNT_POINT "/record.txt", "r");
|
|
||||||
if (record_file == nullptr) {
|
|
||||||
ESP_LOGE("main", "failed to open record.txt");
|
|
||||||
}
|
|
||||||
set_playback_source(record_file, true);
|
|
||||||
start_playback();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void do_p001() {
|
|
||||||
play_modified = false;
|
|
||||||
puzzle = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void do_p001_modified() {
|
|
||||||
play_modified = true;
|
|
||||||
puzzle = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void do_p002() {
|
|
||||||
puzzle = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Wait for "*9819"
|
/// Wait for "*9819"
|
||||||
void step0() {
|
void step0() {
|
||||||
led_set(IndicatorLED::LED_SPEAKER, LEDColor::LED_COLOR_BLUE);
|
led_set(IndicatorLED::LED_SPEAKER, LEDColor::LED_COLOR_BLUE);
|
||||||
@@ -68,25 +42,13 @@ void step0() {
|
|||||||
StarCodeHandler star_codes[] = {
|
StarCodeHandler star_codes[] = {
|
||||||
{
|
{
|
||||||
.code = "*9819",
|
.code = "*9819",
|
||||||
.display_text = "Start P001DH",
|
.display_text = "Diffusal Initiated",
|
||||||
.should_exit = true,
|
.should_exit = true,
|
||||||
.callback = do_p001,
|
.callback = nullptr,
|
||||||
},
|
|
||||||
{
|
|
||||||
.code = "*9818",
|
|
||||||
.display_text = "Start P001DM",
|
|
||||||
.should_exit = true,
|
|
||||||
.callback = do_p001_modified,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.code = "*3141",
|
|
||||||
.display_text = "Start P002",
|
|
||||||
.should_exit = true,
|
|
||||||
.callback = do_p002,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.code = "*59861",
|
.code = "*59861",
|
||||||
.display_text = "Setup Wires",
|
.display_text = "Set Up Wires",
|
||||||
.should_exit = false,
|
.should_exit = false,
|
||||||
.callback = setup_wires,
|
.callback = setup_wires,
|
||||||
},
|
},
|
||||||
@@ -192,12 +154,6 @@ void step0() {
|
|||||||
.should_exit = false,
|
.should_exit = false,
|
||||||
.callback = flashbang,
|
.callback = flashbang,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
.code = "*1113",
|
|
||||||
.display_text = "replay_last",
|
|
||||||
.should_exit = false,
|
|
||||||
.callback = replay_last,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
int len = sizeof(star_codes)/sizeof(StarCodeHandler);
|
int len = sizeof(star_codes)/sizeof(StarCodeHandler);
|
||||||
do_star_codes(star_codes, len);
|
do_star_codes(star_codes, len);
|
||||||
|
|||||||
+6
-6
@@ -8,12 +8,12 @@
|
|||||||
#include "setup_wires.h"
|
#include "setup_wires.h"
|
||||||
#include "../helper.h"
|
#include "../helper.h"
|
||||||
|
|
||||||
#include "p001_step1.h"
|
#include "step1.h"
|
||||||
#include "p001_step2.h"
|
#include "step2.h"
|
||||||
#include "p001_step3.h"
|
#include "step3.h"
|
||||||
#include "p001_step4.h"
|
#include "step4.h"
|
||||||
#include "p001_step5.h"
|
#include "step5.h"
|
||||||
#include "p001_step6.h"
|
#include "step6.h"
|
||||||
|
|
||||||
/// Wait for "*9819"
|
/// Wait for "*9819"
|
||||||
void step0(void);
|
void step0(void);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "p001_step1.h"
|
#include "step1.h"
|
||||||
|
|
||||||
__attribute__((unused))
|
__attribute__((unused))
|
||||||
static const char *TAG = "step1";
|
static const char *TAG = "step1";
|
||||||
@@ -276,7 +276,7 @@ static bool play_part(uint32_t time) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p001_step1(void) {
|
void step1(void) {
|
||||||
while (get_switch_flipped(nullptr));
|
while (get_switch_flipped(nullptr));
|
||||||
|
|
||||||
init_step();
|
init_step();
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef STEP_1_H
|
||||||
|
#define STEP_1_H
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
#include "../drivers/bottom_half.h"
|
||||||
|
#include "../drivers/tft.h"
|
||||||
|
#include "../drivers/leds.h"
|
||||||
|
#include "../drivers/wires.h"
|
||||||
|
#include "../drivers/speaker.h"
|
||||||
|
#include "../drivers/game_timer.h"
|
||||||
|
#include "../drivers/char_lcd.h"
|
||||||
|
|
||||||
|
void step1(void);
|
||||||
|
|
||||||
|
#endif /* STEP_1_H */
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "p001_step2.h"
|
#include "step2.h"
|
||||||
|
|
||||||
__attribute__((unused))
|
__attribute__((unused))
|
||||||
static const char *TAG = "step2";
|
static const char *TAG = "step2";
|
||||||
@@ -88,10 +88,9 @@ static void new_puzzle(void) {
|
|||||||
// ESP_LOGI(TAG, "Flipping bit %i on display %i", i, display);
|
// ESP_LOGI(TAG, "Flipping bit %i on display %i", i, display);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_module_sseg_raw(display_map);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void p001_step2(void) {
|
void step2(void) {
|
||||||
KeypadKey key;
|
KeypadKey key;
|
||||||
int solved_times = 0;
|
int solved_times = 0;
|
||||||
|
|
||||||
@@ -99,6 +98,7 @@ void p001_step2(void) {
|
|||||||
int strike_time = 0;
|
int strike_time = 0;
|
||||||
while(solved_times < NUM_SOLVES) {
|
while(solved_times < NUM_SOLVES) {
|
||||||
// for every bit in the answer-
|
// for every bit in the answer-
|
||||||
|
set_module_sseg_raw(display_map);
|
||||||
if (get_keypad_pressed(&key)) {
|
if (get_keypad_pressed(&key)) {
|
||||||
lcd_clear();
|
lcd_clear();
|
||||||
char c = char_of_keypad_key(key);
|
char c = char_of_keypad_key(key);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef P001_STEP_2_H
|
#ifndef STEP_2_H
|
||||||
#define P001_STEP_2_H
|
#define STEP_2_H
|
||||||
|
|
||||||
#include "../drivers/bottom_half.h"
|
#include "../drivers/bottom_half.h"
|
||||||
#include "../drivers/wires.h"
|
#include "../drivers/wires.h"
|
||||||
@@ -11,6 +11,6 @@
|
|||||||
#include <random>
|
#include <random>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
void p001_step2(void);
|
void step2(void);
|
||||||
|
|
||||||
#endif /* P001_STEP_2_H */
|
#endif /* STEP_2_H */
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "p001_step3.h"
|
#include "step3.h"
|
||||||
|
|
||||||
#define ONE_SECOND_TIME 90'000
|
#define ONE_SECOND_TIME 90'000
|
||||||
#define THREE_SECOND_TIME 90'000
|
#define THREE_SECOND_TIME 90'000
|
||||||
@@ -63,7 +63,7 @@ static bool one_second();
|
|||||||
static bool three_second();
|
static bool three_second();
|
||||||
static bool six_second();
|
static bool six_second();
|
||||||
|
|
||||||
void p001_step3(void) {
|
void step3(void) {
|
||||||
StarCodeHandler star_codes[] = {
|
StarCodeHandler star_codes[] = {
|
||||||
{
|
{
|
||||||
.code = "*1642",
|
.code = "*1642",
|
||||||
@@ -361,10 +361,10 @@ static bool six_second() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int pink_led_on_bottom_count = 0;
|
int purple_led_on_bottom_count = 0;
|
||||||
for (int i = IndicatorLED::LED_RFID; i < LED_COUNT; i++) {
|
for (int i = IndicatorLED::LED_RFID; i < LED_COUNT; i++) {
|
||||||
if (indicator_led_idxs[i] == 5) {
|
if (indicator_led_idxs[i] == 5) {
|
||||||
pink_led_on_bottom_count++;
|
purple_led_on_bottom_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +372,7 @@ static bool six_second() {
|
|||||||
vowels > 7,
|
vowels > 7,
|
||||||
second_switch_correct_state,
|
second_switch_correct_state,
|
||||||
true,
|
true,
|
||||||
!(pink_led_on_bottom_count > 1)
|
!(purple_led_on_bottom_count > 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
uint8_t correct_button_mask = 0b1101;
|
uint8_t correct_button_mask = 0b1101;
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef STEP_3_H
|
||||||
|
#define STEP_3_H
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
#include "../drivers/bottom_half.h"
|
||||||
|
#include "../drivers/wires.h"
|
||||||
|
#include "../drivers/speaker.h"
|
||||||
|
#include "../drivers/leds.h"
|
||||||
|
#include "../drivers/char_lcd.h"
|
||||||
|
#include "../drivers/game_timer.h"
|
||||||
|
#include "../helper.h"
|
||||||
|
|
||||||
|
void step3(void);
|
||||||
|
|
||||||
|
#endif /* STEP_3_H */
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "p001_step4.h"
|
#include "step4.h"
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
__attribute__((unused))
|
__attribute__((unused))
|
||||||
static const char *TAG = "step4";
|
static const char *TAG = "step4";
|
||||||
@@ -234,11 +233,8 @@ bool play_game(int time, int required_score) {
|
|||||||
target_score = required_score;
|
target_score = required_score;
|
||||||
score = 0;
|
score = 0;
|
||||||
update_score();
|
update_score();
|
||||||
|
|
||||||
if (!play_modified) {
|
|
||||||
set_module_time(time);
|
set_module_time(time);
|
||||||
start_module_timer();
|
start_module_timer();
|
||||||
}
|
|
||||||
|
|
||||||
clear_board();
|
clear_board();
|
||||||
|
|
||||||
@@ -276,7 +272,6 @@ bool play_game(int time, int required_score) {
|
|||||||
show_board();
|
show_board();
|
||||||
|
|
||||||
if (score >= required_score) {
|
if (score >= required_score) {
|
||||||
if (!play_modified)
|
|
||||||
stop_module_timer();
|
stop_module_timer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -312,7 +307,6 @@ bool play_game(int time, int required_score) {
|
|||||||
show_board();
|
show_board();
|
||||||
|
|
||||||
if (score >= required_score) {
|
if (score >= required_score) {
|
||||||
if (!play_modified)
|
|
||||||
stop_module_timer();
|
stop_module_timer();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -320,12 +314,11 @@ bool play_game(int time, int required_score) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!play_modified) && get_module_time() <= 0) {
|
if (get_module_time() <= 0) {
|
||||||
stop_module_timer();
|
stop_module_timer();
|
||||||
strike("Out of time");
|
strike("Out of time");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (get_switch_flipped(&switch_)) {
|
// if (get_switch_flipped(&switch_)) {
|
||||||
// printf("%d\n", piece);
|
// printf("%d\n", piece);
|
||||||
// for (int i = 0; i < sizeof(piece_nodes)/sizeof(piece_nodes[0]); i++) {
|
// for (int i = 0; i < sizeof(piece_nodes)/sizeof(piece_nodes[0]); i++) {
|
||||||
@@ -340,7 +333,6 @@ bool play_game(int time, int required_score) {
|
|||||||
|
|
||||||
// game over
|
// game over
|
||||||
ESP_LOGI(TAG, "Game Over. Score: %d", score);
|
ESP_LOGI(TAG, "Game Over. Score: %d", score);
|
||||||
if (!play_modified)
|
|
||||||
stop_module_timer();
|
stop_module_timer();
|
||||||
strike("Out of room");
|
strike("Out of room");
|
||||||
return false;
|
return false;
|
||||||
@@ -387,7 +379,7 @@ static void fail() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void p001_step4() {
|
void step4() {
|
||||||
StarCodeHandler star_code = {
|
StarCodeHandler star_code = {
|
||||||
.code = "*3850",
|
.code = "*3850",
|
||||||
.display_text = "Starting...",
|
.display_text = "Starting...",
|
||||||
@@ -397,16 +389,13 @@ void p001_step4() {
|
|||||||
do_star_codes(&star_code, 1);
|
do_star_codes(&star_code, 1);
|
||||||
init_screen();
|
init_screen();
|
||||||
|
|
||||||
int lines_1 = play_modified ? 2 : 2;
|
while (!play_game(4*60*1000, 2)) fail();
|
||||||
int lines_2 = play_modified ? 5 : 4;
|
|
||||||
int lines_3 = play_modified ? 12 : 8;
|
|
||||||
while (!play_game(4*60*1000, lines_1)) fail();
|
|
||||||
play_clip_wav(MOUNT_POINT "/partdone.wav", true, false, 0, 0);
|
play_clip_wav(MOUNT_POINT "/partdone.wav", true, false, 0, 0);
|
||||||
complete();
|
complete();
|
||||||
while (!play_game(4*60*1000, lines_2)) fail();
|
while (!play_game(4*60*1000, 4)) fail();
|
||||||
play_clip_wav(MOUNT_POINT "/partdone.wav", true, false, 0, 0);
|
play_clip_wav(MOUNT_POINT "/partdone.wav", true, false, 0, 0);
|
||||||
complete();
|
complete();
|
||||||
while (!play_game(6*60*1000, lines_3)) fail();
|
while (!play_game(7*60*1000, 8)) fail();
|
||||||
play_clip_wav(MOUNT_POINT "/stepdone.wav", true, false, 1, 0);
|
play_clip_wav(MOUNT_POINT "/stepdone.wav", true, false, 1, 0);
|
||||||
complete();
|
complete();
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef P001_STEP_4_H
|
#ifndef STEP_4_H
|
||||||
#define P001_STEP_4_H
|
#define STEP_4_H
|
||||||
|
|
||||||
#include <random>
|
#include <random>
|
||||||
#include "../drivers/tft.h"
|
#include "../drivers/tft.h"
|
||||||
@@ -13,6 +13,6 @@
|
|||||||
#define TETRIS_USE_FLASH_IMG
|
#define TETRIS_USE_FLASH_IMG
|
||||||
#define TETRIS_USE_FLASH_BG_IMG
|
#define TETRIS_USE_FLASH_BG_IMG
|
||||||
|
|
||||||
void p001_step4(void);
|
void step4(void);
|
||||||
|
|
||||||
#endif /* P001_STEP_4_H */
|
#endif /* STEP_4_H */
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "p001_step5.h"
|
#include "step5.h"
|
||||||
|
|
||||||
#define TIME_CLEAR 30'000
|
#define TIME_CLEAR 30'000
|
||||||
#define TIME_PLANK 40'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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p001_step5(void) {
|
void step5(void) {
|
||||||
StarCodeHandler star_codes[] = {
|
StarCodeHandler star_codes[] = {
|
||||||
{
|
{
|
||||||
.code = "*2648",
|
.code = "*2648",
|
||||||
@@ -651,105 +651,7 @@ void p001_step5(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 7: {
|
case 7: {
|
||||||
if (play_modified) {
|
lcd_print("What");
|
||||||
// do PLINK
|
|
||||||
lcd_print("Plink");
|
|
||||||
set_module_time(TIME_PLINK);
|
|
||||||
start_module_timer();
|
|
||||||
|
|
||||||
std::uniform_int_distribution<> indicator_number_dist(0, 4);
|
|
||||||
|
|
||||||
// ESP_LOGI(TAG, "Green: %i, Red: %i, Yellow: %i, Blue: %i", green_indicators, red_indicators, yellow_indicators, blue_indicators);
|
|
||||||
|
|
||||||
const uint32_t COLORS[] = {
|
|
||||||
LEDColor::LED_COLOR_GREEN,
|
|
||||||
LEDColor::LED_COLOR_RED,
|
|
||||||
LEDColor::LED_COLOR_YELLOW,
|
|
||||||
LEDColor::LED_COLOR_BLUE,
|
|
||||||
LEDColor::LED_COLOR_PINK,
|
|
||||||
};
|
|
||||||
|
|
||||||
int solved_times = 0;
|
|
||||||
bool failed = false;
|
|
||||||
while (solved_times < 3 && !failed) {
|
|
||||||
int indicator_numbers[5] = {indicator_number_dist(gen), indicator_number_dist(gen), indicator_number_dist(gen), indicator_number_dist(gen), indicator_number_dist(gen)};
|
|
||||||
|
|
||||||
std::vector<int> led_options = all_leds;
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
set_unique_leds(led_options, indicator_numbers[i], COLORS[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
leds_flush();
|
|
||||||
|
|
||||||
std::uniform_int_distribution<> answer_color_dist(0, 4);
|
|
||||||
|
|
||||||
std::map<int, std::string> color_name_map = {
|
|
||||||
{0, "Green"},
|
|
||||||
{1, "Red"},
|
|
||||||
{2, "Yellow"},
|
|
||||||
{3, "Blue"},
|
|
||||||
{4, "Pink"},
|
|
||||||
};
|
|
||||||
|
|
||||||
int answer_color = answer_color_dist(gen);
|
|
||||||
|
|
||||||
std::string color_string = color_name_map[answer_color];
|
|
||||||
std::string answer_num = std::to_string(indicator_numbers[answer_color]);
|
|
||||||
|
|
||||||
// ESP_LOGI(TAG, "color string: %s", color_string.c_str());
|
|
||||||
|
|
||||||
lcd_print(1, 2, color_string.c_str());
|
|
||||||
|
|
||||||
std::string entered_string;
|
|
||||||
|
|
||||||
KeypadKey key;
|
|
||||||
while (1) {
|
|
||||||
if (get_keypad_pressed(&key)) {
|
|
||||||
bool failed = false;
|
|
||||||
|
|
||||||
if (key == KeypadKey::star) {
|
|
||||||
// clear
|
|
||||||
entered_string = "";
|
|
||||||
} else if (key == KeypadKey::pound) {
|
|
||||||
// submit
|
|
||||||
if (entered_string != answer_num) {
|
|
||||||
strike("Incorrect answer!");
|
|
||||||
failed = true;
|
|
||||||
} else {
|
|
||||||
solved_correctly = true;;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
entered_string += char_of_keypad_key(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (failed) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
lcd_clear();
|
|
||||||
lcd_print(1, 1, "Plink");
|
|
||||||
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!");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
if (!failed) {
|
|
||||||
solved_correctly = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// do WHAT
|
|
||||||
lcd_print(1, 1, "What");
|
|
||||||
set_module_time(TIME_WHAT);
|
set_module_time(TIME_WHAT);
|
||||||
start_module_timer();
|
start_module_timer();
|
||||||
|
|
||||||
@@ -822,7 +724,7 @@ void p001_step5(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// display expression
|
// display expression
|
||||||
lcd_print(2, 1, display_expression.c_str());
|
lcd_print(1, 2, display_expression.c_str());
|
||||||
|
|
||||||
// set LEDs
|
// set LEDs
|
||||||
const uint32_t COLORS[] = {
|
const uint32_t COLORS[] = {
|
||||||
@@ -883,8 +785,8 @@ void p001_step5(void) {
|
|||||||
|
|
||||||
lcd_clear();
|
lcd_clear();
|
||||||
lcd_print(1, 1, "What");
|
lcd_print(1, 1, "What");
|
||||||
lcd_print(2, 1, display_expression.c_str());
|
lcd_print(1, 2, display_expression.c_str());
|
||||||
lcd_print(3, 1, entered_string.c_str());
|
lcd_print(1, 3, entered_string.c_str());
|
||||||
}
|
}
|
||||||
if (get_module_time() <= 0) {
|
if (get_module_time() <= 0) {
|
||||||
strike("Ran out of time!");
|
strike("Ran out of time!");
|
||||||
@@ -893,13 +795,107 @@ void p001_step5(void) {
|
|||||||
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(10));
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
case 8: {
|
||||||
ESP_LOGE(TAG, "Invalid puzzle number %d", puzzle);
|
lcd_print("Plink");
|
||||||
|
set_module_time(TIME_PLINK);
|
||||||
|
start_module_timer();
|
||||||
|
|
||||||
|
std::uniform_int_distribution<> indicator_number_dist(0, 4);
|
||||||
|
|
||||||
|
// ESP_LOGI(TAG, "Green: %i, Red: %i, Yellow: %i, Blue: %i", green_indicators, red_indicators, yellow_indicators, blue_indicators);
|
||||||
|
|
||||||
|
const uint32_t COLORS[] = {
|
||||||
|
LEDColor::LED_COLOR_GREEN,
|
||||||
|
LEDColor::LED_COLOR_RED,
|
||||||
|
LEDColor::LED_COLOR_YELLOW,
|
||||||
|
LEDColor::LED_COLOR_BLUE,
|
||||||
|
LEDColor::LED_COLOR_PINK,
|
||||||
|
};
|
||||||
|
|
||||||
|
int solved_times = 0;
|
||||||
|
bool failed = false;
|
||||||
|
while (solved_times < 3 && !failed) {
|
||||||
|
int indicator_numbers[5] = {indicator_number_dist(gen), indicator_number_dist(gen), indicator_number_dist(gen), indicator_number_dist(gen), indicator_number_dist(gen)};
|
||||||
|
|
||||||
|
std::vector<int> led_options = all_leds;
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
set_unique_leds(led_options, indicator_numbers[i], COLORS[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
leds_flush();
|
||||||
|
|
||||||
|
std::uniform_int_distribution<> answer_color_dist(0, 4);
|
||||||
|
|
||||||
|
std::map<int, std::string> color_name_map = {
|
||||||
|
{0, "Green"},
|
||||||
|
{1, "Red"},
|
||||||
|
{2, "Yellow"},
|
||||||
|
{3, "Blue"},
|
||||||
|
{4, "Purple"},
|
||||||
|
};
|
||||||
|
|
||||||
|
int answer_color = answer_color_dist(gen);
|
||||||
|
|
||||||
|
std::string color_string = color_name_map[answer_color];
|
||||||
|
std::string answer_num = std::to_string(indicator_numbers[answer_color]);
|
||||||
|
|
||||||
|
// ESP_LOGI(TAG, "color string: %s", color_string.c_str());
|
||||||
|
|
||||||
|
lcd_print(1, 2, color_string.c_str());
|
||||||
|
|
||||||
|
std::string entered_string;
|
||||||
|
|
||||||
|
KeypadKey key;
|
||||||
|
while (1) {
|
||||||
|
if (get_keypad_pressed(&key)) {
|
||||||
|
bool failed = false;
|
||||||
|
|
||||||
|
if (key == KeypadKey::star) {
|
||||||
|
// clear
|
||||||
|
entered_string = "";
|
||||||
|
} else if (key == KeypadKey::pound) {
|
||||||
|
// submit
|
||||||
|
if (entered_string != answer_num) {
|
||||||
|
strike("Incorrect answer!");
|
||||||
|
failed = true;
|
||||||
|
} else {
|
||||||
|
solved_correctly = true;;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
entered_string += char_of_keypad_key(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failed) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
lcd_clear();
|
||||||
|
lcd_print(1, 1, "Plink");
|
||||||
|
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!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (!failed) {
|
||||||
|
solved_correctly = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
stop_module_timer();
|
stop_module_timer();
|
||||||
if (solved_correctly) {
|
if (solved_correctly) {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef P001_STEP_5_H
|
#ifndef STEP_5_H
|
||||||
#define P001_STEP_5_H
|
#define STEP_5_H
|
||||||
|
|
||||||
#include "../drivers/bottom_half.h"
|
#include "../drivers/bottom_half.h"
|
||||||
#include "../drivers/game_timer.h"
|
#include "../drivers/game_timer.h"
|
||||||
@@ -15,6 +15,6 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
void p001_step5(void);
|
void step5(void);
|
||||||
|
|
||||||
#endif /* P001_STEP_5_H */
|
#endif /* STEP_5_H */
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
#include "p001_step6.h"
|
#include "step6.h"
|
||||||
|
|
||||||
__attribute__((unused))
|
__attribute__((unused))
|
||||||
static const char *TAG = "step6";
|
static const char *TAG = "step6";
|
||||||
|
|
||||||
static uint8_t cut_wires = 0;
|
static uint8_t cut_wires = 0;
|
||||||
|
|
||||||
void p001_step6(void) {
|
void step6(void) {
|
||||||
get_cut_wires();
|
get_cut_wires();
|
||||||
clear_all_pressed_released();
|
clear_all_pressed_released();
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#ifndef STEP_6_H
|
||||||
|
#define STEP_6_H
|
||||||
|
|
||||||
|
#include "wires_puzzle.h"
|
||||||
|
#include "drivers/wires.h"
|
||||||
|
#include "drivers/bottom_half.h"
|
||||||
|
#include "drivers/sd.h"
|
||||||
|
#include "drivers/speaker.h"
|
||||||
|
|
||||||
|
void step6(void);
|
||||||
|
|
||||||
|
#endif /* STEP_6_H */
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# Automatically generated file. DO NOT EDIT.
|
# Automatically generated file. DO NOT EDIT.
|
||||||
# Espressif IoT Development Framework (ESP-IDF) 5.3.5 Project Configuration
|
# Espressif IoT Development Framework (ESP-IDF) 5.3.2 Project Configuration
|
||||||
#
|
#
|
||||||
CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000
|
CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000
|
||||||
CONFIG_SOC_MPU_REGIONS_MAX_NUM=8
|
CONFIG_SOC_MPU_REGIONS_MAX_NUM=8
|
||||||
@@ -11,7 +11,6 @@ CONFIG_SOC_PHY_SUPPORTED=y
|
|||||||
CONFIG_SOC_WIFI_SUPPORTED=y
|
CONFIG_SOC_WIFI_SUPPORTED=y
|
||||||
CONFIG_SOC_TWAI_SUPPORTED=y
|
CONFIG_SOC_TWAI_SUPPORTED=y
|
||||||
CONFIG_SOC_GDMA_SUPPORTED=y
|
CONFIG_SOC_GDMA_SUPPORTED=y
|
||||||
CONFIG_SOC_UHCI_SUPPORTED=y
|
|
||||||
CONFIG_SOC_AHB_GDMA_SUPPORTED=y
|
CONFIG_SOC_AHB_GDMA_SUPPORTED=y
|
||||||
CONFIG_SOC_GPTIMER_SUPPORTED=y
|
CONFIG_SOC_GPTIMER_SUPPORTED=y
|
||||||
CONFIG_SOC_LCDCAM_SUPPORTED=y
|
CONFIG_SOC_LCDCAM_SUPPORTED=y
|
||||||
@@ -65,7 +64,6 @@ CONFIG_SOC_LIGHT_SLEEP_SUPPORTED=y
|
|||||||
CONFIG_SOC_DEEP_SLEEP_SUPPORTED=y
|
CONFIG_SOC_DEEP_SLEEP_SUPPORTED=y
|
||||||
CONFIG_SOC_LP_PERIPH_SHARE_INTERRUPT=y
|
CONFIG_SOC_LP_PERIPH_SHARE_INTERRUPT=y
|
||||||
CONFIG_SOC_PM_SUPPORTED=y
|
CONFIG_SOC_PM_SUPPORTED=y
|
||||||
CONFIG_SOC_SIMD_INSTRUCTION_SUPPORTED=y
|
|
||||||
CONFIG_SOC_XTAL_SUPPORT_40M=y
|
CONFIG_SOC_XTAL_SUPPORT_40M=y
|
||||||
CONFIG_SOC_APPCPU_HAS_CLOCK_GATING_BUG=y
|
CONFIG_SOC_APPCPU_HAS_CLOCK_GATING_BUG=y
|
||||||
CONFIG_SOC_ADC_RTC_CTRL_SUPPORTED=y
|
CONFIG_SOC_ADC_RTC_CTRL_SUPPORTED=y
|
||||||
@@ -102,8 +100,7 @@ CONFIG_SOC_CPU_HAS_FPU=y
|
|||||||
CONFIG_SOC_HP_CPU_HAS_MULTIPLE_CORES=y
|
CONFIG_SOC_HP_CPU_HAS_MULTIPLE_CORES=y
|
||||||
CONFIG_SOC_CPU_BREAKPOINTS_NUM=2
|
CONFIG_SOC_CPU_BREAKPOINTS_NUM=2
|
||||||
CONFIG_SOC_CPU_WATCHPOINTS_NUM=2
|
CONFIG_SOC_CPU_WATCHPOINTS_NUM=2
|
||||||
CONFIG_SOC_CPU_WATCHPOINT_MAX_REGION_SIZE=0x40
|
CONFIG_SOC_CPU_WATCHPOINT_MAX_REGION_SIZE=64
|
||||||
CONFIG_SOC_SIMD_PREFERRED_DATA_ALIGNMENT=16
|
|
||||||
CONFIG_SOC_DS_SIGNATURE_MAX_BIT_LEN=4096
|
CONFIG_SOC_DS_SIGNATURE_MAX_BIT_LEN=4096
|
||||||
CONFIG_SOC_DS_KEY_PARAM_MD_IV_LENGTH=16
|
CONFIG_SOC_DS_KEY_PARAM_MD_IV_LENGTH=16
|
||||||
CONFIG_SOC_DS_KEY_CHECK_MAX_WAIT_US=1100
|
CONFIG_SOC_DS_KEY_CHECK_MAX_WAIT_US=1100
|
||||||
@@ -179,7 +176,7 @@ CONFIG_SOC_RMT_CHANNELS_PER_GROUP=8
|
|||||||
CONFIG_SOC_RMT_MEM_WORDS_PER_CHANNEL=48
|
CONFIG_SOC_RMT_MEM_WORDS_PER_CHANNEL=48
|
||||||
CONFIG_SOC_RMT_SUPPORT_RX_PINGPONG=y
|
CONFIG_SOC_RMT_SUPPORT_RX_PINGPONG=y
|
||||||
CONFIG_SOC_RMT_SUPPORT_RX_DEMODULATION=y
|
CONFIG_SOC_RMT_SUPPORT_RX_DEMODULATION=y
|
||||||
CONFIG_SOC_RMT_SUPPORT_ASYNC_STOP=y
|
CONFIG_SOC_RMT_SUPPORT_TX_ASYNC_STOP=y
|
||||||
CONFIG_SOC_RMT_SUPPORT_TX_LOOP_COUNT=y
|
CONFIG_SOC_RMT_SUPPORT_TX_LOOP_COUNT=y
|
||||||
CONFIG_SOC_RMT_SUPPORT_TX_LOOP_AUTO_STOP=y
|
CONFIG_SOC_RMT_SUPPORT_TX_LOOP_AUTO_STOP=y
|
||||||
CONFIG_SOC_RMT_SUPPORT_TX_SYNCHRO=y
|
CONFIG_SOC_RMT_SUPPORT_TX_SYNCHRO=y
|
||||||
@@ -206,8 +203,7 @@ CONFIG_SOC_RTCIO_PIN_COUNT=22
|
|||||||
CONFIG_SOC_RTCIO_INPUT_OUTPUT_SUPPORTED=y
|
CONFIG_SOC_RTCIO_INPUT_OUTPUT_SUPPORTED=y
|
||||||
CONFIG_SOC_RTCIO_HOLD_SUPPORTED=y
|
CONFIG_SOC_RTCIO_HOLD_SUPPORTED=y
|
||||||
CONFIG_SOC_RTCIO_WAKE_SUPPORTED=y
|
CONFIG_SOC_RTCIO_WAKE_SUPPORTED=y
|
||||||
CONFIG_SOC_LP_IO_CLOCK_IS_INDEPENDENT=y
|
CONFIG_SOC_SDM_GROUPS=y
|
||||||
CONFIG_SOC_SDM_GROUPS=1
|
|
||||||
CONFIG_SOC_SDM_CHANNELS_PER_GROUP=8
|
CONFIG_SOC_SDM_CHANNELS_PER_GROUP=8
|
||||||
CONFIG_SOC_SDM_CLK_SUPPORT_APB=y
|
CONFIG_SOC_SDM_CLK_SUPPORT_APB=y
|
||||||
CONFIG_SOC_SPI_PERIPH_NUM=3
|
CONFIG_SOC_SPI_PERIPH_NUM=3
|
||||||
@@ -247,8 +243,6 @@ CONFIG_SOC_TIMER_GROUP_COUNTER_BIT_WIDTH=54
|
|||||||
CONFIG_SOC_TIMER_GROUP_SUPPORT_XTAL=y
|
CONFIG_SOC_TIMER_GROUP_SUPPORT_XTAL=y
|
||||||
CONFIG_SOC_TIMER_GROUP_SUPPORT_APB=y
|
CONFIG_SOC_TIMER_GROUP_SUPPORT_APB=y
|
||||||
CONFIG_SOC_TIMER_GROUP_TOTAL_TIMERS=4
|
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_VERSION=2
|
||||||
CONFIG_SOC_TOUCH_SENSOR_NUM=15
|
CONFIG_SOC_TOUCH_SENSOR_NUM=15
|
||||||
CONFIG_SOC_TOUCH_SUPPORT_SLEEP_WAKEUP=y
|
CONFIG_SOC_TOUCH_SUPPORT_SLEEP_WAKEUP=y
|
||||||
@@ -271,7 +265,6 @@ CONFIG_SOC_UART_SUPPORT_WAKEUP_INT=y
|
|||||||
CONFIG_SOC_UART_SUPPORT_APB_CLK=y
|
CONFIG_SOC_UART_SUPPORT_APB_CLK=y
|
||||||
CONFIG_SOC_UART_SUPPORT_RTC_CLK=y
|
CONFIG_SOC_UART_SUPPORT_RTC_CLK=y
|
||||||
CONFIG_SOC_UART_SUPPORT_XTAL_CLK=y
|
CONFIG_SOC_UART_SUPPORT_XTAL_CLK=y
|
||||||
CONFIG_SOC_UHCI_NUM=1
|
|
||||||
CONFIG_SOC_USB_OTG_PERIPH_NUM=1
|
CONFIG_SOC_USB_OTG_PERIPH_NUM=1
|
||||||
CONFIG_SOC_SHA_DMA_MAX_BUFFER_SIZE=3968
|
CONFIG_SOC_SHA_DMA_MAX_BUFFER_SIZE=3968
|
||||||
CONFIG_SOC_SHA_SUPPORT_DMA=y
|
CONFIG_SOC_SHA_SUPPORT_DMA=y
|
||||||
@@ -357,7 +350,6 @@ CONFIG_SOC_WIFI_HW_TSF=y
|
|||||||
CONFIG_SOC_WIFI_FTM_SUPPORT=y
|
CONFIG_SOC_WIFI_FTM_SUPPORT=y
|
||||||
CONFIG_SOC_WIFI_GCMP_SUPPORT=y
|
CONFIG_SOC_WIFI_GCMP_SUPPORT=y
|
||||||
CONFIG_SOC_WIFI_WAPI_SUPPORT=y
|
CONFIG_SOC_WIFI_WAPI_SUPPORT=y
|
||||||
CONFIG_SOC_WIFI_TXOP_SUPPORT=y
|
|
||||||
CONFIG_SOC_WIFI_CSI_SUPPORT=y
|
CONFIG_SOC_WIFI_CSI_SUPPORT=y
|
||||||
CONFIG_SOC_WIFI_MESH_SUPPORT=y
|
CONFIG_SOC_WIFI_MESH_SUPPORT=y
|
||||||
CONFIG_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW=y
|
CONFIG_SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW=y
|
||||||
@@ -374,7 +366,7 @@ CONFIG_IDF_TOOLCHAIN="gcc"
|
|||||||
CONFIG_IDF_TARGET_ARCH_XTENSA=y
|
CONFIG_IDF_TARGET_ARCH_XTENSA=y
|
||||||
CONFIG_IDF_TARGET_ARCH="xtensa"
|
CONFIG_IDF_TARGET_ARCH="xtensa"
|
||||||
CONFIG_IDF_TARGET="esp32s3"
|
CONFIG_IDF_TARGET="esp32s3"
|
||||||
CONFIG_IDF_INIT_VERSION="5.3.5"
|
CONFIG_IDF_INIT_VERSION="5.3.2"
|
||||||
CONFIG_IDF_TARGET_ESP32S3=y
|
CONFIG_IDF_TARGET_ESP32S3=y
|
||||||
CONFIG_IDF_FIRMWARE_CHIP_ID=0x0009
|
CONFIG_IDF_FIRMWARE_CHIP_ID=0x0009
|
||||||
|
|
||||||
@@ -601,21 +593,7 @@ CONFIG_APPTRACE_LOCK_ENABLE=y
|
|||||||
# Bluetooth
|
# Bluetooth
|
||||||
#
|
#
|
||||||
# CONFIG_BT_ENABLED is not set
|
# 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
|
# end of Bluetooth
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -639,7 +617,6 @@ CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM=y
|
|||||||
# Legacy ADC Driver Configuration
|
# Legacy ADC Driver Configuration
|
||||||
#
|
#
|
||||||
# CONFIG_ADC_SUPPRESS_DEPRECATE_WARN is not set
|
# CONFIG_ADC_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
# CONFIG_ADC_SKIP_LEGACY_CONFLICT_CHECK is not set
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Legacy ADC Calibration Configuration
|
# Legacy ADC Calibration Configuration
|
||||||
@@ -652,55 +629,42 @@ CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM=y
|
|||||||
# Legacy MCPWM Driver Configurations
|
# Legacy MCPWM Driver Configurations
|
||||||
#
|
#
|
||||||
# CONFIG_MCPWM_SUPPRESS_DEPRECATE_WARN is not set
|
# CONFIG_MCPWM_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
# CONFIG_MCPWM_SKIP_LEGACY_CONFLICT_CHECK is not set
|
|
||||||
# end of Legacy MCPWM Driver Configurations
|
# end of Legacy MCPWM Driver Configurations
|
||||||
|
|
||||||
#
|
#
|
||||||
# Legacy Timer Group Driver Configurations
|
# Legacy Timer Group Driver Configurations
|
||||||
#
|
#
|
||||||
# CONFIG_GPTIMER_SUPPRESS_DEPRECATE_WARN is not set
|
# CONFIG_GPTIMER_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
# CONFIG_GPTIMER_SKIP_LEGACY_CONFLICT_CHECK is not set
|
|
||||||
# end of Legacy Timer Group Driver Configurations
|
# end of Legacy Timer Group Driver Configurations
|
||||||
|
|
||||||
#
|
#
|
||||||
# Legacy RMT Driver Configurations
|
# Legacy RMT Driver Configurations
|
||||||
#
|
#
|
||||||
# CONFIG_RMT_SUPPRESS_DEPRECATE_WARN is not set
|
# CONFIG_RMT_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
# CONFIG_RMT_SKIP_LEGACY_CONFLICT_CHECK is not set
|
|
||||||
# end of Legacy RMT Driver Configurations
|
# end of Legacy RMT Driver Configurations
|
||||||
|
|
||||||
#
|
#
|
||||||
# Legacy I2S Driver Configurations
|
# Legacy I2S Driver Configurations
|
||||||
#
|
#
|
||||||
# CONFIG_I2S_SUPPRESS_DEPRECATE_WARN is not set
|
# CONFIG_I2S_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
# CONFIG_I2S_SKIP_LEGACY_CONFLICT_CHECK is not set
|
|
||||||
# end of Legacy I2S Driver Configurations
|
# 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
|
# Legacy PCNT Driver Configurations
|
||||||
#
|
#
|
||||||
# CONFIG_PCNT_SUPPRESS_DEPRECATE_WARN is not set
|
# CONFIG_PCNT_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
# CONFIG_PCNT_SKIP_LEGACY_CONFLICT_CHECK is not set
|
|
||||||
# end of Legacy PCNT Driver Configurations
|
# end of Legacy PCNT Driver Configurations
|
||||||
|
|
||||||
#
|
#
|
||||||
# Legacy SDM Driver Configurations
|
# Legacy SDM Driver Configurations
|
||||||
#
|
#
|
||||||
# CONFIG_SDM_SUPPRESS_DEPRECATE_WARN is not set
|
# CONFIG_SDM_SUPPRESS_DEPRECATE_WARN is not set
|
||||||
# CONFIG_SDM_SKIP_LEGACY_CONFLICT_CHECK is not set
|
|
||||||
# end of Legacy SDM Driver Configurations
|
# end of Legacy SDM Driver Configurations
|
||||||
|
|
||||||
#
|
#
|
||||||
# Legacy Temperature Sensor Driver Configurations
|
# Legacy Temperature Sensor Driver Configurations
|
||||||
#
|
#
|
||||||
# CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN is not set
|
# 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 Legacy Temperature Sensor Driver Configurations
|
||||||
# end of Driver Configurations
|
# end of Driver Configurations
|
||||||
|
|
||||||
@@ -723,7 +687,6 @@ CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y
|
|||||||
# CONFIG_ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL is not set
|
# CONFIG_ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL is not set
|
||||||
# CONFIG_ESP_TLS_PSK_VERIFICATION is not set
|
# CONFIG_ESP_TLS_PSK_VERIFICATION is not set
|
||||||
# CONFIG_ESP_TLS_INSECURE is not set
|
# CONFIG_ESP_TLS_INSECURE is not set
|
||||||
CONFIG_ESP_TLS_DYN_BUF_STRATEGY_SUPPORTED=y
|
|
||||||
# end of ESP-TLS
|
# end of ESP-TLS
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -761,7 +724,6 @@ CONFIG_ESP_ERR_TO_NAME_LOOKUP=y
|
|||||||
CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y
|
CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y
|
||||||
# CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM is not set
|
# CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM is not set
|
||||||
# CONFIG_GPTIMER_ISR_IRAM_SAFE 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
|
# CONFIG_GPTIMER_ENABLE_DEBUG_LOG is not set
|
||||||
# end of ESP-Driver:GPTimer Configurations
|
# end of ESP-Driver:GPTimer Configurations
|
||||||
|
|
||||||
@@ -845,14 +807,6 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y
|
|||||||
# CONFIG_UART_ISR_IN_IRAM is not set
|
# CONFIG_UART_ISR_IN_IRAM is not set
|
||||||
# end of ESP-Driver:UART Configurations
|
# 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
|
# ESP-Driver:USB Serial/JTAG Configuration
|
||||||
#
|
#
|
||||||
@@ -888,13 +842,6 @@ CONFIG_ESP_GDBSTUB_SUPPORT_TASKS=y
|
|||||||
CONFIG_ESP_GDBSTUB_MAX_TASKS=32
|
CONFIG_ESP_GDBSTUB_MAX_TASKS=32
|
||||||
# end of GDB Stub
|
# 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
|
# ESP HTTP client
|
||||||
#
|
#
|
||||||
@@ -973,8 +920,8 @@ CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES=4
|
|||||||
#
|
#
|
||||||
# Sleep Config
|
# Sleep Config
|
||||||
#
|
#
|
||||||
|
# CONFIG_ESP_SLEEP_POWER_DOWN_FLASH is not set
|
||||||
CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND=y
|
CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND=y
|
||||||
CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND=y
|
|
||||||
CONFIG_ESP_SLEEP_MSPI_NEED_ALL_IO_PU=y
|
CONFIG_ESP_SLEEP_MSPI_NEED_ALL_IO_PU=y
|
||||||
CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y
|
CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y
|
||||||
CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y
|
CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y
|
||||||
@@ -1068,11 +1015,7 @@ CONFIG_ESP_PHY_RF_CAL_PARTIAL=y
|
|||||||
# CONFIG_ESP_PHY_RF_CAL_NONE is not set
|
# CONFIG_ESP_PHY_RF_CAL_NONE is not set
|
||||||
# CONFIG_ESP_PHY_RF_CAL_FULL is not set
|
# CONFIG_ESP_PHY_RF_CAL_FULL is not set
|
||||||
CONFIG_ESP_PHY_CALIBRATION_MODE=0
|
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_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
|
# end of PHY
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1087,40 +1030,7 @@ CONFIG_PM_RESTORE_CACHE_TAGMEM_AFTER_LIGHT_SLEEP=y
|
|||||||
#
|
#
|
||||||
# ESP PSRAM
|
# ESP PSRAM
|
||||||
#
|
#
|
||||||
CONFIG_SPIRAM=y
|
# CONFIG_SPIRAM is not set
|
||||||
|
|
||||||
#
|
|
||||||
# SPI RAM config
|
|
||||||
#
|
|
||||||
CONFIG_SPIRAM_MODE_QUAD=y
|
|
||||||
# CONFIG_SPIRAM_MODE_OCT is not set
|
|
||||||
CONFIG_SPIRAM_TYPE_AUTO=y
|
|
||||||
# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set
|
|
||||||
# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set
|
|
||||||
# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set
|
|
||||||
CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y
|
|
||||||
CONFIG_SPIRAM_CLK_IO=30
|
|
||||||
CONFIG_SPIRAM_CS_IO=26
|
|
||||||
# CONFIG_SPIRAM_XIP_FROM_PSRAM is not set
|
|
||||||
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
|
|
||||||
# CONFIG_SPIRAM_RODATA is not set
|
|
||||||
# CONFIG_SPIRAM_SPEED_120M is not set
|
|
||||||
# CONFIG_SPIRAM_SPEED_80M is not set
|
|
||||||
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
|
|
||||||
CONFIG_SPIRAM_USE_MALLOC=y
|
|
||||||
CONFIG_SPIRAM_MEMTEST=y
|
|
||||||
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384
|
|
||||||
# CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is not set
|
|
||||||
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768
|
|
||||||
# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set
|
|
||||||
# CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY is not set
|
|
||||||
# end of SPI RAM config
|
|
||||||
# end of ESP PSRAM
|
# end of ESP PSRAM
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1327,6 +1237,7 @@ CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y
|
|||||||
# end of WPS Configuration Options
|
# end of WPS Configuration Options
|
||||||
|
|
||||||
# CONFIG_ESP_WIFI_DEBUG_PRINT is not set
|
# 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_ENTERPRISE_SUPPORT=y
|
||||||
# CONFIG_ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER is not set
|
# CONFIG_ESP_WIFI_ENT_FREE_DYNAMIC_BUFFER is not set
|
||||||
# end of Wi-Fi
|
# end of Wi-Fi
|
||||||
@@ -1374,7 +1285,6 @@ CONFIG_FATFS_CODEPAGE=437
|
|||||||
CONFIG_FATFS_FS_LOCK=0
|
CONFIG_FATFS_FS_LOCK=0
|
||||||
CONFIG_FATFS_TIMEOUT_MS=10000
|
CONFIG_FATFS_TIMEOUT_MS=10000
|
||||||
CONFIG_FATFS_PER_FILE_CACHE=y
|
CONFIG_FATFS_PER_FILE_CACHE=y
|
||||||
CONFIG_FATFS_ALLOC_PREFER_EXTRAM=y
|
|
||||||
# CONFIG_FATFS_USE_FASTSEEK is not set
|
# CONFIG_FATFS_USE_FASTSEEK is not set
|
||||||
CONFIG_FATFS_VFS_FSTAT_BLKSIZE=0
|
CONFIG_FATFS_VFS_FSTAT_BLKSIZE=0
|
||||||
# CONFIG_FATFS_IMMEDIATE_FSYNC is not set
|
# CONFIG_FATFS_IMMEDIATE_FSYNC is not set
|
||||||
@@ -1456,6 +1366,7 @@ CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2
|
|||||||
CONFIG_HAL_WDT_USE_ROM_IMPL=y
|
CONFIG_HAL_WDT_USE_ROM_IMPL=y
|
||||||
CONFIG_HAL_SPI_MASTER_FUNC_IN_IRAM=y
|
CONFIG_HAL_SPI_MASTER_FUNC_IN_IRAM=y
|
||||||
CONFIG_HAL_SPI_SLAVE_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)
|
# end of Hardware Abstraction Layer (HAL) and Low Level (LL)
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1544,7 +1455,6 @@ CONFIG_LWIP_DHCPS=y
|
|||||||
CONFIG_LWIP_DHCPS_LEASE_UNIT=60
|
CONFIG_LWIP_DHCPS_LEASE_UNIT=60
|
||||||
CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8
|
CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8
|
||||||
CONFIG_LWIP_DHCPS_STATIC_ENTRIES=y
|
CONFIG_LWIP_DHCPS_STATIC_ENTRIES=y
|
||||||
CONFIG_LWIP_DHCPS_ADD_DNS=y
|
|
||||||
# end of DHCP server
|
# end of DHCP server
|
||||||
|
|
||||||
# CONFIG_LWIP_AUTOIP is not set
|
# CONFIG_LWIP_AUTOIP is not set
|
||||||
@@ -1679,7 +1589,6 @@ CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y
|
|||||||
# mbedTLS
|
# mbedTLS
|
||||||
#
|
#
|
||||||
CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
|
CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
|
||||||
# CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC is not set
|
|
||||||
# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set
|
# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set
|
||||||
# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set
|
# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set
|
||||||
CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y
|
CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y
|
||||||
@@ -1696,7 +1605,6 @@ CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096
|
|||||||
# CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK is not set
|
# CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK is not set
|
||||||
# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set
|
# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set
|
||||||
CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y
|
CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y
|
||||||
# CONFIG_MBEDTLS_SSL_KEYING_MATERIAL_EXPORT is not set
|
|
||||||
CONFIG_MBEDTLS_PKCS7_C=y
|
CONFIG_MBEDTLS_PKCS7_C=y
|
||||||
# end of mbedTLS v3.x related
|
# end of mbedTLS v3.x related
|
||||||
|
|
||||||
@@ -1730,7 +1638,6 @@ CONFIG_MBEDTLS_HAVE_TIME=y
|
|||||||
# CONFIG_MBEDTLS_PLATFORM_TIME_ALT is not set
|
# CONFIG_MBEDTLS_PLATFORM_TIME_ALT is not set
|
||||||
# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set
|
# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set
|
||||||
CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y
|
CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y
|
||||||
CONFIG_MBEDTLS_SHA1_C=y
|
|
||||||
CONFIG_MBEDTLS_SHA512_C=y
|
CONFIG_MBEDTLS_SHA512_C=y
|
||||||
# CONFIG_MBEDTLS_SHA3_C is not set
|
# CONFIG_MBEDTLS_SHA3_C is not set
|
||||||
CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y
|
CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y
|
||||||
@@ -1810,7 +1717,6 @@ CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y
|
|||||||
# CONFIG_MBEDTLS_THREADING_C is not set
|
# CONFIG_MBEDTLS_THREADING_C is not set
|
||||||
CONFIG_MBEDTLS_ERROR_STRINGS=y
|
CONFIG_MBEDTLS_ERROR_STRINGS=y
|
||||||
CONFIG_MBEDTLS_FS_IO=y
|
CONFIG_MBEDTLS_FS_IO=y
|
||||||
# CONFIG_MBEDTLS_ALLOW_WEAK_CERTIFICATE_VERIFICATION is not set
|
|
||||||
# end of mbedTLS
|
# end of mbedTLS
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1845,8 +1751,6 @@ CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y
|
|||||||
# CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE is not set
|
# CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE is not set
|
||||||
# end of Newlib
|
# end of Newlib
|
||||||
|
|
||||||
CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND=y
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# NVS
|
# NVS
|
||||||
#
|
#
|
||||||
@@ -1861,12 +1765,25 @@ CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND=y
|
|||||||
# CONFIG_OPENTHREAD_ENABLED is not set
|
# CONFIG_OPENTHREAD_ENABLED is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# OpenThread Spinel
|
# Thread Operational Dataset
|
||||||
#
|
#
|
||||||
# CONFIG_OPENTHREAD_SPINEL_ONLY is not set
|
CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread-ESP"
|
||||||
# end of OpenThread Spinel
|
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_DEBUG is not set
|
CONFIG_OPENTHREAD_XTAL_ACCURACY=130
|
||||||
|
# CONFIG_OPENTHREAD_SPINEL_ONLY is not set
|
||||||
|
CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# Thread Address Query Config
|
||||||
|
#
|
||||||
|
# end of Thread Address Query Config
|
||||||
# end of OpenThread
|
# end of OpenThread
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1875,7 +1792,6 @@ CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND=y
|
|||||||
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0=y
|
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0=y
|
||||||
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=y
|
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=y
|
||||||
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2=y
|
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2=y
|
||||||
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_PATCH_VERSION=y
|
|
||||||
# end of Protocomm
|
# end of Protocomm
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1927,7 +1843,6 @@ CONFIG_SPI_FLASH_SUSPEND_QVL_SUPPORTED=y
|
|||||||
# CONFIG_SPI_FLASH_AUTO_SUSPEND is not set
|
# CONFIG_SPI_FLASH_AUTO_SUSPEND is not set
|
||||||
CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US=50
|
CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US=50
|
||||||
# CONFIG_SPI_FLASH_FORCE_ENABLE_XMC_C_SUSPEND is not set
|
# 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 Optional and Experimental Features (READ DOCS FIRST)
|
||||||
# end of Main Flash configuration
|
# end of Main Flash configuration
|
||||||
|
|
||||||
@@ -2462,6 +2377,7 @@ CONFIG_POST_EVENTS_FROM_IRAM_ISR=y
|
|||||||
CONFIG_GDBSTUB_SUPPORT_TASKS=y
|
CONFIG_GDBSTUB_SUPPORT_TASKS=y
|
||||||
CONFIG_GDBSTUB_MAX_TASKS=32
|
CONFIG_GDBSTUB_MAX_TASKS=32
|
||||||
# CONFIG_OTA_ALLOW_HTTP is not set
|
# CONFIG_OTA_ALLOW_HTTP is not set
|
||||||
|
# CONFIG_ESP_SYSTEM_PD_FLASH is not set
|
||||||
CONFIG_ESP32S3_DEEP_SLEEP_WAKEUP_DELAY=2000
|
CONFIG_ESP32S3_DEEP_SLEEP_WAKEUP_DELAY=2000
|
||||||
CONFIG_ESP_SLEEP_DEEP_SLEEP_WAKEUP_DELAY=2000
|
CONFIG_ESP_SLEEP_DEEP_SLEEP_WAKEUP_DELAY=2000
|
||||||
CONFIG_ESP32S3_RTC_CLK_SRC_INT_RC=y
|
CONFIG_ESP32S3_RTC_CLK_SRC_INT_RC=y
|
||||||
@@ -2477,9 +2393,7 @@ CONFIG_ESP32_PHY_MAX_TX_POWER=20
|
|||||||
# CONFIG_ESP32_REDUCE_PHY_TX_POWER is not set
|
# CONFIG_ESP32_REDUCE_PHY_TX_POWER is not set
|
||||||
CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU=y
|
CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU=y
|
||||||
CONFIG_PM_POWER_DOWN_TAGMEM_IN_LIGHT_SLEEP=y
|
CONFIG_PM_POWER_DOWN_TAGMEM_IN_LIGHT_SLEEP=y
|
||||||
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
|
# CONFIG_ESP32S3_SPIRAM_SUPPORT is not set
|
||||||
CONFIG_DEFAULT_PSRAM_CLK_IO=30
|
|
||||||
CONFIG_DEFAULT_PSRAM_CS_IO=26
|
|
||||||
# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_80 is not set
|
# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_80 is not set
|
||||||
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_160=y
|
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_160=y
|
||||||
# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240 is not set
|
# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240 is not set
|
||||||
@@ -2507,6 +2421,7 @@ CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y
|
|||||||
CONFIG_ESP32S3_DEBUG_OCDAWARE=y
|
CONFIG_ESP32S3_DEBUG_OCDAWARE=y
|
||||||
CONFIG_BROWNOUT_DET=y
|
CONFIG_BROWNOUT_DET=y
|
||||||
CONFIG_ESP32S3_BROWNOUT_DET=y
|
CONFIG_ESP32S3_BROWNOUT_DET=y
|
||||||
|
CONFIG_ESP32S3_BROWNOUT_DET=y
|
||||||
CONFIG_BROWNOUT_DET_LVL_SEL_7=y
|
CONFIG_BROWNOUT_DET_LVL_SEL_7=y
|
||||||
CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_7=y
|
CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_7=y
|
||||||
# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set
|
# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set
|
||||||
@@ -2536,6 +2451,8 @@ CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM=16
|
|||||||
CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y
|
CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y
|
||||||
CONFIG_ESP32_WIFI_TX_BA_WIN=6
|
CONFIG_ESP32_WIFI_TX_BA_WIN=6
|
||||||
CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y
|
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_RX_BA_WIN=6
|
||||||
CONFIG_ESP32_WIFI_NVS_ENABLED=y
|
CONFIG_ESP32_WIFI_NVS_ENABLED=y
|
||||||
CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y
|
CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y
|
||||||
@@ -2557,6 +2474,7 @@ CONFIG_WPA_MBEDTLS_TLS_CLIENT=y
|
|||||||
# CONFIG_WPA_WPS_SOFTAP_REGISTRAR is not set
|
# CONFIG_WPA_WPS_SOFTAP_REGISTRAR is not set
|
||||||
# CONFIG_WPA_WPS_STRICT is not set
|
# CONFIG_WPA_WPS_STRICT is not set
|
||||||
# CONFIG_WPA_DEBUG_PRINT 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_FLASH is not set
|
||||||
# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set
|
# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set
|
||||||
CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y
|
CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y
|
||||||
|
|||||||
Reference in New Issue
Block a user