2#include "TinyGPU/Boards/LCDBoards.h"
3#include "TinyGPU/Drivers/DeviceOutput.h"
4#include "TinyGPU/IO/BMPExporter.h"
5#include "TinyGPU/Input/GestureDetector.h"
6#include "TinyGPU/Surface/Surface.h"
8#include "TinyMaterialDesign/Core/Screen.h"
9#include "TinyMaterialDesign/Theme/MaterialTheme.h"
12#if !(defined(ARDUINO) || __has_include
(<Print.h>))
14#include "TinyGPU/IO/AVIWriter.h"
19#if !(defined(ARDUINO) || __has_include
(<Print.h>))
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
98 explicit App(tinygpu::LCDBoard& board,
const MaterialTheme<RGB_T>& theme = defaultTheme<RGB_T>())
121 directRender_ = !surface_.begin();
125 "App: full-screen framebuffer allocation failed - falling back to "
126 "Screen::drawDirect()");
128 fprintf(stderr,
"App: full-screen framebuffer allocation failed - falling back to "
129 "Screen::drawDirect()\n");
133 gestures_.onGesture = &App::onGestureTrampoline;
134 gestures_.isDraggable = &App::isDraggableTrampoline;
141 gestures_.update(*board_.touch());
143 if (screen_.isDirty()) {
145 screen_.drawDirect(board_.display(), scratch_,
static_cast<int32_t>(width()),
146 static_cast<int32_t>(height()));
148 screen_.draw(surface_);
149 display_.writeData(surface_);
166 return tinygpu::millis();
171 if (directRender_)
return false;
172 if (screen_.isDirty()) {
173 screen_.draw(surface_);
174 display_.writeData(surface_);
176 tinygpu::BMPExporter<RGB_T> exporter(surface_);
177 return exporter.save(out);
209 static void onGestureTrampoline(tinygpu::GestureEvent& event) { instance_->screen_.handleGesture(event); }
210 static bool isDraggableTrampoline(int16_t x, int16_t y) {
211 return instance_->screen_.isDraggableAt(x, y);
214 static App<RGB_T>* instance_;
216 tinygpu::LCDBoard& board_;
217 tinygpu::Surface<RGB_T> surface_;
218 tinygpu::Surface<RGB_T> scratch_;
219 tinygpu::DeviceOutput<RGB_T> display_;
220 tinygpu::GestureDetector gestures_;
222 bool directRender_ =
false;
225template <
typename RGB_T>
226App<RGB_T>*
App<RGB_T>::instance_ =
nullptr;
Bundles the surface + display + gesture routing + Screen boilerplate that every single-widget example...
Definition: App.h:93
App(tinygpu::LCDBoard &board, const MaterialTheme< RGB_T > &theme=defaultTheme< RGB_T >())
Definition: App.h:98
bool usesDirectRender() const
Definition: App.h:184
bool saveScreenshot(Print &out)
Definition: App.h:170
static uint32_t nowMillis()
Definition: App.h:162
size_t width() const
Definition: App.h:205
Screen< RGB_T > & screen()
Definition: App.h:188
void begin()
Definition: App.h:118
void update()
Definition: App.h:140
const MaterialTheme< RGB_T > & theme() const
Definition: App.h:193
size_t height() const
Definition: App.h:206
tinygpu::Surface< RGB_T > & surface()
Definition: App.h:199
Owns a set of widgets, draws them, and routes gesture events to whichever one should handle each even...
Definition: Screen.h:71
Definition: AnchorLayout.h:4
Bundles a color scheme, shape tokens, typography, and spacing into one theme, passed to widgets so th...
Definition: MaterialTheme.h:50