@geastack/host 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +25 -0
- package/audio_runtime.cpp +807 -0
- package/bluetooth.cpp +125 -0
- package/geolocation.cpp +43 -0
- package/host/apps.cpp +20 -0
- package/host/audio.cpp +240 -0
- package/host/ble.cpp +239 -0
- package/host/camera.cpp +193 -0
- package/host/display.cpp +230 -0
- package/host/fetch.cpp +1060 -0
- package/host/geolocation.cpp +31 -0
- package/host/gpio.cpp +55 -0
- package/host/http.cpp +349 -0
- package/host/image.cpp +335 -0
- package/host/imu.cpp +51 -0
- package/host/input.cpp +12 -0
- package/host/media.cpp +579 -0
- package/host/memory.cpp +91 -0
- package/host/rtc.cpp +212 -0
- package/host/rtc_esp.cpp +291 -0
- package/host/tile_loader.cpp +478 -0
- package/host/timers.cpp +327 -0
- package/host/touch.cpp +25 -0
- package/host/websocket.cpp +279 -0
- package/host/wifi.cpp +99 -0
- package/include/gea/embedded-host.h +38 -0
- package/include/host/apps.h +15 -0
- package/include/host/audio.h +158 -0
- package/include/host/backends.h +455 -0
- package/include/host/battery.h +25 -0
- package/include/host/camera.h +236 -0
- package/include/host/clock.h +45 -0
- package/include/host/device_control.h +23 -0
- package/include/host/display.h +266 -0
- package/include/host/display_orientation.h +291 -0
- package/include/host/fetch.h +310 -0
- package/include/host/gpio.h +36 -0
- package/include/host/http.h +161 -0
- package/include/host/image.h +144 -0
- package/include/host/input.h +14 -0
- package/include/host/media.h +165 -0
- package/include/host/memory.h +44 -0
- package/include/host/navigator.h +283 -0
- package/include/host/notify.h +41 -0
- package/include/host/profiler.h +49 -0
- package/include/host/rtc.h +174 -0
- package/include/host/storage.h +141 -0
- package/include/host/tile_loader.h +59 -0
- package/include/host/timers.h +41 -0
- package/include/host/touch.h +20 -0
- package/include/host/websocket.h +179 -0
- package/include/host/window.h +31 -0
- package/input.cpp +68 -0
- package/package.json +27 -0
- package/services/app_state.cpp +19 -0
- package/services/battery_service.cpp +19 -0
- package/services/bluetooth_service.cpp +37 -0
- package/services/diagnostics.cpp +233 -0
- package/services/diagnostics_connection.cpp +231 -0
- package/services/diagnostics_internal.h +15 -0
- package/services/diagnostics_server.cpp +135 -0
- package/services/mirror.cpp +364 -0
- package/services/network_services.cpp +62 -0
- package/services/runtime_log.cpp +23 -0
- package/services/settings_surface.h +221 -0
- package/wifi.cpp +185 -0
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
#include <cstdint>
|
|
5
|
+
#include <string>
|
|
6
|
+
#include <vector>
|
|
7
|
+
|
|
8
|
+
#include "geolocation.h"
|
|
9
|
+
|
|
10
|
+
namespace gea::framework::sensors {
|
|
11
|
+
|
|
12
|
+
class AccelerometerBackend {
|
|
13
|
+
public:
|
|
14
|
+
static void init();
|
|
15
|
+
static void close();
|
|
16
|
+
static void calibrateBias();
|
|
17
|
+
static double tiltX();
|
|
18
|
+
static double tiltY();
|
|
19
|
+
static double accelerationX();
|
|
20
|
+
static double accelerationY();
|
|
21
|
+
static double accelerationZ();
|
|
22
|
+
static double gyroscopeX();
|
|
23
|
+
static double gyroscopeY();
|
|
24
|
+
static double gyroscopeZ();
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
} // namespace gea::framework::sensors
|
|
28
|
+
|
|
29
|
+
namespace gea::framework::camera {
|
|
30
|
+
|
|
31
|
+
class CameraBackend {
|
|
32
|
+
public:
|
|
33
|
+
static bool isAvailable();
|
|
34
|
+
static bool hasPermission();
|
|
35
|
+
static bool requestPermission();
|
|
36
|
+
|
|
37
|
+
// facing: "front" | "back" | <device id from deviceIdAt>
|
|
38
|
+
// preferredWidth/Height: 0 means "platform default"
|
|
39
|
+
static bool open(const std::string &facing, double preferredWidth, double preferredHeight);
|
|
40
|
+
static void close();
|
|
41
|
+
static bool isOpen();
|
|
42
|
+
|
|
43
|
+
static double width();
|
|
44
|
+
static double height();
|
|
45
|
+
static double orientation();
|
|
46
|
+
static std::string facing();
|
|
47
|
+
|
|
48
|
+
static double deviceCount();
|
|
49
|
+
static std::string deviceIdAt(double index);
|
|
50
|
+
static std::string deviceFacingAt(double index);
|
|
51
|
+
|
|
52
|
+
// Blit the latest preview frame into the framebuffer.
|
|
53
|
+
// destWidth/destHeight = 0 means draw at native size.
|
|
54
|
+
static void draw(double x, double y, double destWidth, double destHeight);
|
|
55
|
+
|
|
56
|
+
// Capture a still image; returns the ImageStore id or -1 on failure.
|
|
57
|
+
static double capture();
|
|
58
|
+
static double captureMirrored();
|
|
59
|
+
|
|
60
|
+
// Video recording (esp32-p4: MJPEG). startRecording returns true on success;
|
|
61
|
+
// stopRecording returns the clip duration in ms, or -1 on failure.
|
|
62
|
+
static bool startRecording(const std::string &path, double fps);
|
|
63
|
+
static double stopRecording();
|
|
64
|
+
static bool isRecording();
|
|
65
|
+
|
|
66
|
+
static void setFlash(const std::string &mode);
|
|
67
|
+
static void setZoom(double factor);
|
|
68
|
+
static void setMirror(bool mirror);
|
|
69
|
+
|
|
70
|
+
// Capture controls forwarded to the platform backend. See camera.h for the
|
|
71
|
+
// accepted `mode` keywords; numeric args default to 0 ("leave as is").
|
|
72
|
+
static void setExposure(const std::string &mode, double bias, double iso, double durationMs);
|
|
73
|
+
static void setWhiteBalance(const std::string &mode, double temperatureK, double tint);
|
|
74
|
+
static void setFocus(const std::string &mode, double pointX, double pointY);
|
|
75
|
+
static void setTorch(const std::string &mode, double level);
|
|
76
|
+
|
|
77
|
+
// Options-record open form. Header-only template so the generated
|
|
78
|
+
// cpp can pass any record-shaped value (geatsc emits gea_cpp_value or
|
|
79
|
+
// a struct with named fields). Reads facing/width/height when present.
|
|
80
|
+
template <typename Options>
|
|
81
|
+
static bool openWithOptions(const Options &options) {
|
|
82
|
+
std::string facing;
|
|
83
|
+
double width = 0.0;
|
|
84
|
+
double height = 0.0;
|
|
85
|
+
if constexpr (requires { options.facing; }) {
|
|
86
|
+
facing = static_cast<std::string>(options.facing);
|
|
87
|
+
} else if constexpr (requires { options.record_get_literal("facing"); }) {
|
|
88
|
+
auto value = options.record_get_literal("facing");
|
|
89
|
+
if (!value.is_nullish()) facing = static_cast<std::string>(value);
|
|
90
|
+
}
|
|
91
|
+
if (facing.empty()) facing = "back";
|
|
92
|
+
if constexpr (requires { options.width; }) {
|
|
93
|
+
width = static_cast<double>(options.width);
|
|
94
|
+
} else if constexpr (requires { options.record_get_literal("width"); }) {
|
|
95
|
+
auto value = options.record_get_literal("width");
|
|
96
|
+
if (!value.is_nullish()) width = static_cast<double>(value);
|
|
97
|
+
}
|
|
98
|
+
if constexpr (requires { options.height; }) {
|
|
99
|
+
height = static_cast<double>(options.height);
|
|
100
|
+
} else if constexpr (requires { options.record_get_literal("height"); }) {
|
|
101
|
+
auto value = options.record_get_literal("height");
|
|
102
|
+
if (!value.is_nullish()) height = static_cast<double>(value);
|
|
103
|
+
}
|
|
104
|
+
return open(facing, width, height);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Options-record capture form. Reads `mirror` to decide which path.
|
|
108
|
+
template <typename Options>
|
|
109
|
+
static double captureWithOptions(const Options &options) {
|
|
110
|
+
bool mirror = false;
|
|
111
|
+
if constexpr (requires { options.mirror; }) {
|
|
112
|
+
mirror = static_cast<bool>(options.mirror);
|
|
113
|
+
} else if constexpr (requires { options.record_get_literal("mirror"); }) {
|
|
114
|
+
auto value = options.record_get_literal("mirror");
|
|
115
|
+
if (!value.is_nullish()) mirror = static_cast<bool>(value);
|
|
116
|
+
}
|
|
117
|
+
return mirror ? captureMirrored() : capture();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Field readers shared by the options-record control forms below. The
|
|
121
|
+
// dynamic (gea_cpp_value record) arm reads through record_get_literal; typed
|
|
122
|
+
// options — geatsc `__gea_type_*` interface structs and the plugin's
|
|
123
|
+
// anonymous options structs — are read field-by-field in each control form
|
|
124
|
+
// below, since member selection needs the field name at compile time.
|
|
125
|
+
template <typename Options>
|
|
126
|
+
static std::string optionString(const Options &options, const char *field, const std::string &fallback) {
|
|
127
|
+
if constexpr (requires { options.record_get_literal(field); }) {
|
|
128
|
+
auto value = options.record_get_literal(field);
|
|
129
|
+
if (!value.is_nullish()) return static_cast<std::string>(value);
|
|
130
|
+
}
|
|
131
|
+
return fallback;
|
|
132
|
+
}
|
|
133
|
+
template <typename Options>
|
|
134
|
+
static double optionNumber(const Options &options, const char *field, double fallback) {
|
|
135
|
+
if constexpr (requires { options.record_get_literal(field); }) {
|
|
136
|
+
auto value = options.record_get_literal(field);
|
|
137
|
+
if (!value.is_nullish()) return static_cast<double>(value);
|
|
138
|
+
}
|
|
139
|
+
return fallback;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Per-field typed-first read: prefer a real struct member (guarded by the
|
|
143
|
+
// geatsc `__gea_has_<field>` presence flag when the struct carries one; the
|
|
144
|
+
// plugin's anonymous options structs only contain fields the literal wrote,
|
|
145
|
+
// so bare presence of the member means present), falling back to the dynamic
|
|
146
|
+
// record arm, then the default. Expression-shaped so the readers stay
|
|
147
|
+
// declarative; undefined behind this header's include boundary.
|
|
148
|
+
#define GEA_CAMERA_OPTION_FIELD(options, field, fallback, castT) \
|
|
149
|
+
([&]() { \
|
|
150
|
+
if constexpr (requires { (options).field; }) { \
|
|
151
|
+
bool __gea_present = true; \
|
|
152
|
+
if constexpr (requires { (options).__gea_has_##field; }) __gea_present = (options).__gea_has_##field; \
|
|
153
|
+
if (__gea_present) return static_cast<castT>((options).field); \
|
|
154
|
+
} \
|
|
155
|
+
return static_cast<castT>(optionsFieldFallback_##castT((options), #field, fallback)); \
|
|
156
|
+
}())
|
|
157
|
+
|
|
158
|
+
template <typename Options>
|
|
159
|
+
static std::string optionsFieldFallback_OptionStringT(const Options &options, const char *field, const std::string &fallback) {
|
|
160
|
+
return optionString(options, field, fallback);
|
|
161
|
+
}
|
|
162
|
+
template <typename Options>
|
|
163
|
+
static double optionsFieldFallback_OptionNumberT(const Options &options, const char *field, double fallback) {
|
|
164
|
+
return optionNumber(options, field, fallback);
|
|
165
|
+
}
|
|
166
|
+
using OptionStringT = std::string;
|
|
167
|
+
using OptionNumberT = double;
|
|
168
|
+
|
|
169
|
+
// Options-record control forms — mirror open/capture so call sites can pass
|
|
170
|
+
// the same `{ ... }` record shape the TypeScript API uses, whether it lowers
|
|
171
|
+
// to a typed struct (preferred) or a dynamic gea_cpp_value record (legacy).
|
|
172
|
+
template <typename Options>
|
|
173
|
+
static void setExposureWithOptions(const Options &options) {
|
|
174
|
+
setExposure(GEA_CAMERA_OPTION_FIELD(options, mode, std::string("continuous"), OptionStringT),
|
|
175
|
+
GEA_CAMERA_OPTION_FIELD(options, bias, 0.0, OptionNumberT),
|
|
176
|
+
GEA_CAMERA_OPTION_FIELD(options, iso, 0.0, OptionNumberT),
|
|
177
|
+
GEA_CAMERA_OPTION_FIELD(options, durationMs, 0.0, OptionNumberT));
|
|
178
|
+
}
|
|
179
|
+
template <typename Options>
|
|
180
|
+
static void setWhiteBalanceWithOptions(const Options &options) {
|
|
181
|
+
setWhiteBalance(GEA_CAMERA_OPTION_FIELD(options, mode, std::string("auto"), OptionStringT),
|
|
182
|
+
GEA_CAMERA_OPTION_FIELD(options, temperature, 0.0, OptionNumberT),
|
|
183
|
+
GEA_CAMERA_OPTION_FIELD(options, tint, 0.0, OptionNumberT));
|
|
184
|
+
}
|
|
185
|
+
template <typename Options>
|
|
186
|
+
static void setFocusWithOptions(const Options &options) {
|
|
187
|
+
double px = 0.0;
|
|
188
|
+
double py = 0.0;
|
|
189
|
+
if constexpr (requires { options.point; }) {
|
|
190
|
+
auto &&point = options.point;
|
|
191
|
+
px = GEA_CAMERA_OPTION_FIELD(point, x, 0.0, OptionNumberT);
|
|
192
|
+
py = GEA_CAMERA_OPTION_FIELD(point, y, 0.0, OptionNumberT);
|
|
193
|
+
} else if constexpr (requires { options.record_get_literal("point"); }) {
|
|
194
|
+
auto point = options.record_get_literal("point");
|
|
195
|
+
if (!point.is_nullish()) {
|
|
196
|
+
px = optionNumber(point, "x", 0.0);
|
|
197
|
+
py = optionNumber(point, "y", 0.0);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
setFocus(GEA_CAMERA_OPTION_FIELD(options, mode, std::string("continuous"), OptionStringT), px, py);
|
|
201
|
+
}
|
|
202
|
+
template <typename Options>
|
|
203
|
+
static bool startRecordingWithOptions(const Options &options) {
|
|
204
|
+
return startRecording(GEA_CAMERA_OPTION_FIELD(options, path, std::string(""), OptionStringT),
|
|
205
|
+
GEA_CAMERA_OPTION_FIELD(options, fps, 0.0, OptionNumberT));
|
|
206
|
+
}
|
|
207
|
+
#undef GEA_CAMERA_OPTION_FIELD
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// Registers the platform camera backend with the runtime's board-independent
|
|
211
|
+
// preview seam (gea::embedded::ui::CameraSurface). Targets that link a camera
|
|
212
|
+
// backend call this during init (e.g. from app_main), the same way Wifi
|
|
213
|
+
// registers its driver. Defined in host/camera.cpp.
|
|
214
|
+
void registerCameraSurface();
|
|
215
|
+
|
|
216
|
+
} // namespace gea::framework::camera
|
|
217
|
+
|
|
218
|
+
namespace gea::framework::network {
|
|
219
|
+
|
|
220
|
+
class WifiBackend {
|
|
221
|
+
public:
|
|
222
|
+
static bool enabled();
|
|
223
|
+
static void setEnabled(bool enabled);
|
|
224
|
+
static bool connected();
|
|
225
|
+
static double rssi();
|
|
226
|
+
static std::string ssid();
|
|
227
|
+
static std::string ip();
|
|
228
|
+
static std::string mac();
|
|
229
|
+
static void configure(const std::string &ssid, const std::string &password);
|
|
230
|
+
static bool waitForConnection(double timeoutMs);
|
|
231
|
+
static void startScan();
|
|
232
|
+
static bool scanning();
|
|
233
|
+
static double scanCount();
|
|
234
|
+
static std::string scanSsidAt(double index);
|
|
235
|
+
static double scanRssiAt(double index);
|
|
236
|
+
static bool scanSecuredAt(double index);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
} // namespace gea::framework::network
|
|
240
|
+
|
|
241
|
+
namespace gea::framework::geolocation {
|
|
242
|
+
|
|
243
|
+
class GeolocationBackend {
|
|
244
|
+
public:
|
|
245
|
+
static bool hasFix();
|
|
246
|
+
static GeolocationPosition currentPosition();
|
|
247
|
+
static double latitude();
|
|
248
|
+
static double longitude();
|
|
249
|
+
static double accuracy();
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
} // namespace gea::framework::geolocation
|
|
253
|
+
|
|
254
|
+
namespace gea::framework::bluetooth {
|
|
255
|
+
|
|
256
|
+
class HidBackend {
|
|
257
|
+
public:
|
|
258
|
+
static void init(const std::string &device_name, double appearance, const std::string &mac_address);
|
|
259
|
+
static bool enabled();
|
|
260
|
+
static void setEnabled(bool enabled);
|
|
261
|
+
static void startAdvertising();
|
|
262
|
+
static void stopAdvertising();
|
|
263
|
+
static bool connected();
|
|
264
|
+
static bool bound();
|
|
265
|
+
static double batteryLevel();
|
|
266
|
+
static std::string mac();
|
|
267
|
+
static std::string deviceName();
|
|
268
|
+
static void keyTap(double hid_code);
|
|
269
|
+
static void keyDown(double modifier, double hid_code);
|
|
270
|
+
static void keyUp();
|
|
271
|
+
static void mouseMove(double dx, double dy, double buttons, double wheel);
|
|
272
|
+
static void mouseClick(double button);
|
|
273
|
+
static void midiEnable();
|
|
274
|
+
static bool midiBound();
|
|
275
|
+
static void midiSend(const std::vector<double> &bytes);
|
|
276
|
+
static void midiStartScan();
|
|
277
|
+
static void midiStopScan();
|
|
278
|
+
static bool midiScanning();
|
|
279
|
+
static double midiScanCount();
|
|
280
|
+
static std::string midiScanNameAt(double index);
|
|
281
|
+
static void midiConnect(double index);
|
|
282
|
+
static void midiDisconnect();
|
|
283
|
+
static void hidHostStartScan();
|
|
284
|
+
static void hidHostStopScan();
|
|
285
|
+
static bool hidHostScanning();
|
|
286
|
+
static double hidHostScanCount();
|
|
287
|
+
static std::string hidHostScanNameAt(double index);
|
|
288
|
+
static void hidHostConnect(double index);
|
|
289
|
+
static void hidHostDisconnect();
|
|
290
|
+
static bool hidHostBound();
|
|
291
|
+
static double hidHostReportCount();
|
|
292
|
+
static double hidHostReportIdAt(double index);
|
|
293
|
+
static double hidHostReportLenAt(double index);
|
|
294
|
+
static double hidHostReportByteAt(double index, double byteIndex);
|
|
295
|
+
static void hidHostClearReports();
|
|
296
|
+
static double connectionCount();
|
|
297
|
+
static double connectionKindAt(double index);
|
|
298
|
+
static std::string connectionNameAt(double index);
|
|
299
|
+
static void configSetDocument(const std::vector<double> &bytes);
|
|
300
|
+
static double configPendingLength();
|
|
301
|
+
static double configPendingByteAt(double index);
|
|
302
|
+
static void configConsumePending();
|
|
303
|
+
static bool configPairing();
|
|
304
|
+
static std::string configPairCode();
|
|
305
|
+
static void configDismissPairing();
|
|
306
|
+
static void configPushActivity(double index);
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
} // namespace gea::framework::bluetooth
|
|
310
|
+
|
|
311
|
+
namespace gea::framework::audio {
|
|
312
|
+
|
|
313
|
+
class AudioBackend {
|
|
314
|
+
public:
|
|
315
|
+
static double volume();
|
|
316
|
+
static void setVolume(double volume);
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
} // namespace gea::framework::audio
|
|
320
|
+
|
|
321
|
+
namespace gea::framework::display {
|
|
322
|
+
|
|
323
|
+
class DisplayBackend {
|
|
324
|
+
public:
|
|
325
|
+
static double brightness();
|
|
326
|
+
static void setBrightness(double brightness);
|
|
327
|
+
static void setAA(double samples);
|
|
328
|
+
static void setFlushConfig(double rows, double depth);
|
|
329
|
+
// E-paper refresh policy + custom waveforms (weak-hooked: no-op on boards
|
|
330
|
+
// without an e-paper panel). Negative numbers = leave unchanged. LUTs must
|
|
331
|
+
// be the panel's full waveform table (159 bytes on SSD1681-class panels);
|
|
332
|
+
// hasLut=true with an empty vector restores the board's vendor default.
|
|
333
|
+
static void setEpaperRefreshConfig(double fullRefreshEveryPartials,
|
|
334
|
+
double fullRefreshHardCapPartials,
|
|
335
|
+
double fastStreakWindowMs,
|
|
336
|
+
const std::vector<std::uint8_t> &partialLut, bool hasPartialLut,
|
|
337
|
+
const std::vector<std::uint8_t> &fastLut, bool hasFastLut);
|
|
338
|
+
static void epaperFullRefresh();
|
|
339
|
+
// Toggle 4-level grayscale rendering on e-paper boards that support it
|
|
340
|
+
// (weak-hooked no-op elsewhere). Gray mode trades the fast partial waveform
|
|
341
|
+
// for a slower full-refresh that drives 4 reflectance levels.
|
|
342
|
+
static void setEpaperGrayscale(bool enabled);
|
|
343
|
+
static void setEpaperFullOnCover(bool enabled);
|
|
344
|
+
static double nativeWidth();
|
|
345
|
+
static double nativeHeight();
|
|
346
|
+
static std::string orientation();
|
|
347
|
+
static void setOrientation(const std::string &orientation);
|
|
348
|
+
static std::vector<std::string> supportedOrientations();
|
|
349
|
+
static void setSupportedOrientations(const std::vector<std::string> &orientations);
|
|
350
|
+
static void setSupportedOrientations(const std::string &orientation);
|
|
351
|
+
static bool autoRotate();
|
|
352
|
+
static void setAutoRotate(bool enabled);
|
|
353
|
+
// Opt-in tearing sync (TE/VBlank). No-op on targets without a TE line.
|
|
354
|
+
static void setVSync(bool on);
|
|
355
|
+
// Opt-in large-static-text sprite cache (default off). Forwards to the shared
|
|
356
|
+
// software rasterizer (Canvas); no per-platform behavior.
|
|
357
|
+
static void setTextRasterCache(bool on);
|
|
358
|
+
// Opt-in pre-packed glyph stamping over a declared solid backdrop (packed
|
|
359
|
+
// 4bpp targets; no-op elsewhere). 0xRRGGBB; negative disables.
|
|
360
|
+
static void setTextSolidBackdrop(int rrggbb);
|
|
361
|
+
// Mark the next present as a full-screen damage-all (skip the dirty-rect diff
|
|
362
|
+
// and the persistent previous-frame copy). No-op on targets without a present diff.
|
|
363
|
+
static void invalidate();
|
|
364
|
+
static std::string pixelFormat();
|
|
365
|
+
static void setPixelFormat(const std::string &format);
|
|
366
|
+
static std::string panelPixelFormat();
|
|
367
|
+
static std::vector<std::string> supportedPixelFormats();
|
|
368
|
+
static void updateAutoRotationFromAccelerometer();
|
|
369
|
+
static void updateAutoRotation(double acceleration_x, double acceleration_y, double acceleration_z);
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
} // namespace gea::framework::display
|
|
373
|
+
|
|
374
|
+
namespace gea::framework::memory {
|
|
375
|
+
|
|
376
|
+
class MemoryBackend {
|
|
377
|
+
public:
|
|
378
|
+
static double internalFree();
|
|
379
|
+
static double internalLargestFreeBlock();
|
|
380
|
+
static double internalMinimumFree();
|
|
381
|
+
static double psramFree();
|
|
382
|
+
static double currentTaskStackHighWaterMark();
|
|
383
|
+
static double geaMainStackBytes();
|
|
384
|
+
static double geaInitStackBytes();
|
|
385
|
+
static double appFrameStackWords();
|
|
386
|
+
static double appFrameStackBytes();
|
|
387
|
+
static double displayFlushConfiguredRows();
|
|
388
|
+
static double displayFlushConfiguredDepth();
|
|
389
|
+
static double displayFlushBufferMaxBytes();
|
|
390
|
+
static double displayFlushRows();
|
|
391
|
+
static double displayFlushDepth();
|
|
392
|
+
static double displayFlushBufferBytes();
|
|
393
|
+
static double allocationSramCount();
|
|
394
|
+
static double allocationPsramCount();
|
|
395
|
+
static double allocationSramBytes();
|
|
396
|
+
static double allocationPsramBytes();
|
|
397
|
+
static double allocationSramPeakBytes();
|
|
398
|
+
static double allocationPsramPeakBytes();
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
} // namespace gea::framework::memory
|
|
402
|
+
|
|
403
|
+
namespace gea::framework::input {
|
|
404
|
+
|
|
405
|
+
class InputBackend {
|
|
406
|
+
public:
|
|
407
|
+
// Reads and clears the one-shot back-button-pressed flag. Polled by the
|
|
408
|
+
// launcher's rAF loop; when true and Settings is visible, the launcher
|
|
409
|
+
// closes Settings. Set from the platform's launcher-button task (BOOT
|
|
410
|
+
// short press on ESP32) and from an application's `_settings_toggle()`
|
|
411
|
+
// entry stub (fired by `Application::toggleSettings()` for `SettingsToggle`
|
|
412
|
+
// events posted via `AppManager::queueSettingsToggle()`).
|
|
413
|
+
static bool consumeBackButton();
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
} // namespace gea::framework::input
|
|
417
|
+
|
|
418
|
+
namespace gea::framework::gpio {
|
|
419
|
+
|
|
420
|
+
// Digital pins, for the wiring a board exposes that no other facade covers: an
|
|
421
|
+
// LED, a relay, a button that is not the launcher button. A board with no
|
|
422
|
+
// display reaches the outside world through these and nothing else.
|
|
423
|
+
//
|
|
424
|
+
// Every call answers "did this board do it", not "was the call well-formed":
|
|
425
|
+
// an out-of-range pin, a pin the chip cannot drive, or a target with no GPIO at
|
|
426
|
+
// all all report false rather than aborting, so an app written for one board
|
|
427
|
+
// degrades on another instead of crashing on it.
|
|
428
|
+
class GpioBackend {
|
|
429
|
+
public:
|
|
430
|
+
static bool configureOutput(double pin);
|
|
431
|
+
static bool configureInput(double pin, bool pull_up);
|
|
432
|
+
static bool write(double pin, bool level);
|
|
433
|
+
static bool read(double pin);
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
// A WS2812/NeoPixel strand on one pin — the "onboard LED" of most modern ESP32
|
|
437
|
+
// modules, which is addressable rather than a plain diode.
|
|
438
|
+
//
|
|
439
|
+
// `set` is the default: one call attaches the pin if needed, writes the colour
|
|
440
|
+
// and clocks it out, which is the whole of what a board's single onboard LED
|
|
441
|
+
// needs. `off` is `set` with black. The attach/setPixel/show trio underneath is
|
|
442
|
+
// for a real strand, where one transmit per frame beats one per pixel; show
|
|
443
|
+
// returns once the strand has latched, so a true means the LED is showing what
|
|
444
|
+
// was asked for rather than that the write was queued.
|
|
445
|
+
class AddressableLedBackend {
|
|
446
|
+
public:
|
|
447
|
+
static bool set(double pin, double r, double g, double b);
|
|
448
|
+
static bool off(double pin);
|
|
449
|
+
static bool attach(double pin, double count);
|
|
450
|
+
static bool setPixel(double index, double r, double g, double b);
|
|
451
|
+
static bool show();
|
|
452
|
+
static void detach();
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
} // namespace gea::framework::gpio
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
#include "power.h"
|
|
5
|
+
|
|
6
|
+
namespace gea::host {
|
|
7
|
+
|
|
8
|
+
// Battery state for app code. level() is the charge percentage (0-100) read from
|
|
9
|
+
// the platform PMU — gea::platform::power::Power::batteryPercent(), an I2C read of
|
|
10
|
+
// the AXP2101 on this board (not a flash op, so safe from any task, unlike NVS).
|
|
11
|
+
// Lets a watch face show a battery complication.
|
|
12
|
+
//
|
|
13
|
+
// Header-only: links from any TU including gea/embedded.h with no
|
|
14
|
+
// idf_component_register SRCS entry. The inline method is only instantiated where
|
|
15
|
+
// actually called, so targets without a Power impl are unaffected unless an app
|
|
16
|
+
// uses Battery.
|
|
17
|
+
struct BatteryFacade {
|
|
18
|
+
double level() const {
|
|
19
|
+
return static_cast<double>(gea::platform::power::Power::batteryPercent());
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
inline constexpr BatteryFacade Battery{};
|
|
24
|
+
|
|
25
|
+
} // namespace gea::host
|