2022-05-11 09:09:34 +00:00
|
|
|
let cal_settings = require('Storage').readJSON("calibration.json", true) || {active: false};
|
|
|
|
Bangle.on('touch', function(button, xy) {
|
|
|
|
// do nothing if the calibration is deactivated
|
2022-05-27 08:53:52 +00:00
|
|
|
if (cal_settings.active === false || Bangle.disableCalibration) return;
|
2022-05-11 09:09:34 +00:00
|
|
|
|
|
|
|
// reload the calibration offset at each touch event /!\ bad for the flash memory
|
|
|
|
if (cal_settings.reload === true) {
|
|
|
|
cal_settings = require('Storage').readJSON("calibration.json", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// apply the calibration offset
|
2022-05-27 08:53:52 +00:00
|
|
|
xy.x = Math.round((xy.x + cal_settings.xoffset) * cal_settings.xscale);
|
|
|
|
xy.y = Math.round((xy.y + cal_settings.yoffset) * cal_settings.yscale);
|
2022-05-11 09:09:34 +00:00
|
|
|
});
|