Skip to content

Commit 9a4e27b

Browse files
committed
example updates for release
1 parent d0e3883 commit 9a4e27b

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

examples/arduino32/piPicoTftTouch/piPicoTftTouch.ino

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ void setup() {
3232
// This is added by the code generator, it initialises the menu
3333
setupMenu();
3434

35+
// check if the touch screen needs to be initialised, we provide a callback that will be called before and
36+
// after the calibration UI is shown, it should reset the screen and touch to native orientation on start, and
37+
// put it back to "menu" mode on finishing.
38+
touchCalibrator.initCalibration([](bool starting) {
39+
static iotouch::TouchOrientationSettings oldSettings = iotouch::TouchOrientationSettings(false, false, false);
40+
if(starting) {
41+
gfx.setRotation(0);
42+
oldSettings = touchScreen.changeOrientation(iotouch::TouchOrientationSettings(false, true, true));
43+
} else {
44+
gfx.setRotation(1);
45+
touchScreen.changeOrientation(oldSettings);
46+
}
47+
}, true);
48+
3549
// Add a callback to show the build version when the title is pressed
3650
// this uses the standard function to show a version dialog from tcUtil.h
3751
setTitlePressedCallback([](int) {

src/extras/DrawableTouchCalibrator.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,12 @@ uint32_t fltToU32(float val) {
136136
}
137137

138138
void IoaTouchScreenCalibrator::saveCalibration() {
139-
serlogF2(SER_TCMENU_INFO, "Saving IOA touch calibration at ", romPos);
140139
EepromAbstraction *rom = menuMgr.getEepromAbstraction();
140+
if(!rom) {
141+
serlogF(SER_ERROR, "Calibration - No ROM defined");
142+
}
143+
144+
serlogF2(SER_TCMENU_INFO, "Saving IOA touch calibration at ", romPos);
141145
rom->write16(romPos, calibrationMagicIoa);
142146
rom->write32(romPos + 2, fltToU32(calibrationHandler.getMinX()));
143147
rom->write32(romPos + 6, fltToU32(calibrationHandler.getMaxX()));
@@ -151,7 +155,7 @@ void IoaTouchScreenCalibrator::saveCalibration() {
151155
bool IoaTouchScreenCalibrator::loadCalibration() {
152156
serlogF2(SER_TCMENU_INFO, "Loading IOA touch calibration at ", romPos);
153157
EepromAbstraction *rom = menuMgr.getEepromAbstraction();
154-
if(rom->read16(romPos) != calibrationMagicIoa) {
158+
if(!rom || rom->read16(romPos) != calibrationMagicIoa) {
155159
serlogF(SER_TCMENU_INFO, "Calibrator ROM mismatch");
156160
return false;
157161
}

0 commit comments

Comments
 (0)