@geastack/host 0.1.14 → 0.1.15

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.
@@ -12,7 +12,7 @@ gea::Promise<void> workletPromise(Action action) {
12
12
  }
13
13
  inline gea::host::AudioContext createAudioContext() {
14
14
  hostworker::installRealmRuntime();
15
- return gea::host::AudioContext(16000.0);
15
+ return gea::host::AudioContext(double(gea::platform::audio::deviceSampleRate));
16
16
  }
17
17
  template <typename Options>
18
18
  gea::host::AudioContext createAudioContext(const Options& options) {
@@ -59,8 +59,9 @@ gea::host::AudioWorkletNodeOptions workletOptions(const Options& options) {
59
59
  if constexpr (requires { options.outputChannelCount; }) {
60
60
  hostworker::present(options.outputChannelCount, [&](const auto& counts) {
61
61
  const auto& values = [&]() -> const auto& { if constexpr (requires { counts->size(); }) return *counts; else return counts; }();
62
- if (values.size() != result.numberOfOutputs || values.size() != 1 || values.at(0) != 1)
63
- throw std::invalid_argument("Embedded AudioWorklet requires one mono output");
62
+ if (values.size() != result.numberOfOutputs || values.size() > 1 ||
63
+ (values.size() == 1 && values.at(0) != 1))
64
+ throw std::invalid_argument("Embedded AudioWorklet output channel counts must match zero or one mono output");
64
65
  });
65
66
  }
66
67
  }
@@ -0,0 +1,127 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ #pragma once
3
+
4
+ #include "gea_runtime.h"
5
+ #include "host/http.h"
6
+
7
+ namespace gea::host::http {
8
+ namespace detail {
9
+
10
+ template <typename T> T &mutableRecord(T &value) { return value; }
11
+
12
+ template <typename T> T &mutableRecord(gea::Ref<T> &value) {
13
+ value = gea::makeRef<T>();
14
+ return *value;
15
+ }
16
+
17
+ template <typename T> const T &record(const T &value) { return value; }
18
+
19
+ template <typename T> const T &record(const gea::Ref<T> &value) {
20
+ return *value;
21
+ }
22
+
23
+ template <typename T> T field(const T &value, const T &) { return value; }
24
+
25
+ template <typename T>
26
+ T field(const gea::Optional<T> &value, const T &fallback) {
27
+ return value.has_value() ? *value : fallback;
28
+ }
29
+
30
+ template <typename T> gea::Ref<T> arrayField(const gea::Ref<T> &value) {
31
+ return value;
32
+ }
33
+
34
+ template <typename T>
35
+ gea::Ref<T> arrayField(const gea::Optional<gea::Ref<T>> &value) {
36
+ return value.has_value() ? *value : gea::Ref<T>{};
37
+ }
38
+
39
+ template <typename T> struct RequestArgument {
40
+ static T make(const HttpRequest &request) {
41
+ T value{};
42
+ value.method = request.method;
43
+ value.path = request.path;
44
+ value.query = request.query;
45
+ value.url = request.query.empty() ? request.path
46
+ : request.path + "?" + request.query;
47
+ if constexpr (requires { value.body; }) {
48
+ value.body =
49
+ gea::makeRef<gea::TypedArray<std::uint8_t>>(request.body.size());
50
+ std::copy(request.body.begin(), request.body.end(), value.body->data());
51
+ }
52
+ if constexpr (requires { value.headers; }) {
53
+ using Array =
54
+ typename std::remove_cvref_t<decltype(value.headers)>::element_type;
55
+ using Header =
56
+ std::remove_cvref_t<decltype(std::declval<Array>().cells[0].value)>;
57
+ value.headers = gea::makeRef<Array>();
58
+ for (const auto &header : request.headers) {
59
+ Header entry{};
60
+ auto &fields = mutableRecord(entry);
61
+ fields.name = header.name;
62
+ fields.value = header.value;
63
+ value.headers->push(entry);
64
+ }
65
+ }
66
+ return value;
67
+ }
68
+ };
69
+
70
+ template <typename T> struct RequestArgument<gea::Ref<T>> {
71
+ static gea::Ref<T> make(const HttpRequest &request) {
72
+ return gea::makeRef<T>(RequestArgument<T>::make(request));
73
+ }
74
+ };
75
+
76
+ template <typename Handler, typename Argument>
77
+ NativeHttpServerHandle registerTypedHandler(Handler handler) {
78
+ return register_handler([handler](const HttpRequest &request) -> HttpReply {
79
+ const auto result =
80
+ handler(RequestArgument<std::remove_cvref_t<Argument>>::make(request));
81
+ const auto &value = record(result);
82
+ HttpReply reply;
83
+ if constexpr (requires { value.status; }) {
84
+ reply.status = static_cast<int>(field(value.status, 200.0));
85
+ }
86
+ if constexpr (requires { value.contentType; }) {
87
+ reply.contentType = field(value.contentType, std::string("text/plain"));
88
+ }
89
+ if constexpr (requires { value.body; }) {
90
+ reply.body = field(value.body, std::string{});
91
+ }
92
+ if constexpr (requires { value.file; }) {
93
+ reply.file = field(value.file, std::string{});
94
+ }
95
+ if constexpr (requires { value.download; }) {
96
+ reply.download = field(value.download, std::string{});
97
+ }
98
+ if constexpr (requires { value.headers; }) {
99
+ const auto headers = arrayField(value.headers);
100
+ if (headers) {
101
+ for (const auto &cell : headers->cells) {
102
+ const auto &header = record(cell.value);
103
+ reply.headers.push_back({header.name, header.value});
104
+ }
105
+ }
106
+ }
107
+ return reply;
108
+ });
109
+ }
110
+
111
+ } // namespace detail
112
+
113
+ template <typename Result, typename Argument>
114
+ NativeHttpServerHandle
115
+ create_typed_server(gea::CallableObject<Result(Argument)> handler) {
116
+ return detail::registerTypedHandler<decltype(handler), Argument>(
117
+ std::move(handler));
118
+ }
119
+
120
+ template <typename Result, typename Argument>
121
+ NativeHttpServerHandle
122
+ create_typed_server(std::function<Result(Argument)> handler) {
123
+ return detail::registerTypedHandler<decltype(handler), Argument>(
124
+ std::move(handler));
125
+ }
126
+
127
+ } // namespace gea::host::http
@@ -13,6 +13,11 @@
13
13
  #include <utility>
14
14
  #include <vector>
15
15
 
16
+ namespace gea {
17
+ template <typename T> struct Ref;
18
+ template <typename T> class TypedArray;
19
+ } // namespace gea
20
+
16
21
  namespace gea::embedded::ui {
17
22
  class NodeHandle;
18
23
  }
@@ -53,14 +58,60 @@ struct AudioContextCurrentTimeProperty {
53
58
  operator double() const;
54
59
  };
55
60
 
61
+ struct AudioBufferStorage;
62
+
56
63
  struct AudioBuffer {
57
64
  std::vector<std::int16_t> samples;
58
65
  int sampleRate = 16000;
59
66
  int channels = 1;
67
+ mutable std::shared_ptr<AudioBufferStorage> storage;
60
68
 
61
- constexpr AudioBuffer() = default;
69
+ AudioBuffer() = default;
62
70
  AudioBuffer(std::vector<std::int16_t> pcm, int rate, int channelCount)
63
- : samples(std::move(pcm)), sampleRate(rate), channels(channelCount) {}
71
+ : samples(std::move(pcm)), sampleRate(rate), channels(channelCount) {
72
+ ensureStorage();
73
+ }
74
+
75
+ double getLength() const;
76
+ double getDuration() const;
77
+ double getNumberOfChannels() const;
78
+ gea::Ref<gea::TypedArray<float>> getChannelData(double channel) const;
79
+ const std::vector<std::int16_t> &pcmSamples() const;
80
+
81
+ template <typename Source>
82
+ void copyToChannel(const Source &source, double channel,
83
+ double offset = 0) const {
84
+ if constexpr (requires {
85
+ source.get();
86
+ *source;
87
+ }) {
88
+ copyToChannel(*source, channel, offset);
89
+ } else {
90
+ copyToChannelValues(source.data(), source.size(), channel, offset);
91
+ }
92
+ }
93
+
94
+ template <typename Destination>
95
+ void copyFromChannel(const Destination &destination, double channel,
96
+ double offset = 0) const {
97
+ if constexpr (requires {
98
+ destination.get();
99
+ *destination;
100
+ }) {
101
+ copyFromChannelValues(destination->data(), destination->size(), channel,
102
+ offset);
103
+ } else {
104
+ copyFromChannelValues(destination.data(), destination.size(), channel,
105
+ offset);
106
+ }
107
+ }
108
+
109
+ private:
110
+ void ensureStorage() const;
111
+ void copyToChannelValues(const float *source, std::size_t count,
112
+ double channel, double offset) const;
113
+ void copyFromChannelValues(float *destination, std::size_t count,
114
+ double channel, double offset) const;
64
115
  };
65
116
 
66
117
  struct AudioParamValueProperty {
@@ -100,12 +151,15 @@ struct OscillatorTypeProperty {
100
151
 
101
152
  struct OscillatorNode {
102
153
  NativeAudioHandle nativeHandle = 0;
154
+ std::shared_ptr<audio_worklet::ContextState> context;
155
+ mutable double clockOffset = 0;
156
+ mutable bool clockAligned = false;
103
157
  mutable AudioParam frequency;
104
158
  mutable OscillatorTypeProperty type;
105
159
 
106
- constexpr OscillatorNode() = default;
107
- explicit constexpr OscillatorNode(NativeAudioHandle oscillator) : nativeHandle(oscillator), frequency(oscillator), type(oscillator) {}
108
- explicit constexpr OscillatorNode(double oscillator) : nativeHandle(static_cast<NativeAudioHandle>(oscillator)), frequency(oscillator), type(oscillator) {}
160
+ OscillatorNode() = default;
161
+ explicit OscillatorNode(NativeAudioHandle oscillator) : nativeHandle(oscillator), frequency(oscillator), type(oscillator) {}
162
+ explicit OscillatorNode(double oscillator) : nativeHandle(static_cast<NativeAudioHandle>(oscillator)), frequency(oscillator), type(oscillator) {}
109
163
 
110
164
  constexpr operator double() const { return static_cast<double>(nativeHandle); }
111
165
 
@@ -117,6 +171,15 @@ struct OscillatorNode {
117
171
  };
118
172
 
119
173
  struct AudioBufferSourceNode {
174
+ private:
175
+ bool present_ = false;
176
+ explicit AudioBufferSourceNode(bool present) : present_(present) {}
177
+ friend struct AudioContext;
178
+
179
+ public:
180
+ AudioBufferSourceNode() = default;
181
+ explicit operator bool() const { return present_; }
182
+ bool operator==(std::nullptr_t) const { return !present_; }
120
183
  mutable AudioBuffer buffer;
121
184
  mutable bool connected = false;
122
185
 
@@ -139,7 +202,7 @@ struct AudioContext {
139
202
  bool operator==(std::nullptr_t) const { return !state_; }
140
203
  template <typename Options>
141
204
  explicit AudioContext(const Options& options) : AudioContext(sampleRateOption(options)) {}
142
- double sampleRate = 16000;
205
+ double sampleRate = gea::platform::audio::deviceSampleRate;
143
206
  AudioDestinationProperty destination;
144
207
  AudioContextCurrentTimeProperty currentTime;
145
208
  AudioWorklet audioWorklet;
@@ -155,19 +218,27 @@ struct AudioContext {
155
218
 
156
219
  OscillatorNode createOscillator() const;
157
220
  AudioBufferSourceNode createBufferSource() const;
221
+ AudioBuffer createBuffer(double channels, double length, double rate) const;
158
222
  AudioBuffer decodeAudioData(const std::vector<std::uint8_t> &bytes) const;
159
223
  private:
160
224
  template <typename Options>
161
225
  static double sampleRateOption(const Options& options) {
162
- if constexpr (requires { options.has_value(); *options; })
163
- return options.has_value() ? sampleRateOption(*options) : 16000;
164
- else if constexpr (requires { options.get(); *options; })
165
- return options.get() ? sampleRateOption(*options) : 16000;
226
+ if constexpr (requires {
227
+ options.has_value();
228
+ *options;
229
+ })
230
+ return options.has_value() ? sampleRateOption(*options)
231
+ : gea::platform::audio::deviceSampleRate;
232
+ else if constexpr (requires {
233
+ options.get();
234
+ *options;
235
+ })
236
+ return options.get() ? sampleRateOption(*options) : gea::platform::audio::deviceSampleRate;
166
237
  else if constexpr (requires { options.sampleRate; })
167
238
  return sampleRateOption(options.sampleRate);
168
239
  else if constexpr (requires { static_cast<double>(options); })
169
240
  return static_cast<double>(options);
170
- else return 16000;
241
+ else return gea::platform::audio::deviceSampleRate;
171
242
  }
172
243
  };
173
244
 
@@ -204,7 +275,7 @@ class HTMLAudioElement {
204
275
  };
205
276
 
206
277
  // Streaming mono PCM transport independent of any speech provider. Wire PCM
207
- // uses sampleRate; capture/playback use the device's 16 kHz audio clock.
278
+ // uses sampleRate; capture/playback use the configured device audio clock.
208
279
  class WebSocket;
209
280
  class PcmAudioStream {
210
281
  public:
@@ -238,7 +309,7 @@ struct AudioFacade {
238
309
  };
239
310
 
240
311
  inline const AudioContext& sharedAudioContext() {
241
- static const AudioContext context(16000.0);
312
+ static const AudioContext context{double(gea::platform::audio::deviceSampleRate)};
242
313
  return context;
243
314
  }
244
315
  inline constexpr AudioFacade Audio{};
@@ -24,7 +24,7 @@ public:
24
24
  static double gyroscopeZ();
25
25
  };
26
26
 
27
- } // namespace gea::framework::sensors
27
+ } // namespace gea::framework::sensors
28
28
 
29
29
  namespace gea::framework::camera {
30
30
 
@@ -36,7 +36,8 @@ public:
36
36
 
37
37
  // facing: "front" | "back" | <device id from deviceIdAt>
38
38
  // preferredWidth/Height: 0 means "platform default"
39
- static bool open(const std::string &facing, double preferredWidth, double preferredHeight);
39
+ static bool open(const std::string &facing, double preferredWidth,
40
+ double preferredHeight);
40
41
  static void close();
41
42
  static bool isOpen();
42
43
 
@@ -56,6 +57,7 @@ public:
56
57
  // Capture a still image; returns the ImageStore id or -1 on failure.
57
58
  static double capture();
58
59
  static double captureMirrored();
60
+ static std::string captureFrame();
59
61
 
60
62
  // Video recording (esp32-p4: MJPEG). startRecording returns true on success;
61
63
  // stopRecording returns the clip duration in ms, or -1 on failure.
@@ -69,8 +71,10 @@ public:
69
71
 
70
72
  // Capture controls forwarded to the platform backend. See camera.h for the
71
73
  // 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 setExposure(const std::string &mode, double bias, double iso,
75
+ double durationMs);
76
+ static void setWhiteBalance(const std::string &mode, double temperatureK,
77
+ double tint);
74
78
  static void setFocus(const std::string &mode, double pointX, double pointY);
75
79
  static void setTorch(const std::string &mode, double level);
76
80
 
@@ -86,20 +90,24 @@ public:
86
90
  facing = static_cast<std::string>(options.facing);
87
91
  } else if constexpr (requires { options.record_get_literal("facing"); }) {
88
92
  auto value = options.record_get_literal("facing");
89
- if (!value.is_nullish()) facing = static_cast<std::string>(value);
93
+ if (!value.is_nullish())
94
+ facing = static_cast<std::string>(value);
90
95
  }
91
- if (facing.empty()) facing = "back";
96
+ if (facing.empty())
97
+ facing = "back";
92
98
  if constexpr (requires { options.width; }) {
93
99
  width = static_cast<double>(options.width);
94
100
  } else if constexpr (requires { options.record_get_literal("width"); }) {
95
101
  auto value = options.record_get_literal("width");
96
- if (!value.is_nullish()) width = static_cast<double>(value);
102
+ if (!value.is_nullish())
103
+ width = static_cast<double>(value);
97
104
  }
98
105
  if constexpr (requires { options.height; }) {
99
106
  height = static_cast<double>(options.height);
100
107
  } else if constexpr (requires { options.record_get_literal("height"); }) {
101
108
  auto value = options.record_get_literal("height");
102
- if (!value.is_nullish()) height = static_cast<double>(value);
109
+ if (!value.is_nullish())
110
+ height = static_cast<double>(value);
103
111
  }
104
112
  return open(facing, width, height);
105
113
  }
@@ -112,7 +120,8 @@ public:
112
120
  mirror = static_cast<bool>(options.mirror);
113
121
  } else if constexpr (requires { options.record_get_literal("mirror"); }) {
114
122
  auto value = options.record_get_literal("mirror");
115
- if (!value.is_nullish()) mirror = static_cast<bool>(value);
123
+ if (!value.is_nullish())
124
+ mirror = static_cast<bool>(value);
116
125
  }
117
126
  return mirror ? captureMirrored() : capture();
118
127
  }
