RGB Sunglasses Animation Extension API fw-v3.8.1-1-geacf2f0
rgbx ABI + C++ wrapper for sandboxed .llext animations
Loading...
Searching...
No Matches
rgbx_v2.h
Go to the documentation of this file.
1
13#pragma once
14
15#include <stdint.h>
16
18#define RGBX_V2_ABI_VERSION 2u
20#define RGBX_V2_WIDTH 40u
22#define RGBX_V2_HEIGHT 12u
24#define RGBX_V2_PIXEL_COUNT (RGBX_V2_WIDTH * RGBX_V2_HEIGHT)
26#define RGBX_V2_PIXELS_PER_SPAN 8u
28#define RGBX_V2_MAX_PARAMS 16u
30#define RGBX_V2_MAX_STRING_PARAMS 4u
32#define RGBX_V2_STRING_PARAM_SIZE 32u
34#define RGBX_V2_AUDIO_BAND_COUNT 4u
36#define RGBX_V2_AUDIO_DISPLAY_BUCKET_COUNT 20u
38#define RGBX_V2_IMU_AXIS_COUNT 3u
40#define RGBX_V2_DIAGNOSTIC_COUNT 4u
42#define RGBX_V2_MODULE_MAX_BYTES 2048u
43
44/*
45 * Admission profile.
46 *
47 * Every structural limit the host applies to a memoryless RGBX v2 module is
48 * declared once, here. The firmware admission path static_asserts its own
49 * constants against these macros, the SDK packager copies them verbatim into
50 * sdk-manifest.json, and the SDK's post-link gate reads them back out of that
51 * manifest, so the three cannot describe different profiles without a build
52 * failure or a gate failure.
53 */
54
56#define RGBX_V2_MAX_FUNCTIONS 8u
58#define RGBX_V2_MAX_GLOBALS 8u
60#define RGBX_V2_MAX_LOCALS_PER_FUNCTION 32u
62#define RGBX_V2_MIN_IMPORTS 2u
64#define RGBX_V2_MAX_IMPORTS 5u
66#define RGBX_V2_MAX_PARAM_CALLS_PER_TICK 16u
68#define RGBX_V2_MAX_INPUT_CALLS_PER_TICK 64u
70#define RGBX_V2_SPAN_CALLS_PER_TICK (RGBX_V2_PIXEL_COUNT / RGBX_V2_PIXELS_PER_SPAN)
71
72/*
73 * Section-id bitmasks: bit N is set when standard WebAssembly section id N
74 * belongs to the set. Admitted ids are type(1), import(2), function(3),
75 * global(6), export(7) and code(10); every other id, including custom(0),
76 * table(4), memory(5), start(8), element(9) and data(11), is refused. The
77 * required set is the same list without the optional global section.
78 */
80#define RGBX_V2_SECTION_ALLOWED_MASK 0x04ceu
82#define RGBX_V2_SECTION_REQUIRED_MASK 0x048eu
83
85#define RGBX_V2_CAPABILITY_BUTTONS (1u << 0)
87#define RGBX_V2_CAPABILITY_IMU (1u << 1)
89#define RGBX_V2_CAPABILITY_AUDIO (1u << 2)
91#define RGBX_V2_CAPABILITY_ALL \
92 (RGBX_V2_CAPABILITY_BUTTONS | RGBX_V2_CAPABILITY_IMU | RGBX_V2_CAPABILITY_AUDIO)
93
105
106#if defined(__cplusplus)
108#define RGBX_V2_EXTERN_C extern "C"
109#else
111#define RGBX_V2_EXTERN_C extern
112#endif
113
114#if defined(__wasm__)
119#define RGBX_V2_IMPORT(name) __attribute__((import_module("rgbx_v2"), import_name(name)))
124#define RGBX_V2_EXPORT(name) __attribute__((export_name(name)))
125#else
127#define RGBX_V2_IMPORT(name)
129#define RGBX_V2_EXPORT(name)
130#endif
131
137RGBX_V2_EXTERN_C uint32_t rgbx_v2_param_u32(uint32_t id) RGBX_V2_IMPORT("param_u32");
144RGBX_V2_EXTERN_C uint32_t rgbx_v2_input_u32(uint32_t kind, uint32_t index)
145 RGBX_V2_IMPORT("input_u32");
151 RGBX_V2_IMPORT("set_good_moment");
157RGBX_V2_EXTERN_C void rgbx_v2_debug_u32(uint32_t tag, uint32_t value)
158 RGBX_V2_IMPORT("debug_u32");
159
172RGBX_V2_EXTERN_C void rgbx_v2_set_span8(uint32_t first_pixel, uint32_t color0, uint32_t color1,
173 uint32_t color2, uint32_t color3, uint32_t color4,
174 uint32_t color5, uint32_t color6, uint32_t color7)
175 RGBX_V2_IMPORT("set_span8");
176
191RGBX_V2_EXTERN_C void rgbx_v2_set_luma_span8(uint32_t first_pixel, uint32_t foreground,
192 uint32_t background, uint32_t luma0, uint32_t luma1,
193 uint32_t luma2, uint32_t luma3, uint32_t luma4,
194 uint32_t luma5, uint32_t luma6, uint32_t luma7)
195 RGBX_V2_IMPORT("set_luma_span8");
196
197/* Every guest exports exactly these signatures:
198 *
199 * RGBX_V2_EXPORT("rgbx_init") void rgbx_init(void);
200 * RGBX_V2_EXPORT("rgbx_tick") void rgbx_tick(uint32_t dt_ms);
201 *
202 * A complete frame is 60 ordered calls to exactly one span function at
203 * first_pixel offsets 0, 8, ..., 472. A guest that imports
204 * set_good_moment must call it exactly once per successfully committed frame.
205 */
206
207#undef RGBX_V2_EXTERN_C
#define RGBX_V2_IMPORT(name)
Host-parser no-op form of RGBX_V2_IMPORT().
Definition rgbx_v2.h:127
RGBX_V2_EXTERN_C uint32_t rgbx_v2_param_u32(uint32_t id) RGBX_V2_IMPORT("param_u32")
Read one numeric parameter from the immutable tick snapshot.
RGBX_V2_EXTERN_C uint32_t rgbx_v2_input_u32(uint32_t kind, uint32_t index) RGBX_V2_IMPORT("input_u32")
Read one sensor, button, or bounded string-summary value.
RGBX_V2_EXTERN_C void rgbx_v2_debug_u32(uint32_t tag, uint32_t value) RGBX_V2_IMPORT("debug_u32")
Append one bounded numeric diagnostic to the current frame.
#define RGBX_V2_EXTERN_C
C-linkage declaration helper used by the flat guest ABI.
Definition rgbx_v2.h:108
RGBX_V2_EXTERN_C void rgbx_v2_set_luma_span8(uint32_t first_pixel, uint32_t foreground, uint32_t background, uint32_t luma0, uint32_t luma1, uint32_t luma2, uint32_t luma3, uint32_t luma4, uint32_t luma5, uint32_t luma6, uint32_t luma7) RGBX_V2_IMPORT("set_luma_span8")
Emit eight luma values interpolated between two RGB24 colors.
RGBX_V2_EXTERN_C void rgbx_v2_set_span8(uint32_t first_pixel, uint32_t color0, uint32_t color1, uint32_t color2, uint32_t color3, uint32_t color4, uint32_t color5, uint32_t color6, uint32_t color7) RGBX_V2_IMPORT("set_span8")
Emit eight consecutive native RGB24 colors.
rgbx_v2_input_kind
Selector passed to rgbx_v2_input_u32().
Definition rgbx_v2.h:95
@ RGBX_V2_INPUT_AUDIO_DISPLAY_Q16
Q16 display energy; index 0..19.
Definition rgbx_v2.h:97
@ RGBX_V2_INPUT_BUTTONS_PRESSED
Pressed-button mask; index must be zero.
Definition rgbx_v2.h:99
@ RGBX_V2_INPUT_AUDIO_BEAT_MASK
Beat bit mask; index must be zero.
Definition rgbx_v2.h:98
@ RGBX_V2_INPUT_GYRO_MILLI
Signed gyroscope axis; index 0..2.
Definition rgbx_v2.h:101
@ RGBX_V2_INPUT_AUDIO_BAND_Q16
Q16 energy; index 0..3.
Definition rgbx_v2.h:96
@ RGBX_V2_INPUT_STRING_LENGTH
String length; string slot 0..3.
Definition rgbx_v2.h:102
@ RGBX_V2_INPUT_ACCEL_MILLI
Signed accelerometer axis; index 0..2.
Definition rgbx_v2.h:100
@ RGBX_V2_INPUT_STRING_BYTE_SUM
Unsigned byte sum; string slot 0..3.
Definition rgbx_v2.h:103
RGBX_V2_EXTERN_C void rgbx_v2_set_good_moment(uint32_t value) RGBX_V2_IMPORT("set_good_moment")
Publish this frame's shuffle-safe boundary signal.