Touch: Migrate touch calibration to persistent memory.

This commit is contained in:
Jared Boone 2016-07-27 15:30:43 -07:00
parent aa1b8f63fc
commit c424bf08f3
5 changed files with 34 additions and 22 deletions

View file

@ -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 */