@@ -123,18 +132,22 @@ public:
123
132
  // anonymous options structs — are read field-by-field in each control form
124
133
  // below, since member selection needs the field name at compile time.
125
134
  template <typename Options>
126
- static std::string optionString(const Options &options, const char *field, const std::string &fallback) {
135
+ static std::string optionString(const Options &options, const char *field,
136
+ const std::string &fallback) {
127
137
  if constexpr (requires { options.record_get_literal(field); }) {
128
138
  auto value = options.record_get_literal(field);
129
- if (!value.is_nullish()) return static_cast<std::string>(value);
139
+ if (!value.is_nullish())
140
+ return static_cast<std::string>(value);
130
141
  }
131
142
  return fallback;
132
143
  }
133
144
  template <typename Options>
134
- static double optionNumber(const Options &options, const char *field, double fallback) {
145
+ static double optionNumber(const Options &options, const char *field,
146
+ double fallback) {
135
147
  if constexpr (requires { options.record_get_literal(field); }) {
136
148
  auto value = options.record_get_literal(field);
137
- if (!value.is_nullish()) return static_cast<double>(value);
149
+ if (!value.is_nullish())
150
+ return static_cast<double>(value);
138
151
  }
139
152
  return fallback;
140
153
  }
@@ -145,22 +158,29 @@ public:
145
158
  // so bare presence of the member means present), falling back to the dynamic
146
159
  // record arm, then the default. Expression-shaped so the readers stay
147
160
  // 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)); \
161
+ #define GEA_CAMERA_OPTION_FIELD(options, field, fallback, castT) \
162
+ ([&]() { \
163
+ if constexpr (requires { (options).field; }) { \
164
+ bool __gea_present = true; \
165
+ if constexpr (requires { (options).__gea_has_##field; }) \
166
+ __gea_present = (options).__gea_has_##field; \
167
+ if (__gea_present) \
168
+ return static_cast<castT>((options).field); \
169
+ } \
170
+ return static_cast<castT>( \
171
+ optionsFieldFallback_##castT((options), #field, fallback)); \
156
172
  }())
157
173
 
158
174
  template <typename Options>
159
- static std::string optionsFieldFallback_OptionStringT(const Options &options, const char *field, const std::string &fallback) {
175
+ static std::string
176
+ optionsFieldFallback_OptionStringT(const Options &options, const char *field,
177
+ const std::string &fallback) {
160
178
  return optionString(options, field, fallback);
161
179
  }
162
180
  template <typename Options>
163
- static double optionsFieldFallback_OptionNumberT(const Options &options, const char *field, double fallback) {
181
+ static double optionsFieldFallback_OptionNumberT(const Options &options,
182
+ const char *field,
183
+ double fallback) {
164
184
  return optionNumber(options, field, fallback);
165
185
  }
166
186
  using OptionStringT = std::string;
@@ -171,16 +191,20 @@ public:
171
191
  // to a typed struct (preferred) or a dynamic gea_cpp_value record (legacy).
172
192
  template <typename Options>
173
193
  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));
194
+ setExposure(
195
+ GEA_CAMERA_OPTION_FIELD(options, mode, std::string("continuous"),
196
+ OptionStringT),
197
+ GEA_CAMERA_OPTION_FIELD(options, bias, 0.0, OptionNumberT),
198
+ GEA_CAMERA_OPTION_FIELD(options, iso, 0.0, OptionNumberT),
199
+ GEA_CAMERA_OPTION_FIELD(options, durationMs, 0.0, OptionNumberT));
178
200
  }
179
201
  template <typename Options>
180
202
  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));
203
+ setWhiteBalance(
204
+ GEA_CAMERA_OPTION_FIELD(options, mode, std::string("auto"),
205
+ OptionStringT),
206
+ GEA_CAMERA_OPTION_FIELD(options, temperature, 0.0, OptionNumberT),
207
+ GEA_CAMERA_OPTION_FIELD(options, tint, 0.0, OptionNumberT));
184
208
  }
185
209
  template <typename Options>
186
210
  static void setFocusWithOptions(const Options &options) {
@@ -197,12 +221,15 @@ public:
197
221
  py = optionNumber(point, "y", 0.0);
198
222
  }
199
223
  }
