mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-25 05:47:44 +00:00
Touch: Migrate touch calibration to persistent memory.
This commit is contained in:
@@ -46,6 +46,8 @@ constexpr ppb_t ppb_reset_value { 0 };
|
||||
struct data_t {
|
||||
int64_t tuned_frequency;
|
||||
int32_t correction_ppb;
|
||||
uint32_t touch_calibration_magic;
|
||||
touch::Calibration touch_calibration;
|
||||
};
|
||||
|
||||
static_assert(sizeof(data_t) <= backup_ram.size(), "Persistent memory structure too large for VBAT-maintained region");
|
||||
@@ -72,5 +74,19 @@ void set_correction_ppb(const ppb_t new_value) {
|
||||
portapack::clock_manager.set_reference_ppb(clipped_value);
|
||||
}
|
||||
|
||||
static constexpr uint32_t touch_calibration_magic = 0x074af82f;
|
||||
|
||||
void set_touch_calibration(const touch::Calibration& new_value) {
|
||||
data->touch_calibration = new_value;
|
||||
data->touch_calibration_magic = touch_calibration_magic;
|
||||
}
|
||||
|
||||
const touch::Calibration& touch_calibration() {
|
||||
if( data->touch_calibration_magic != touch_calibration_magic ) {
|
||||
set_touch_calibration(touch::default_calibration());
|
||||
}
|
||||
return data->touch_calibration;
|
||||
}
|
||||
|
||||
} /* namespace persistent_memory */
|
||||
} /* namespace portapack */
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "rf_path.hpp"
|
||||
#include "touch.hpp"
|
||||
|
||||
namespace portapack {
|
||||
namespace persistent_memory {
|
||||
@@ -37,6 +38,9 @@ void set_tuned_frequency(const rf::Frequency new_value);
|
||||
ppb_t correction_ppb();
|
||||
void set_correction_ppb(const ppb_t new_value);
|
||||
|
||||
void set_touch_calibration(const touch::Calibration& new_value);
|
||||
const touch::Calibration& touch_calibration();
|
||||
|
||||
} /* namespace persistent_memory */
|
||||
} /* namespace portapack */
|
||||
|
||||
|
Reference in New Issue
Block a user