RGB Sunglasses Animation Extension API fw-v3.8.1-1-geacf2f0
rgbx ABI + C++ wrapper for sandboxed .llext animations
Loading...
Searching...
No Matches
rgbx_api.h
Go to the documentation of this file.
1
33#ifndef RGBX_API_H_
34#define RGBX_API_H_
35
36#include <stddef.h>
37#include <stdint.h>
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
45#define RGBX_ABI_VERSION 1u
46
48#define RGBX_MAX_PARAMS 16u
49
51#define RGBX_MAX_STRING_PARAMS 4u
52
55#define RGBX_PARAM_STRING_MAX 32u
56
59#define RGBX_AUDIO_NUM_BANDS 4u
60
62#define RGBX_AUDIO_NUM_DISPLAY_BUCKETS 20u
63
90
96 uint32_t u32;
97 uint32_t color;
98 uint32_t boolean;
99 float f32;
102 const char *str;
105};
106
122
129 uint32_t abi_version;
130 const char *name;
131 uint32_t width;
133 uint32_t height;
134 uint32_t param_count;
137 const struct rgbx_param_desc *params;
138};
139
183
195#define RGBX_PARAM(name_, type_, default_u32_) \
196 {(name_), (type_), {.u32 = (default_u32_)}}
197
205#define RGBX_PARAM_STR(name_, default_str_) \
206 {(name_), RGBX_PARAM_STRING, {.str = (default_str_)}}
207
221#define RGBX_PARAM_F32(name_, default_f32_) \
222 {(name_), RGBX_PARAM_FLOAT, {.f32 = (default_f32_)}}
223
237#define RGBX_PIXEL_INDEX(w, x, y) ((((size_t)(y) * (size_t)(w)) + (size_t)(x)) * 3u)
238
251extern const struct rgbx_manifest rgbx_manifest;
252
255extern struct rgbx_inputs rgbx_inputs;
256
260extern uint8_t rgbx_framebuffer[];
261
265void rgbx_init(void);
266
271void rgbx_tick(void);
272
273/* The symbol names the host passes to llext_find_sym(), kept next to the
274 * declarations above so the two can't drift apart. */
275
277#define RGBX_SYM_MANIFEST "rgbx_manifest"
279#define RGBX_SYM_INPUTS "rgbx_inputs"
281#define RGBX_SYM_FRAMEBUFFER "rgbx_framebuffer"
283#define RGBX_SYM_INIT "rgbx_init"
285#define RGBX_SYM_TICK "rgbx_tick"
286
311extern uint8_t rgbx_good_moment;
312
314#define RGBX_SYM_GOOD_MOMENT "rgbx_good_moment"
315
318#ifdef __cplusplus
319} /* extern "C" */
320#endif
321
322#endif /* RGBX_API_H_ */
#define RGBX_MAX_PARAMS
Fixed capacity of the per-extension parameter block.
Definition rgbx_api.h:48
#define RGBX_MAX_STRING_PARAMS
Maximum number of RGBX_PARAM_STRING parameters per extension.
Definition rgbx_api.h:51
void rgbx_tick(void)
Called once per frame, on the sandboxed thread.
void rgbx_init(void)
Called once, on the sandboxed thread, after every (re)load and before the first tick.
uint8_t rgbx_good_moment
OPTIONAL.
#define RGBX_AUDIO_NUM_BANDS
Number of coarse audio bands (energy + beat flag each).
Definition rgbx_api.h:59
uint8_t rgbx_framebuffer[]
The scratch framebuffer the extension renders into, sized exactly width * height * 3 bytes (see RGBX_...
#define RGBX_AUDIO_NUM_DISPLAY_BUCKETS
Number of fine-grained audio display buckets (bar-graph style).
Definition rgbx_api.h:62
rgbx_param_type
Parameter types, mapped by the host onto the same BLE characteristic presentation formats (CPF) the b...
Definition rgbx_api.h:68
@ RGBX_PARAM_UINT32
plain unsigned integer (4-byte BLE value)
Definition rgbx_api.h:69
@ RGBX_PARAM_STRING
UTF-8 string, at most RGBX_PARAM_STRING_MAX-1 bytes (text field in the companion app)
Definition rgbx_api.h:74
@ RGBX_PARAM_FLOAT
IEEE-754 float32 (numeric field in the companion app).
Definition rgbx_api.h:76
@ RGBX_PARAM_COLOR
0x00RRGGBB, high byte ignored (color picker in the companion app)
Definition rgbx_api.h:70
@ RGBX_PARAM_BOOL
0 or 1 (toggle in the companion app; 1-byte BLE value)
Definition rgbx_api.h:72
#define RGBX_PARAM_STRING_MAX
Fixed storage size of one string parameter value, INCLUDING the NUL terminator (so the longest usable...
Definition rgbx_api.h:55
Per-tick input snapshot.
Definition rgbx_api.h:152
float audio_display_bucket[RGBX_AUDIO_NUM_DISPLAY_BUCKETS]
fine-grained spectrum buckets for bar-graph visualisation, low frequencies first (62 Hz–3 kHz).
Definition rgbx_api.h:170
float gyro[3]
IMU gyroscope x/y/z, rad/s.
Definition rgbx_api.h:164
uint32_t dt_ms
nominal ms since the previous tick
Definition rgbx_api.h:153
uint32_t buttons_pressed
bit i set = button i was pressed since the previous tick.
Definition rgbx_api.h:179
char param_strings[RGBX_MAX_STRING_PARAMS][RGBX_PARAM_STRING_MAX]
current string parameter values, always NUL-terminated; slot i = the i-th STRING-typed param in decla...
Definition rgbx_api.h:159
float audio_band_energy[RGBX_AUDIO_NUM_BANDS]
smoothed energy per coarse band, low frequencies first
Definition rgbx_api.h:166
uint8_t audio_beat[RGBX_AUDIO_NUM_BANDS]
1 if a beat was detected in that band this frame, else 0
Definition rgbx_api.h:168
uint32_t params[RGBX_MAX_PARAMS]
current scalar parameter values (UINT32/COLOR/BOOL), in manifest declaration order
Definition rgbx_api.h:155
float accel[3]
IMU accelerometer x/y/z, m/s^2.
Definition rgbx_api.h:163
Extension self-description.
Definition rgbx_api.h:128
uint32_t width
framebuffer width the extension renders at; must match the host display (40 on proto0)
Definition rgbx_api.h:131
const struct rgbx_param_desc * params
NULL iff param_count == 0.
Definition rgbx_api.h:137
uint32_t param_count
entries in params, <= RGBX_MAX_PARAMS; at most RGBX_MAX_STRING_PARAMS of them may be RGBX_PARAM_STRIN...
Definition rgbx_api.h:134
const char * name
animation display name (BLE "Animation Name")
Definition rgbx_api.h:130
uint32_t abi_version
must be RGBX_ABI_VERSION
Definition rgbx_api.h:129
uint32_t height
framebuffer height (12 on proto0)
Definition rgbx_api.h:133
One user-tunable parameter, surfaced as a BLE characteristic named name on the extension's auto-gener...
Definition rgbx_api.h:111
const char * name
display name (CUD string); must be a string literal inside the extension image
Definition rgbx_api.h:112
union rgbx_param_default default_value
value before any BLE write arrives, keyed by type
Definition rgbx_api.h:119
enum rgbx_param_type type
value type.
Definition rgbx_api.h:115
Default value for one parameter; which member is read is keyed by the parameter's rgbx_param_type.
Definition rgbx_api.h:95
uint32_t u32
RGBX_PARAM_UINT32.
Definition rgbx_api.h:96
uint32_t boolean
RGBX_PARAM_BOOL, 0 or 1.
Definition rgbx_api.h:98
uint32_t color
RGBX_PARAM_COLOR, 0x00RRGGBB.
Definition rgbx_api.h:97
const char * str
RGBX_PARAM_STRING; must point at a NUL-terminated string literal inside the extension image,...
Definition rgbx_api.h:102
float f32
RGBX_PARAM_FLOAT (same 4-byte slot: sizeof(float) == sizeof(uint32_t) on both ABI targets,...
Definition rgbx_api.h:99