200
- setFocus(GEA_CAMERA_OPTION_FIELD(options, mode, std::string("continuous"), OptionStringT), px, py);
224
+ setFocus(GEA_CAMERA_OPTION_FIELD(options, mode, std::string("continuous"),
225
+ OptionStringT),
226
+ px, py);
201
227
  }
202
228
  template <typename Options>
203
229
  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));
230
+ return startRecording(
231
+ GEA_CAMERA_OPTION_FIELD(options, path, std::string(""), OptionStringT),
232
+ GEA_CAMERA_OPTION_FIELD(options, fps, 0.0, OptionNumberT));
206
233
  }
207
234
  #undef GEA_CAMERA_OPTION_FIELD
208
235
  };
@@ -213,7 +240,7 @@ public:
213
240
  // registers its driver. Defined in host/camera.cpp.
214
241
  void registerCameraSurface();
215
242
 
216
- } // namespace gea::framework::camera
243
+ } // namespace gea::framework::camera
217
244
 
218
245
  namespace gea::framework::network {
219
246
 
@@ -227,6 +254,12 @@ public:
227
254
  static std::string ip();
228
255
  static std::string mac();
229
256
  static void configure(const std::string &ssid, const std::string &password);
257
+ static bool startAccessPoint(const std::string &ssid,
258
+ const std::string &password);
259
+ static void stopAccessPoint();
260
+ static std::string accessPointMac();
261
+ static bool startCaptivePortal();
262
+ static void stopCaptivePortal();
230
263
  static bool waitForConnection(double timeoutMs);
231
264
  static void startScan();
232
265
  static bool scanning();
@@ -236,7 +269,7 @@ public:
236
269
  static bool scanSecuredAt(double index);
237
270
  };
