Skip to content

Commit 746042f

Browse files
author
dave
committed
#177 improve the touch calibrator for integration into plugins
1 parent 41cf3cb commit 746042f

30 files changed

+1360
-977
lines changed

examples/esp/esp32Amplifier/esp32Amplifier.emf

Lines changed: 103 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"functionName": "onVolumeChanged",
2121
"readOnly": false,
2222
"localOnly": false,
23-
"visible": true
23+
"visible": true,
24+
"staticDataInRAM": false
2425
}
2526
},
2627
{
@@ -39,7 +40,8 @@
3940
"functionName": "onChannelChanged",
4041
"readOnly": false,
4142
"localOnly": false,
42-
"visible": true
43+
"visible": true,
44+
"staticDataInRAM": false
4345
}
4446
},
4547
{
@@ -55,7 +57,8 @@
5557
"functionName": "onAudioDirect",
5658
"readOnly": false,
5759
"localOnly": false,
58-
"visible": true
60+
"visible": true,
61+
"staticDataInRAM": false
5962
}
6063
},
6164
{
@@ -71,7 +74,8 @@
7174
"functionName": "onMuteSound",
7275
"readOnly": false,
7376
"localOnly": false,
74-
"visible": true
77+
"visible": true,
78+
"staticDataInRAM": false
7579
}
7680
},
7781
{
@@ -85,7 +89,8 @@
8589
"eepromAddress": -1,
8690
"readOnly": false,
8791
"localOnly": false,
88-
"visible": true
92+
"visible": true,
93+
"staticDataInRAM": false
8994
}
9095
},
9196
{
@@ -99,7 +104,8 @@
99104
"eepromAddress": -1,
100105
"readOnly": false,
101106
"localOnly": false,
102-
"visible": true
107+
"visible": true,
108+
"staticDataInRAM": false
103109
}
104110
},
105111
{
@@ -118,7 +124,8 @@
118124
"functionName": "",
119125
"readOnly": false,
120126
"localOnly": false,
121-
"visible": true
127+
"visible": true,
128+
"staticDataInRAM": false
122129
}
123130
},
124131
{
@@ -137,7 +144,8 @@
137144
"eepromAddress": 9,
138145
"readOnly": false,
139146
"localOnly": false,
140-
"visible": true
147+
"visible": true,
148+
"staticDataInRAM": false
141149
}
142150
},
143151
{
@@ -154,7 +162,8 @@
154162
"functionName": "",
155163
"readOnly": false,
156164
"localOnly": false,
157-
"visible": true
165+
"visible": true,
166+
"staticDataInRAM": false
158167
}
159168
},
160169
{
@@ -168,7 +177,8 @@
168177
"functionName": "onChannelSetttingsUpdate",
169178
"readOnly": false,
170179
"localOnly": false,
171-
"visible": true
180+
"visible": true,
181+
"staticDataInRAM": false
172182
}
173183
},
174184
{
@@ -188,7 +198,8 @@
188198
"functionName": "@warmUpChanged",
189199
"readOnly": false,
190200
"localOnly": false,
191-
"visible": true
201+
"visible": true,
202+
"staticDataInRAM": false
192203
}
193204
},
194205
{
@@ -208,7 +219,8 @@
208219
"functionName": "@valveHeatingChanged",
209220
"readOnly": false,
210221
"localOnly": false,
211-
"visible": true
222+
"visible": true,
223+
"staticDataInRAM": false
212224
}
213225
},
214226
{
@@ -222,7 +234,8 @@
222234
"functionName": "onSaveSettings",
223235
"readOnly": false,
224236
"localOnly": false,
225-
"visible": true
237+
"visible": true,
238+
"staticDataInRAM": false
226239
}
227240
},
228241
{
@@ -236,7 +249,8 @@
236249
"eepromAddress": -1,
237250
"readOnly": false,
238251
"localOnly": false,
239-
"visible": true
252+
"visible": true,
253+
"staticDataInRAM": false
240254
}
241255
},
242256
{
@@ -258,7 +272,8 @@
258272
"eepromAddress": -1,
259273
"readOnly": false,
260274
"localOnly": false,
261-
"visible": true
275+
"visible": true,
276+
"staticDataInRAM": false
262277
}
263278
},
264279
{
@@ -277,7 +292,8 @@
277292
"eepromAddress": -1,
278293
"readOnly": false,
279294
"localOnly": false,
280-
"visible": true
295+
"visible": true,
296+
"staticDataInRAM": false
281297
}
282298
},
283299
{
@@ -296,7 +312,8 @@
296312
"eepromAddress": -1,
297313
"readOnly": false,
298314
"localOnly": false,
299-
"visible": true
315+
"visible": true,
316+
"staticDataInRAM": false
300317
}
301318
},
302319
{
@@ -310,7 +327,8 @@
310327
"functionName": "onShowDialogs",
311328
"readOnly": false,
312329
"localOnly": false,
313-
"visible": true
330+
"visible": true,
331+
"staticDataInRAM": false
314332
}
315333
},
316334
{
@@ -325,7 +343,8 @@
325343
"functionName": "",
326344
"readOnly": false,
327345
"localOnly": false,
328-
"visible": true
346+
"visible": true,
347+
"staticDataInRAM": false
329348
}
330349
},
331350
{
@@ -344,7 +363,8 @@
344363
"eepromAddress": -1,
345364
"readOnly": false,
346365
"localOnly": false,
347-
"visible": true
366+
"visible": true,
367+
"staticDataInRAM": false
348368
}
349369
},
350370
{
@@ -358,7 +378,8 @@
358378
"eepromAddress": -1,
359379
"readOnly": false,
360380
"localOnly": false,
361-
"visible": true
381+
"visible": true,
382+
"staticDataInRAM": false
362383
}
363384
},
364385
{
@@ -374,7 +395,8 @@
374395
"eepromAddress": -1,
375396
"readOnly": true,
376397
"localOnly": false,
377-
"visible": true
398+
"visible": true,
399+
"staticDataInRAM": false
378400
}
379401
},
380402
{
@@ -390,7 +412,8 @@
390412
"eepromAddress": 17,
391413
"readOnly": false,
392414
"localOnly": false,
393-
"visible": true
415+
"visible": true,
416+
"staticDataInRAM": false
394417
}
395418
},
396419
{
@@ -406,7 +429,8 @@
406429
"eepromAddress": 37,
407430
"readOnly": false,
408431
"localOnly": false,
409-
"visible": true
432+
"visible": true,
433+
"staticDataInRAM": false
410434
}
411435
},
412436
{
@@ -420,7 +444,8 @@
420444
"eepromAddress": -1,
421445
"readOnly": false,
422446
"localOnly": true,
423-
"visible": true
447+
"visible": true,
448+
"staticDataInRAM": false
424449
}
425450
},
426451
{
@@ -434,7 +459,8 @@
434459
"eepromAddress": -1,
435460
"readOnly": false,
436461
"localOnly": true,
437-
"visible": true
462+
"visible": true,
463+
"staticDataInRAM": false
438464
}
439465
}
440466
],
@@ -470,6 +496,46 @@
470496
"latestValue": "10",
471497
"subsystem": "DISPLAY"
472498
},
499+
{
500+
"name": "TOUCH_SEPARATOR",
501+
"latestValue": "",
502+
"subsystem": "DISPLAY"
503+
},
504+
{
505+
"name": "TFT_TOUCH_SCREEN_REQUIRED",
506+
"latestValue": "false",
507+
"subsystem": "DISPLAY"
508+
},
509+
{
510+
"name": "TFT_TOUCH_SCREEN_CALIBRATE",
511+
"latestValue": "true",
512+
"subsystem": "DISPLAY"
513+
},
514+
{
515+
"name": "TOUCH_USE_RAW_TFT_FUNCTION",
516+
"latestValue": "true",
517+
"subsystem": "DISPLAY"
518+
},
519+
{
520+
"name": "TFT_TOUCH_CALIBRATION_STORAGE_LOC",
521+
"latestValue": "400",
522+
"subsystem": "DISPLAY"
523+
},
524+
{
525+
"name": "TFT_TOUCH_ROTATION",
526+
"latestValue": "PORTRAIT",
527+
"subsystem": "DISPLAY"
528+
},
529+
{
530+
"name": "TOUCH_CALIB_WIDTH",
531+
"latestValue": "240",
532+
"subsystem": "DISPLAY"
533+
},
534+
{
535+
"name": "TOUCH_CALIB_HEIGHT",
536+
"latestValue": "320",
537+
"subsystem": "DISPLAY"
538+
},
473539
{
474540
"name": "XPLUS_PIN",
475541
"latestValue": "2",
@@ -495,6 +561,16 @@
495561
"latestValue": "LANDSCAPE",
496562
"subsystem": "INPUT"
497563
},
564+
{
565+
"name": "TOUCH_SCREEN_CALIBRATE",
566+
"latestValue": "true",
567+
"subsystem": "INPUT"
568+
},
569+
{
570+
"name": "TOUCH_CALIBRATION_STORAGE_LOC",
571+
"latestValue": "400",
572+
"subsystem": "INPUT"
573+
},
498574
{
499575
"name": "ESPWIFI_CONCURRENT_CONNECTIONS",
500576
"latestValue": "1",
@@ -559,6 +635,7 @@
559635
"namingRecursive": true,
560636
"saveToSrc": false,
561637
"useCppMain": false,
638+
"usingSizedEEPROMStorage": false,
562639
"eepromDefinition": "eeprom:",
563640
"authenticatorDefinition": "rom:200:6",
564641
"projectIoExpanders": [

examples/esp/esp32Amplifier/esp32Amplifier.ino

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
#include "TestingDialogController.h"
2525
#include <extras/DrawableTouchCalibrator.h>
2626

27+
#define MENU_USING_CALIBRATION_MGR false
28+
2729
using namespace tcremote;
30+
using namespace iotouch;
2831

2932
const char pgmVersionHeader[] PROGMEM = "tcMenu Version";
3033

@@ -59,10 +62,26 @@ void setup() {
5962
prepareWifiForUse();
6063

6164
controller.initialise();
62-
touchScreen.calibrateMinMaxValues(0.250F, 0.890F, 0.09F, 0.88F);
6365

64-
renderer.setCustomDrawingHandler(new tcextras::TouchScreenCalibrator(&touchScreen, &renderer));
66+
#if MENU_USING_CALIBRATION_MGR == true
67+
touchCalibrator.initCalibration([](bool isStarting) {
68+
static TouchInterrogator::TouchRotation lastRotation = TouchInterrogator::PORTRAIT;
69+
if(isStarting) {
70+
tft.setRotation(0);
71+
lastRotation = touchScreen.getRotation();
72+
touchScreen.changeRotation(TouchInterrogator::PORTRAIT);
73+
} else {
74+
tft.setRotation(1);
75+
touchScreen.changeRotation(lastRotation);
76+
EEPROM.commit();
77+
}
78+
}, true);
6579

80+
// force a recalibration now if uncommented
81+
//touchCalibrator.reCalibrateNow();
82+
#else
83+
touchScreen.calibrateMinMaxValues(0.250F, 0.890F, 0.09F, 0.88F);
84+
#endif // TC_TFT_ESPI_NEEDS_TOUCH
6685
// first we get the graphics factory
6786
auto & factory = renderer.getGraphicsPropertiesFactory();
6887

0 commit comments

Comments
 (0)