more speaker driver updates
This commit is contained in:
parent
cc8dcfacb3
commit
41113ccafe
10
README.md
10
README.md
@ -4,6 +4,14 @@ ESP-IDF version `v5.3.2`
|
||||
|
||||
Firmware for the BLK_BOX Top control board for the puzzle `PDE001`.
|
||||
|
||||
Convert audio files to 44100Hz mono signed 16 uncompressed .wav files with the following command:
|
||||
## Resources
|
||||
|
||||
All the files in the `resources/` folder should be loaded onto a micro SD card placed in the BLK_BOX.
|
||||
|
||||
Developer Note: You can convert mp3 files to 44100Hz mono signed 16 uncompressed .wav files with the following command:
|
||||
```ffmpeg -i input.mp3 -ac 1 -ar 44100 -sample_fmt s16 output.wav```
|
||||
|
||||
File names must be no longer than `8` characters not including the extention
|
||||
File extentions must be no longer than `3` characters.
|
||||
|
||||
|
||||
|
||||
@ -286,8 +286,8 @@ bool get_switch_flipped(SwitchKey* switch_) {
|
||||
*switch_ = (SwitchKey) i;
|
||||
}
|
||||
// clear bit
|
||||
button_pressed &= ~bit_selector;
|
||||
button_released &= ~bit_selector;
|
||||
switch_flipped_up &= ~bit_selector;
|
||||
switch_flipped_down &= ~bit_selector;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#define SPEAKER_PIN_DOUT GPIO_NUM_3
|
||||
#define SAMPLE_RATE 44100
|
||||
// The maximum number of clips that can be queued at one time.
|
||||
#define CLIP_QUEUE_SIZE 8
|
||||
#define CLIP_QUEUE_SIZE 64
|
||||
|
||||
extern i2s_chan_handle_t tx_chan;
|
||||
|
||||
|
||||
@ -13,18 +13,31 @@ void init_sseg() {
|
||||
ESP_LOGI(TAG, "Sseg initialized!");
|
||||
}
|
||||
|
||||
void set_game_sseg_raw(const uint8_t* digits) {
|
||||
sseg->setSegments(digits[0], 0);
|
||||
sseg->setSegments(digits[1], 1);
|
||||
sseg->setSegments(digits[2], 2);
|
||||
sseg->setSegments(digits[3], 3);
|
||||
void set_game_sseg_raw(const uint8_t* segments) {
|
||||
sseg->setSegments(segments[0], 0);
|
||||
sseg->setSegments(segments[1], 1);
|
||||
sseg->setSegments(segments[2], 2);
|
||||
sseg->setSegments(segments[3], 3);
|
||||
}
|
||||
void clear_game_sseg() {
|
||||
sseg->setSegments(0, 0);
|
||||
sseg->setSegments(0, 1);
|
||||
sseg->setSegments(0, 2);
|
||||
sseg->setSegments(0, 3);
|
||||
}
|
||||
|
||||
void set_module_sseg_raw(const uint8_t* digits) {
|
||||
sseg->setSegments(digits[0], 4);
|
||||
sseg->setSegments(digits[1], 5);
|
||||
sseg->setSegments(digits[2], 6);
|
||||
sseg->setSegments(digits[3], 7);
|
||||
void set_module_sseg_raw(const uint8_t* segments) {
|
||||
sseg->setSegments(segments[0], 4);
|
||||
sseg->setSegments(segments[1], 5);
|
||||
sseg->setSegments(segments[2], 6);
|
||||
sseg->setSegments(segments[3], 7);
|
||||
}
|
||||
|
||||
void clear_module_sseg() {
|
||||
sseg->setSegments(0, 4);
|
||||
sseg->setSegments(0, 5);
|
||||
sseg->setSegments(0, 6);
|
||||
sseg->setSegments(0, 7);
|
||||
}
|
||||
|
||||
void set_game_sseg_num(uint32_t value, uint8_t dot_pos) {
|
||||
|
||||
@ -12,19 +12,25 @@ extern TM1640* sseg;
|
||||
/// Initializes the seven segment driver
|
||||
void init_sseg();
|
||||
|
||||
/// sets the game seven segment to the value of the digits
|
||||
/// @brief Sets the game seven segment to the value of `segments`.
|
||||
///
|
||||
/// the bits 0-6 map to segments A-G, and bit 7 is DP.
|
||||
///
|
||||
/// `digits` must have len >= 4.
|
||||
void set_game_sseg_raw(const uint8_t* digits);
|
||||
void set_game_sseg_raw(const uint8_t* segments);
|
||||
|
||||
/// sets the module seven segment to the value of the digits
|
||||
/// @brief Clears the game seven segment display.
|
||||
void clear_game_sseg();
|
||||
|
||||
/// @brief Sets the module seven segment to the value of the `segments`.
|
||||
///
|
||||
/// the bits 0-6 map to segments A-G, and bit 7 is DP.
|
||||
///
|
||||
/// `digits` must have len >= 4.
|
||||
void set_module_sseg_raw(const uint8_t* digits);
|
||||
void set_module_sseg_raw(const uint8_t* segments);
|
||||
|
||||
/// @brief Clears the game seven segment display.
|
||||
void clear_module_sseg();
|
||||
|
||||
/// sets the game timer to the given number, with the dot at position `dot_pos` from the right (0 => right-most digit).
|
||||
void set_game_sseg_num(uint32_t value, uint8_t dot_pos);
|
||||
|
||||
@ -49,7 +49,7 @@ extern "C" void app_main(void) {
|
||||
|
||||
stop_game_timer();
|
||||
ESP_LOGI(TAG, "Bomb has been diffused. Counter-Terrorists win.");
|
||||
play_clip_wav(MOUNT_POINT "/diffused.wav", true, false, 3, 0);
|
||||
play_clip_wav(MOUNT_POINT "/diffuse.wav", true, false, 3, 0);
|
||||
|
||||
display_game_results();
|
||||
}
|
||||
|
||||
@ -263,8 +263,12 @@ static bool play_part(uint32_t time) {
|
||||
lv_label_set_text(text, "");
|
||||
xSemaphoreGive(xGuiSemaphore);
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(80));
|
||||
play_clip_wav(MOUNT_POINT "/correct.wav", true, false, 3, 0);
|
||||
if (part == 2) {
|
||||
play_clip_wav(MOUNT_POINT "/stepdone.wav", true, false, 0, 0);
|
||||
vTaskDelay(pdMS_TO_TICKS(2000));
|
||||
} else {
|
||||
play_clip_wav(MOUNT_POINT "/partdone.wav", true, false, 1, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -100,14 +100,14 @@ void step2(void) {
|
||||
char c = char_of_keypad_key(key);
|
||||
// ESP_LOGI(TAG, "Pressed: %c", c);
|
||||
if (c == answer_char) {
|
||||
play_clip_wav(MOUNT_POINT "/correct.wav", true, false, 3, 0);
|
||||
solved_times++;
|
||||
if (solved_times < NUM_SOLVES) {
|
||||
play_clip_wav(MOUNT_POINT "/stepdone.wav", true, false, 0, 0);
|
||||
clean_bomb();
|
||||
new_puzzle();
|
||||
} else {
|
||||
uint8_t display_tmp[4] = {0b00000000, 0b00000000, 0b00000000, 0b00000000};
|
||||
set_module_sseg_raw(display_tmp);
|
||||
play_clip_wav(MOUNT_POINT "/partdone.wav", true, false, 0, 0);
|
||||
clear_module_sseg();
|
||||
}
|
||||
} else {
|
||||
strike_time = xTaskGetTickCount();
|
||||
|
||||
@ -80,7 +80,7 @@ void step3(void) {
|
||||
// tone = 2;
|
||||
while (get_button_pressed(nullptr)) vTaskDelay(pdMS_TO_TICKS(10));
|
||||
|
||||
play_clip_wav(MOUNT_POINT "/correct.wav", true, false, 3, 0);
|
||||
play_clip_wav(MOUNT_POINT "/ready.wav", true, false, 3, 0);
|
||||
play_clip_wav(TONE_FILES[tone], false, false, 3, 0);
|
||||
|
||||
bool correct = false;
|
||||
@ -98,7 +98,11 @@ void step3(void) {
|
||||
if (correct) {
|
||||
times++;
|
||||
clean_bomb();
|
||||
play_clip_wav(MOUNT_POINT "/correct.wav", true, false, 3, 0);
|
||||
if (times < TIMES_TO_COMPLETE) {
|
||||
play_clip_wav(MOUNT_POINT "/part-done.wav", true, false, 3, 0);
|
||||
} else {
|
||||
play_clip_wav(MOUNT_POINT "/step-done.wav", true, false, 3, 0);
|
||||
}
|
||||
} else {
|
||||
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||
}
|
||||
|
||||
@ -23,8 +23,7 @@ static const void* BACKGROUND_SRC = (void*)"A:" MOUNT_POINT "/bg.bin";
|
||||
// LV_IMG_DECLARE(background);
|
||||
// static const void* BACKGROUND_SRC = (void*)&background;
|
||||
|
||||
static QueueHandle_t stop_music;
|
||||
static bool playing_music = true;
|
||||
#define MUSIC_FILE MOUNT_POINT "/piano.wav"
|
||||
|
||||
static const char* PIECE_IMG_SRC[] = {
|
||||
NULL,
|
||||
@ -162,16 +161,15 @@ static void init_screen() {
|
||||
|
||||
xSemaphoreGive(xGuiSemaphore);
|
||||
|
||||
play_clip_wav(MOUNT_POINT "/tetris.wav", true, false, 3, 0);
|
||||
play_clip_wav(MUSIC_FILE, true, true, 4, 0);
|
||||
}
|
||||
|
||||
static void deinit_screen() {
|
||||
while (xSemaphoreTake(xGuiSemaphore, portMAX_DELAY) == pdFALSE) vTaskDelay(pdMS_TO_TICKS(10));
|
||||
|
||||
lv_obj_clean(lv_scr_act());
|
||||
xSemaphoreGive(xGuiSemaphore);
|
||||
|
||||
if (!stop_clip(MOUNT_POINT "/tetris.wav", pdMS_TO_TICKS(1000))) {
|
||||
if (!stop_clip(MUSIC_FILE, pdMS_TO_TICKS(1000))) {
|
||||
ESP_LOGW(TAG, "Can't stop, addicted to the shindig.");
|
||||
}
|
||||
}
|
||||
|
||||
BIN
resources/high-1.wav
Normal file
BIN
resources/high-1.wav
Normal file
Binary file not shown.
BIN
resources/high-3.wav
Normal file
BIN
resources/high-3.wav
Normal file
Binary file not shown.
BIN
resources/high-6.wav
Normal file
BIN
resources/high-6.wav
Normal file
Binary file not shown.
BIN
resources/low-1.wav
Normal file
BIN
resources/low-1.wav
Normal file
Binary file not shown.
BIN
resources/low-3.wav
Normal file
BIN
resources/low-3.wav
Normal file
Binary file not shown.
BIN
resources/low-6.wav
Normal file
BIN
resources/low-6.wav
Normal file
Binary file not shown.
BIN
resources/piano.wav
Normal file
BIN
resources/piano.wav
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user