238
271
 
239
- } // namespace gea::framework::network
272
+ } // namespace gea::framework::network
240
273
 
241
274
  namespace gea::framework::geolocation {
242
275
 
@@ -249,13 +282,14 @@ public:
249
282
  static double accuracy();
250
283
  };
251
284
 
252
- } // namespace gea::framework::geolocation
285
+ } // namespace gea::framework::geolocation
253
286
 
254
287
  namespace gea::framework::bluetooth {
255
288
 
256
289
  class HidBackend {
257
290
  public:
258
- static void init(const std::string &device_name, double appearance, const std::string &mac_address);
291
+ static void init(const std::string &device_name, double appearance,
292
+ const std::string &mac_address);
259
293
  static bool enabled();
260
294
  static void setEnabled(bool enabled);
261
295
  static void startAdvertising();
@@ -306,7 +340,7 @@ public:
306
340
  static void configPushActivity(double index);
307
341
  };
308
342
 
309
- } // namespace gea::framework::bluetooth
343
+ } // namespace gea::framework::bluetooth
310
344
 
311
345
  namespace gea::framework::audio {
312
346
 
@@ -316,7 +350,7 @@ public:
316
350
  static void setVolume(double volume);
317
351
  };
318
352
 
319
- } // namespace gea::framework::audio
353
+ } // namespace gea::framework::audio
320
354
 
