mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-25 07:10:43 -04:00
Persist audio (#1110)
* Add credits * Persist audio, add volume to apps * Remove comment * Hack around apparent alignment problem
This commit is contained in:
parent
9c39061590
commit
af448cf444
15 changed files with 46 additions and 49 deletions
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
|
||||
#include "audio.hpp"
|
||||
#include "portapack.hpp"
|
||||
#include "hal.h"
|
||||
|
||||
|
@ -75,7 +76,7 @@ constexpr clkout_freq_range_t clkout_freq_range{10, 60000};
|
|||
constexpr uint32_t clkout_freq_reset_value{10000};
|
||||
|
||||
enum data_structure_version_enum : uint32_t {
|
||||
VERSION_CURRENT = 0x10000002,
|
||||
VERSION_CURRENT = 0x10000003,
|
||||
};
|
||||
|
||||
static const uint32_t TOUCH_CALIBRATION_MAGIC = 0x074af82f;
|
||||
|
@ -305,6 +306,9 @@ struct data_t {
|
|||
// Rotary encoder dial sensitivity (encoder.cpp/hpp)
|
||||
uint8_t encoder_dial_sensitivity;
|
||||
|
||||
// Headphone volume in centibels.
|
||||
int32_t headphone_volume_cb;
|
||||
|
||||
constexpr data_t()
|
||||
: structure_version(data_structure_version_enum::VERSION_CURRENT),
|
||||
tuned_frequency(tuned_frequency_reset_value),
|
||||
|
@ -341,7 +345,8 @@ struct data_t {
|
|||
updown_frequency_rx_correction(0),
|
||||
frequency_tx_correction(0),
|
||||
updown_frequency_tx_correction(0),
|
||||
encoder_dial_sensitivity(0) {
|
||||
encoder_dial_sensitivity(0),
|
||||
headphone_volume_cb(-600) {
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -423,6 +428,9 @@ namespace cache {
|
|||
|
||||
void defaults() {
|
||||
cached_backup_ram = backup_ram_t();
|
||||
*data = data_t(); // This is a workaround for apparently alignment issue
|
||||
// that is causing backup_ram_t's block copy to be
|
||||
// misaligned. This force sets values through the struct.
|
||||
|
||||
// defaults values for recon app
|
||||
set_recon_autosave_freqs(false);
|
||||
|
@ -469,6 +477,17 @@ void set_tuned_frequency(const rf::Frequency new_value) {
|
|||
data->tuned_frequency = rf::tuning_range.clip(new_value);
|
||||
}
|
||||
|
||||
volume_t headphone_volume() {
|
||||
auto volume = volume_t::centibel(data->headphone_volume_cb);
|
||||
volume = audio::headphone::volume_range().limit(volume);
|
||||
return volume;
|
||||
}
|
||||
|
||||
void set_headphone_volume(volume_t new_value) {
|
||||
new_value = audio::headphone::volume_range().limit(new_value);
|
||||
data->headphone_volume_cb = new_value.centibel();
|
||||
}
|
||||
|
||||
ppb_t correction_ppb() {
|
||||
ppb_range.reset_if_outside(data->correction_ppb, ppb_reset_value);
|
||||
return data->correction_ppb;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue