From 1fc98118dec2061537651bd7eccdbf344427c0c0 Mon Sep 17 00:00:00 2001 From: radex Date: Sat, 25 May 2024 12:06:50 +0200 Subject: [PATCH] audio AND video? no way! --- firmware/scripts/audio_convert.py | 2 +- firmware/src/audio.h | 4 ++-- firmware/src/leds.cpp | 4 +++- firmware/src/main.cpp | 24 ++++++++++++------------ firmware/src/sd.cpp | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/firmware/scripts/audio_convert.py b/firmware/scripts/audio_convert.py index 9a29b50..429e14d 100644 --- a/firmware/scripts/audio_convert.py +++ b/firmware/scripts/audio_convert.py @@ -16,7 +16,7 @@ if len(data_in.shape)>1: print("resampling...") converter = 'sinc_best' # or 'sinc_fastest', ... -desired_sample_rate = 44000.0 +desired_sample_rate = 22000.0 ratio = desired_sample_rate/datasamplerate data_out = samplerate.resample(data_in, ratio, converter) diff --git a/firmware/src/audio.h b/firmware/src/audio.h index 2c9b69a..b19a60d 100644 --- a/firmware/src/audio.h +++ b/firmware/src/audio.h @@ -5,8 +5,8 @@ #define AUDIO_PIN 2 -#define AUDIO_RATE 44000.0f -#define BUFFER_LEN 512*32 +#define AUDIO_RATE 22000.0f +#define BUFFER_LEN 512*2 #define BUFFER_LEN_MS (BUFFER_LEN / AUDIO_RATE) * 1000.0f extern uint8_t wav_buffer_0[BUFFER_LEN]; diff --git a/firmware/src/leds.cpp b/firmware/src/leds.cpp index 9230cc4..5a50ba5 100644 --- a/firmware/src/leds.cpp +++ b/firmware/src/leds.cpp @@ -16,6 +16,8 @@ inline void pulsePin(uint8_t pin) { // there are glitches without this (maybe just due to breadboard...) _NOP(); _NOP(); + _NOP(); + // busy_wait_us_32(50); gpio_put(pin, LOW); } @@ -199,7 +201,7 @@ void leds_initPusher() { uint latchPin = COL_SRCLK; pio_sm_config config = leds_px_pusher_program_get_default_config(offset); - sm_config_set_clkdiv_int_frac(&config, 1, 0); + sm_config_set_clkdiv_int_frac(&config, 2, 0); // Shift OSR to the right, autopull sm_config_set_out_shift(&config, true, true, 32); diff --git a/firmware/src/main.cpp b/firmware/src/main.cpp index 1b5249a..a9c7e24 100644 --- a/firmware/src/main.cpp +++ b/firmware/src/main.cpp @@ -44,18 +44,18 @@ void loop() { sd_loadNextAudio(); } - if (Serial.available() > 0) { - char c = Serial.read(); - if (c == 'p') { - Serial.println("Paused. Press any key to continue."); - leds_disable(); - while (Serial.available() == 0) { - Serial.read(); - delay(50); - } - Serial.println("Continuing..."); - } - } + // if (Serial.available() > 0) { + // char c = Serial.read(); + // if (c == 'p') { + // Serial.println("Paused. Press any key to continue."); + // leds_disable(); + // while (Serial.available() == 0) { + // Serial.read(); + // delay(50); + // } + // Serial.println("Continuing..."); + // } + // } if (!gfx_decoder_handleLoop()) { Serial.println("Failed to load frame..."); diff --git a/firmware/src/sd.cpp b/firmware/src/sd.cpp index 782c1f0..a05b2c9 100644 --- a/firmware/src/sd.cpp +++ b/firmware/src/sd.cpp @@ -44,7 +44,7 @@ void setupSD() { // printSDConfig(); - if (!SD.begin(5000000, PIN_SPI_SS)) { + if (!SD.begin(20000000, PIN_SPI_SS)) { Serial.println("SD Initialization failed!"); // Serial.print("Error code: "); // Serial.println(SD.card.errorCode(), HEX);