321
355
  namespace gea::framework::display {
322
356
 
@@ -330,11 +364,11 @@ public:
330
364
  // without an e-paper panel). Negative numbers = leave unchanged. LUTs must
331
365
  // be the panel's full waveform table (159 bytes on SSD1681-class panels);
332
366
  // 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);
367
+ static void setEpaperRefreshConfig(
368
+ double fullRefreshEveryPartials, double fullRefreshHardCapPartials,
369
+ double fastStreakWindowMs, const std::vector<std::uint8_t> &partialLut,
370
+ bool hasPartialLut, const std::vector<std::uint8_t> &fastLut,
371
+ bool hasFastLut);
338
372
  static void epaperFullRefresh();
339
373
  // Toggle 4-level grayscale rendering on e-paper boards that support it
340
374
  // (weak-hooked no-op elsewhere). Gray mode trades the fast partial waveform
@@ -346,7 +380,8 @@ public:
346
380
  static std::string orientation();
347
381
  static void setOrientation(const std::string &orientation);
348
382
  static std::vector<std::string> supportedOrientations();
349
- static void setSupportedOrientations(const std::vector<std::string> &orientations);
383
+ static void
384
+ setSupportedOrientations(const std::vector<std::string> &orientations);
350
385
  static void setSupportedOrientations(const std::string &orientation);
351
386
  static bool autoRotate();
352
387
  static void setAutoRotate(bool enabled);
@@ -359,17 +394,19 @@ public:
359
394
  // 4bpp targets; no-op elsewhere). 0xRRGGBB; negative disables.
360
395
  static void setTextSolidBackdrop(int rrggbb);
361
396
  // 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.
397
+ // and the persistent previous-frame copy). No-op on targets without a present
398
+ // diff.
363
399
  static void invalidate();
364
400
  static std::string pixelFormat();
365
401
  static void setPixelFormat(const std::string &format);
366
402
  static std::string panelPixelFormat();
367
403
  static std::vector<std::string> supportedPixelFormats();
368
404
  static void updateAutoRotationFromAccelerometer();
369
- static void updateAutoRotation(double acceleration_x, double acceleration_y, double acceleration_z);
405
+ static void updateAutoRotation(double acceleration_x, double acceleration_y,
406
+ double acceleration_z);
370
407
  };
