Store manual calibration data in a support file

This commit is contained in:
d0k3 2019-07-28 23:30:31 +02:00
parent cb4ea7217a
commit e6b63f328b
3 changed files with 22 additions and 2 deletions

View File

@ -3,6 +3,10 @@
#include "hid.h"
#include "crc16.h"
#include "spiflash.h"
#include "support.h"
#define TOUCH_CALIB_FILENAME "gm9calib.bin"
static const HID_CalibrationData default_calib = {
@ -74,6 +78,19 @@ bool ShowTouchCalibrationDialog(void)
}
is_calibrated = HID_SetCalibrationData(calibrations, countof(dot_positions), SCREEN_WIDTH_BOT, SCREEN_HEIGHT);
if (is_calibrated) { // store calibration data in a file
SaveSupportFile(TOUCH_CALIB_FILENAME, calibrations, sizeof(calibrations));
}
return is_calibrated;
}
bool CalibrateTouchFromSupportFile(void) {
HID_CalibrationData calibrations[10];
size_t size = LoadSupportFile(TOUCH_CALIB_FILENAME, calibrations, sizeof(calibrations));
u32 n_dots = size / sizeof(HID_CalibrationData);
is_calibrated = (n_dots == 0) ? false :
HID_SetCalibrationData(calibrations, n_dots, SCREEN_WIDTH_BOT, SCREEN_HEIGHT);
return is_calibrated;
}

View File

@ -3,5 +3,6 @@
#include "common.h"
bool ShowTouchCalibrationDialog(void);
bool CalibrateTouchFromSupportFile(void);
bool CalibrateTouchFromFlash(void);
bool TouchIsCalibrated(void);

View File

@ -2124,6 +2124,7 @@ u32 GodMode(int entrypoint) {
AutoEmuNandBase(true);
InitNandCrypto(true); // (entrypoint != ENTRY_B9S);
InitExtFS();
if (!CalibrateTouchFromSupportFile())
CalibrateTouchFromFlash();
// brightness from file?
@ -2666,7 +2667,8 @@ u32 ScriptRunner(int entrypoint) {
AutoEmuNandBase(true);
InitNandCrypto(entrypoint != ENTRY_B9S);
InitExtFS();
CalibrateTouchFromFlash(); // !!! this may need some further checking
if (!CalibrateTouchFromSupportFile())
CalibrateTouchFromFlash();
// brightness from file?
s32 brightness = -1;