tcMenu
Loading...
Searching...
No Matches
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
18namespace tcextras {
19
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
45 private:
46 const uint16_t calibrationMagicIoa = 0xd00d;
47 tcgfx::DeviceDrawable *drawable;
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) {
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
Definition BaseRenderers.h:50
void(* IoaCalibrationScreenPrep)(bool starting)
Definition DrawableTouchCalibrator.h:35
Definition BaseRenderers.h:282
Definition BaseRenderers.h:76
Definition DrawableTouchCalibrator.h:44
bool loadCalibration() override
Definition DrawableTouchCalibrator.cpp:173
void renderLoop(unsigned int currentValue, RenderPressMode userClick) override
Definition DrawableTouchCalibrator.cpp:33
void initCalibration(IoaCalibrationScreenPrep screenPrepFn, bool presentUiUninitialised)
Definition DrawableTouchCalibrator.h:69
void reset() override
Definition DrawableTouchCalibrator.h:92
void started(BaseMenuRenderer *currentRenderer) override
Definition DrawableTouchCalibrator.cpp:22
void reCalibrateNow() override
Definition DrawableTouchCalibrator.cpp:136
void saveCalibration() override
Definition DrawableTouchCalibrator.cpp:156
Definition DrawableTouchCalibrator.h:24
Definition DeviceDrawable.h:34
Definition GraphicsDeviceRenderer.h:59
Definition MenuTouchScreenEncoder.h:84