tcMenu
Loading...
Searching...
No Matches
src
extras
DrawableTouchCalibrator.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2018 https://www.thecoderscorner.com (Dave Cherry).
3
* This product is licensed under an Apache license, see the LICENSE file in the top-level directory.
4
*/
5
11
#ifndef TCMENU_DRAWABLETOUCHCALIBRATOR_H
12
#define TCMENU_DRAWABLETOUCHCALIBRATOR_H
13
14
#include <PlatformDetermination.h>
15
#include "../graphics/GraphicsDeviceRenderer.h"
16
#include "../graphics/MenuTouchScreenEncoder.h"
17
18
namespace
tcextras {
19
24
class
TouchCalibrationManager
{
25
public
:
26
virtual
bool
loadCalibration() = 0;
27
virtual
void
saveCalibration() = 0;
28
virtual
void
reCalibrateNow() = 0;
29
};
30
35
typedef
void (*IoaCalibrationScreenPrep)(
bool
starting);
36
44
class
IoaTouchScreenCalibrator
:
public
CustomDrawing
,
TouchCalibrationManager
{
45
private
:
46
const
uint16_t calibrationMagicIoa = 0xd00d;
47
tcgfx::DeviceDrawable
*drawable;
48
tcgfx::MenuTouchScreenManager
*touchScreen;
49
tcgfx::GraphicsDeviceRenderer
* renderer;
50
CustomDrawing
* lastDrawing =
nullptr
;
51
uint16_t romPos;
52
int
oldX = 0, oldY = 0;
53
iotouch::CalibrationHandler calibrationHandler {};
54
IoaCalibrationScreenPrep
screenPrep =
nullptr
;
55
bool
needsRedrawing =
false
;
56
57
public
:
58
explicit
IoaTouchScreenCalibrator
(
tcgfx::MenuTouchScreenManager
*touchScreen,
tcgfx::GraphicsDeviceRenderer
* renderer, uint16_t romPos)
59
: drawable(
nullptr
), touchScreen(touchScreen), renderer(renderer), romPos(romPos) {
60
}
61
69
void
initCalibration
(IoaCalibrationScreenPrep screenPrepFn,
bool
presentUiUninitialised) {
70
this->screenPrep = screenPrepFn;
71
if
(!
loadCalibration
() && presentUiUninitialised) {
72
reCalibrateNow
();
73
}
74
}
75
80
bool
loadCalibration
()
override
;
81
85
void
saveCalibration
()
override
;
86
90
void
reCalibrateNow
()
override
;
91
92
void
reset
()
override
{}
93
void
started
(
BaseMenuRenderer
*currentRenderer)
override
;
94
void
renderLoop
(
unsigned
int
currentValue,
RenderPressMode
userClick)
override
;
95
96
void
giveItBack();
97
};
98
}
// namespace tcextras
99
100
#endif
// TCMENU_DRAWABLETOUCHCALIBRATOR_H
RenderPressMode
RenderPressMode
Definition
BaseRenderers.h:50
tcextras::IoaCalibrationScreenPrep
void(* IoaCalibrationScreenPrep)(bool starting)
Definition
DrawableTouchCalibrator.h:35
BaseMenuRenderer
Definition
BaseRenderers.h:282
CustomDrawing
Definition
BaseRenderers.h:76
tcextras::IoaTouchScreenCalibrator
Definition
DrawableTouchCalibrator.h:44
tcextras::IoaTouchScreenCalibrator::loadCalibration
bool loadCalibration() override
Definition
DrawableTouchCalibrator.cpp:173
tcextras::IoaTouchScreenCalibrator::renderLoop
void renderLoop(unsigned int currentValue, RenderPressMode userClick) override
Definition
DrawableTouchCalibrator.cpp:33
tcextras::IoaTouchScreenCalibrator::initCalibration
void initCalibration(IoaCalibrationScreenPrep screenPrepFn, bool presentUiUninitialised)
Definition
DrawableTouchCalibrator.h:69
tcextras::IoaTouchScreenCalibrator::reset
void reset() override
Definition
DrawableTouchCalibrator.h:92
tcextras::IoaTouchScreenCalibrator::started
void started(BaseMenuRenderer *currentRenderer) override
Definition
DrawableTouchCalibrator.cpp:22
tcextras::IoaTouchScreenCalibrator::reCalibrateNow
void reCalibrateNow() override
Definition
DrawableTouchCalibrator.cpp:136
tcextras::IoaTouchScreenCalibrator::saveCalibration
void saveCalibration() override
Definition
DrawableTouchCalibrator.cpp:156
tcextras::TouchCalibrationManager
Definition
DrawableTouchCalibrator.h:24
tcgfx::DeviceDrawable
Definition
DeviceDrawable.h:34
tcgfx::GraphicsDeviceRenderer
Definition
GraphicsDeviceRenderer.h:59
tcgfx::MenuTouchScreenManager
Definition
MenuTouchScreenEncoder.h:84