371
408
 
372
- } // namespace gea::framework::display
409
+ } // namespace gea::framework::display
373
410
 
374
411
  namespace gea::framework::memory {
375
412
 
@@ -398,7 +435,7 @@ public:
398
435
  static double allocationPsramPeakBytes();
399
436
  };
400
437
 
401
- } // namespace gea::framework::memory
438
+ } // namespace gea::framework::memory
402
439
 
403
440
  namespace gea::framework::input {
404
441
 
@@ -413,7 +450,7 @@ public:
413
450
  static bool consumeBackButton();
414
451
  };
415
452
 
416
- } // namespace gea::framework::input
453
+ } // namespace gea::framework::input
417
454
 
418
455
  namespace gea::framework::gpio {
419
456
 
@@ -452,4 +489,4 @@ public:
452
489
  static void detach();
453
490
  };
454
491
 
455
- } // namespace gea::framework::gpio
492
+ } // namespace gea::framework::gpio
@@ -18,8 +18,18 @@ struct BatteryFacade {
18
18
  double level() const {
19
19
  return static_cast<double>(gea::platform::power::Power::batteryPercent());
20
20
  }
21
+
22
+ bool charging() const { return gea::platform::power::Power::charging(); }
21
23
  };
22
24
 
23
25
  inline constexpr BatteryFacade Battery{};
24
26
 
27
+ struct HapticsFacade {
28
+ bool vibrate(double durationMs, double strength = 100) const {
29
+ return gea::platform::power::Power::vibrate(durationMs, static_cast<int>(strength));
30
+ }
31
+ };
32
+
33
+ inline constexpr HapticsFacade Haptics{};
34
+
25
35
  } // namespace gea::host
@@ -131,6 +131,7 @@ public:
131
131
  // Returns image id of a still capture, suitable to pass to image.draw().
132
132
  double capture() const { return gea::framework::camera::CameraBackend::capture(); }
133
133
  double captureMirrored() const { return gea::framework::camera::CameraBackend::captureMirrored(); }
134
+ std::string captureFrame() const { return gea::framework::camera::CameraBackend::captureFrame(); }
134
135
 
135
136
  // Single-arg form accepting an options record. Reads `mirror` to choose
136
137
  // the path; ignores unknown fields. Lets call sites use the same shape