[DO NOT MERGE] kurt/helios-RAII-wasm#151
Conversation
…ine instances"" This reverts commit b8b7065.
- Remove Helios.h include from HeliosInstance.h (circular include) - Fix getCurColor() to not be const (accesses static Led) - Remove cur_pattern from WASM bindings (caused embind template errors) - Keep only needed methods: init, tick, getCurColor, setColorset, setArgs, setMode
47e3e00 to
80f27a1
Compare
- Add static create() method to HeliosInstance - Export createHeliosInstance() function from WASM - Update JS to use factory function instead of constructor
- Include TimeControl.h to manage timing for patterns. - Call Time::tickClock() in the tick() method to ensure pattern timers function correctly.
…ts across Helios components
Convert Helios controller and core services (pattern runtime, storage, LED, time, and button) to instance-owned state, preserve ISR bridge compatibility, and isolate WASM bindings/build to instance-only APIs.
Introduce HeliosCallbacks and wire button, LED, time, and storage hookpoints through Helios/HeliosLib, with WASM-exposed callback registration APIs for event-driven host integration.
Allow NUM_COLOR_SLOTS override from config and set a safe WASM slot cap so randomizer can vary from 1..N without being hard-limited to 6.
…ntime API. This updates Helios core ownership wiring to use Helios-scoped dependencies, removes legacy static runtime bridges, and consolidates WASM preview/randomizer behavior onto HeliosLib while preserving existing frontend behavior.
This removes remaining non-conforming helper/globals and inheritance layers, deletes obsolete HeliosInstance/HeliosPattern* files, and keeps engine/runtime access consistently instance-based through Helios references.
…te LED color setting to only occur when the color is marked as dirty, improving efficiency. Initialize and reset color dirty state in Pattern class.
| #ifdef HELIOS_EMBEDDED | ||
| #ifdef HELIOS_ARDUINO | ||
| return digitalRead(3) == HIGH; | ||
| defaultState = digitalRead(3) == HIGH; |
There was a problem hiding this comment.
This is changing the code, dont change the code.
Do not create new variables or logic.
This should work exactly the same as it did before.
Adding the ifdef to call the callback a few lines down is correct, but adding defaultState is not, get rid of it.
| return m_pinState; | ||
| defaultState = m_pinState; | ||
| #endif | ||
| return m_helios.callbacks().checkPinHook(BUTTON_PIN, defaultState); |
There was a problem hiding this comment.
This should be inside a ifdef helios_lib it only builds on desktop.
The whole callbacks thing should all be inside ifdef helios lib. Callbacks dont exist if you built this branch for embedded
| #include <queue> | ||
| #endif | ||
|
|
||
| class Time; |
There was a problem hiding this comment.
Forward decls should not be necessary, delete.
If they are necessary its because something is done wrong.
Shouldn't have references to time or whatever here in the header, and where they are used in the cpp file the appropriate header would just be included.
So ya delete these forward decls
| // The number of slots in a colorset | ||
| // The number of slots in a colorset. | ||
| // Firmware default remains 6, but WASM can override via compiler define. | ||
| #ifndef NUM_COLOR_SLOTS |
|
|
||
| #include "Led.h" | ||
|
|
||
| #include "TimeControl.h" |
There was a problem hiding this comment.
Your still using m_helios.time()
You still should include this, the only reason it works without this include is because another header indirectly included it.
Restore this, unnecessary deletion
…d duration calculations. Introduce external Helios reference in ISR for wakeup functionality. Update Button header guard for consistency.
893f278 to
1836cf5
Compare
…M build - Add fade_dur param to PatternArgs (Pattern.h/cpp) - Add isFade() method and tickFade() logic to Pattern - Add PATTERN_FADE, PATTERN_MORPH_FADE, PATTERN_GLITCH_FADE to Patterns.h/cpp - Update HeliosLib WASM bindings for new fade_dur param and pattern IDs - Fix pre-existing WASM build errors: Pattern pointer initialization with Helios ref, checkPinHook signature mismatch, missing restart/tick/getCurColor Made-with: Cursor
tickClock() busy-waits up to 1ms per tick to enforce TICKRATE=1000. When multiple WASM engines run in parallel (fingerroll/multi-light preview), this blocks the browser main thread causing severe lag. JS rAF controls timing for WASM, so the timestep serves no purpose and must be disabled. Made-with: Cursor
Backport cleanup from master (#152): replace #pragma once in Button.h and add missing include guard to Helios.h with standard #ifndef guards. This reduces the diff against master for the RAII PR review. Made-with: Cursor
| # generic clean target | ||
| clean: | ||
| @$(RM) $(DFILES) $(OBJS) $(TARGETS) $(TESTS) | ||
| @$(RM) ../Helios/*.o ../Helios/*.d ../Helios/*.avr.o ../Helios/*.avr.d |
There was a problem hiding this comment.
do we want this in main/helios/aeos?
|
|
||
| clean: | ||
| rm -f $(OBJS) $(TARGET).elf $(TARGET).hex $(DFILES) $(TARGET).bin $(TARGET).eep $(TARGET).lst $(TARGET).map | ||
| rm -f ../Helios/*.o ../Helios/*.d ../Helios/*.avr.o ../Helios/*.avr.d |
There was a problem hiding this comment.
same here, do we want this in main/helios/aeos?
|
|
||
| ifdef WASM | ||
| DEFINES += -D WASM | ||
| DEFINES += -D NUM_COLOR_SLOTS=80 |
There was a problem hiding this comment.
what the heck is NUM_COLOR_SLOTS for O.o
| # generic clean target | ||
| clean: | ||
| @$(RM) $(DFILES) $(OBJS) $(TARGETS) $(TESTS) HeliosLib.js HeliosLib.wasm | ||
| @$(RM) ../Helios/*.o ../Helios/*.d ../Helios/*.avr.o ../Helios/*.avr.d |
There was a problem hiding this comment.
same here, do we want this in main?
- Fix Pattern::crc32() to hash only m_args and m_colorset directly, skipping the m_helios reference (a pointer with non-deterministic address that made the randomizer seed change each run) - Restore helios.wakeup() in HELIOS_EMBEDDED ISR(PCINT0_vect) using the global Helios instance per Daniel's review feedback - Re-record 22 integration tests whose golden output changed due to the new PATTERN_FADE/MORPH_FADE/GLITCH_FADE pattern IDs shifting the PATTERN_COUNT used by the randomizer Made-with: Cursor
- Add comment to HeliosLib/Makefile explaining NUM_COLOR_SLOTS=80: overrides the embedded default of 6 so the WASM web editor supports up to 80 colors per mode (no flash constraints in browser) - Remove stale comment "this was used before..." from HeliosLib/Makefile (LDFLAGS line is still needed) - Add comments to all three clean targets noting they are candidates to backport to master/aeos (intentional full-repo clean behavior) Made-with: Cursor
Made-with: Cursor
This PR adds the
HeliosInstanceclass to enable multiple independent WASM engine instances on the same page.Changes
HeliosInstanceclassWhy
The current Helios class uses all static members, making it impossible to have multiple independent mode previews on the same page (like a grid of mode cards). Each preview would share the same pattern/colorset state.
Usage
This enables the Glow-LEDs mode grid to show live previews for all modes simultaneously.