fix: add frame buffering to NoAudioProcessor for ESP32-C5 (#1766)
* add: Moji 2 has built-in ESP32-C5 dual band Wi-Fi * feat: PowerSaveTimer 160 >> 240 * fix(audio): add frame buffering to NoAudioProcessor On chips where CONFIG_USE_AUDIO_PROCESSOR is unavailable (e.g., ESP32-C5, which is excluded by Kconfig despite having PSRAM), NoAudioProcessor is used. The original implementation passed through 160-sample chunks directly, but the Opus encoder expects 960 samples (60ms @ 16kHz), resulting in frame size mismatch errors, high CPU usage, and watchdog resets. Added output_buffer_ to accumulate audio samples until reaching frame_samples_ (960) before outputting, matching AfeAudioProcessor behavior. other: Turn off sleep mode (PowerSaveTimer)
This commit is contained in:
@ -6,7 +6,6 @@
|
||||
"sdkconfig_append": [
|
||||
"CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y",
|
||||
"CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"partitions/v2/16m.csv\"",
|
||||
"CONFIG_PM_ENABLE=y",
|
||||
"CONFIG_FREERTOS_USE_TICKLESS_IDLE=y",
|
||||
"CONFIG_SPIRAM_MODE_QUAD=y",
|
||||
"CONFIG_SPIRAM_SPEED_80M=y",
|
||||
|
||||
@ -227,16 +227,19 @@ private:
|
||||
void InitializeBatteryMonitor() {
|
||||
adc_battery_monitor_ = new AdcBatteryMonitor(ADC_UNIT_1, ADC_CHANNEL_3, 5100000, 5100000, GPIO_NUM_NC);
|
||||
adc_battery_monitor_->OnChargingStatusChanged([this](bool is_charging) {
|
||||
if (is_charging) {
|
||||
power_save_timer_->SetEnabled(false);
|
||||
} else {
|
||||
power_save_timer_->SetEnabled(true);
|
||||
if (power_save_timer_ != nullptr){
|
||||
if (is_charging) {
|
||||
power_save_timer_->SetEnabled(false);
|
||||
} else {
|
||||
power_save_timer_->SetEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void InitializePowerSaveTimer() {
|
||||
power_save_timer_ = new PowerSaveTimer(240, 300);
|
||||
power_save_timer_ = new PowerSaveTimer(240, -1, -1);
|
||||
power_save_timer_->OnEnterSleepMode([this]() {
|
||||
GetDisplay()->SetPowerSaveMode(true);
|
||||
});
|
||||
@ -348,8 +351,8 @@ private:
|
||||
public:
|
||||
MovecallMoji2ESP32C5() : boot_button_(BOOT_BUTTON_GPIO) {
|
||||
InitializeCodecI2c();
|
||||
InitializeBatteryMonitor();
|
||||
InitializePowerSaveTimer();
|
||||
InitializeBatteryMonitor();
|
||||
InitializeSpi();
|
||||
InitializeSt77916Display();
|
||||
InitializeButtons();
|
||||
|
||||
Reference in New Issue
Block a user