Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1e7f952
Revert "Revert "Add HeliosInstance class for multiple independent eng…
Feb 20, 2026
80f27a1
Fix HeliosInstance build errors
Feb 20, 2026
89b9d83
Fix: add Led.h include to HeliosInstance.cpp
Feb 20, 2026
a8b0dcb
Fix: use factory function instead of constructor for HeliosInstance
Feb 20, 2026
98626c9
Update WASM binding for createHeliosInstance to allow raw pointers
livingkurt Feb 20, 2026
8a8e614
Add TimeControl integration in HeliosInstance
livingkurt Feb 20, 2026
b93ce8f
Update HeliosEngine
livingkurt Feb 20, 2026
a94ba4e
Update HeliosEngine
livingkurt Feb 20, 2026
eef9158
Enhance clean targets in Makefiles to remove additional build artifac…
livingkurt Feb 20, 2026
a48c32c
Update HeliosEngine
livingkurt Feb 20, 2026
988a720
Complete full RAII runtime migration in Helios core.
livingkurt Feb 21, 2026
fc8a195
Add full HeliosLib hookpoint callback architecture.
livingkurt Feb 21, 2026
555d324
Update HeliosEngine
livingkurt Feb 22, 2026
ff12bdf
Restore variable seeded randomizer count for WASM colorsets.
livingkurt Feb 22, 2026
86ba438
Finalize reviewer-aligned RAII migration and remove HeliosInstance ru…
livingkurt Feb 22, 2026
fc7c5fb
Apply strict RAII conformance pass for HeliosLib branch.
livingkurt Feb 22, 2026
54cebfe
Refactor color handling in Helios to use a dirty flag mechanism. Upda…
livingkurt Feb 23, 2026
d028781
Refactor Button class to streamline pin state checking and update hol…
livingkurt Feb 27, 2026
1836cf5
small changes to start
Unreal-Dan Mar 3, 2026
09aead0
small code restore to led
Unreal-Dan Mar 4, 2026
e253ebd
remove unnecessary forward declaration
Unreal-Dan Mar 4, 2026
2a9e3a0
restored pattern code
Unreal-Dan Mar 4, 2026
89c9f5c
fixed up storage and callback for storage
Unreal-Dan Mar 4, 2026
0235cc6
fixed up timecontrol
Unreal-Dan Mar 5, 2026
30b71b2
small adjustments
Unreal-Dan Mar 5, 2026
c61ee54
fixed up timer
Unreal-Dan Mar 5, 2026
b7ef946
some more cleanup
Unreal-Dan Mar 5, 2026
aafc277
fixed up cli tool
Unreal-Dan Mar 5, 2026
5bb59d6
more fixes
Unreal-Dan Mar 5, 2026
fac11ac
small fixes
Unreal-Dan Mar 5, 2026
d5efc2d
proper header guard
Unreal-Dan Mar 5, 2026
06b7903
Port aeos fade pattern changes to feature/helios-instance and fix WAS…
livingkurt Mar 27, 2026
7d088ab
Disable real-time timestep in HeliosLib WASM init
livingkurt Mar 27, 2026
0da3861
Add proper header guards to Button.h and Helios.h
livingkurt Mar 27, 2026
4f5aaf2
Merge branch 'master' into feature/helios-instance
Unreal-Dan Mar 27, 2026
0e5f48b
Fix non-deterministic crc32, restore ISR wakeup, re-record tests
livingkurt Mar 28, 2026
1159f99
Address Daniel's PR review comments on Makefiles
livingkurt Mar 28, 2026
e9789ad
Reduce NUM_COLOR_SLOTS from 80 to 16 for WASM build
livingkurt Mar 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 29 additions & 34 deletions Helios/Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,26 @@

#include "Helios.h"

// static members of Button
uint32_t Button::m_pressTime = 0;
uint32_t Button::m_releaseTime = 0;
uint32_t Button::m_holdDuration = 0;
uint32_t Button::m_releaseDuration = 0;
uint8_t Button::m_releaseCount = 0;
bool Button::m_buttonState = false;
bool Button::m_newPress = false;
bool Button::m_newRelease = false;
bool Button::m_isPressed = false;
bool Button::m_shortClick = false;
bool Button::m_longClick = false;
bool Button::m_holdClick = false;

Button::Button(Helios &helios) :
m_pressTime(0),
m_releaseTime(0),
m_holdDuration(0),
m_releaseDuration(0),
m_releaseCount(0),
m_buttonState(false),
m_newPress(false),
m_newRelease(false),
m_isPressed(false),
m_shortClick(false),
m_longClick(false),
m_holdClick(false),
#ifdef HELIOS_CLI
// an input queue for the button, each tick one even is processed
// out of this queue and used to produce input
std::queue<char> Button::m_inputQueue;
// the virtual pin state
bool Button::m_pinState = false;
// whether the button is waiting to wake the device
bool Button::m_enableWake = false;
m_pinState(false),
m_enableWake(false),
#endif
m_helios(helios)
{
}

// initialize a new button object with a pin number
bool Button::init()
Expand Down Expand Up @@ -85,6 +82,7 @@ void Button::enableWake()
ISR(PCINT0_vect) {
PCMSK &= ~(1 << PCINT3);
GIMSK &= ~(1 << PCIE);
helios.wakeup();
}
#endif

Expand All @@ -100,7 +98,7 @@ bool Button::check()
#elif defined(HELIOS_CLI)
// then just return the pin state as-is, the input event may have
// adjusted this value
return m_pinState;
return m_helios.callbacks().checkPinHook(m_pinState);
#endif
}

Expand Down Expand Up @@ -129,15 +127,15 @@ void Button::update()
m_buttonState = newButtonState;
m_isPressed = m_buttonState;
if (m_isPressed) {
m_pressTime = Time::getCurtime();
m_pressTime = m_helios.time().getCurtime();
m_newPress = true;
} else {
m_releaseTime = Time::getCurtime();
m_releaseTime = m_helios.time().getCurtime();
m_newRelease = true;
m_releaseCount++;
}
}
const uint32_t curtime = Time::getCurtime();
const uint32_t curtime = m_helios.time().getCurtime();
if (m_isPressed) {
m_holdDuration = (curtime >= m_pressTime) ? (uint32_t)(curtime - m_pressTime) : 0;
} else {
Expand All @@ -156,7 +154,7 @@ void Button::update()

if (m_enableWake) {
if (m_isPressed || m_shortClick || m_longClick) {
Helios::wakeup();
m_helios.wakeup();
}
}
#endif
Expand All @@ -180,7 +178,7 @@ bool Button::processPreInput()
doToggle();
break;
case 'q': // quit
Helios::terminate();
m_helios.terminate();
break;
case 'w': // wait
// wait is pre input I guess
Expand Down Expand Up @@ -222,7 +220,7 @@ void Button::doShortClick()
{
m_newRelease = true;
m_shortClick = true;
m_pressTime = Time::getCurtime();
m_pressTime = m_helios.time().getCurtime();
m_holdDuration = SHORT_CLICK_THRESHOLD - 1;
m_releaseCount++;
}
Expand All @@ -231,7 +229,7 @@ void Button::doLongClick()
{
m_newRelease = true;
m_longClick = true;
m_pressTime = Time::getCurtime();
m_pressTime = m_helios.time().getCurtime();
m_holdDuration = SHORT_CLICK_THRESHOLD + 1;
m_releaseCount++;
}
Expand All @@ -240,7 +238,7 @@ void Button::doHoldClick()
{
m_newRelease = true;
m_holdClick = true;
m_pressTime = Time::getCurtime();
m_pressTime = m_helios.time().getCurtime();
m_holdDuration = HOLD_CLICK_START + 1;
m_releaseCount++;
}
Expand Down Expand Up @@ -268,11 +266,8 @@ void Button::queueInput(char input)
m_inputQueue.push(input);
}

uint32_t Button::inputQueueSize()
uint32_t Button::inputQueueSize() const
Comment thread
Unreal-Dan marked this conversation as resolved.
{
return m_inputQueue.size();
}
#endif

// global button
Button button;
86 changes: 45 additions & 41 deletions Helios/Button.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,51 @@
#include <queue>
#endif

class Helios;
Comment thread
Unreal-Dan marked this conversation as resolved.

class Button
{
public:
explicit Button(Helios &helios);
// initialize a new button object with a pin number
static bool init();
bool init();
// directly poll the pin for whether it's pressed right now
static bool check();
bool check();
// poll the button pin and update the state of the button object
static void update();
void update();

// whether the button was pressed this tick
static bool onPress() { return m_newPress; }
bool onPress() const { return m_newPress; }
// whether the button was released this tick
static bool onRelease() { return m_newRelease; }
bool onRelease() const { return m_newRelease; }
// whether the button is currently pressed
static bool isPressed() { return m_isPressed; }
bool isPressed() const { return m_isPressed; }

// whether the button was shortclicked this tick
static bool onShortClick() { return m_shortClick; }
bool onShortClick() const { return m_shortClick; }
// whether the button was long clicked this tick
static bool onLongClick() { return m_longClick; }
bool onLongClick() const { return m_longClick; }
// whether the button was hold clicked this tick
static bool onHoldClick() { return m_holdClick; }
bool onHoldClick() const { return m_holdClick; }

// detect if the button is being held past long click
static bool holdPressing();
bool holdPressing();

// when the button was last pressed
static uint32_t pressTime() { return m_pressTime; }
uint32_t pressTime() const { return m_pressTime; }
// when the button was last released
static uint32_t releaseTime() { return m_releaseTime; }
uint32_t releaseTime() const { return m_releaseTime; }

// how long the button is currently or was last held down (in ticks)
static uint32_t holdDuration() { return m_holdDuration; }
uint32_t holdDuration() const { return m_holdDuration; }
// how long the button is currently or was last released for (in ticks)
static uint32_t releaseDuration() { return m_releaseDuration; }
uint32_t releaseDuration() const { return m_releaseDuration; }

// the number of releases
static uint8_t releaseCount() { return m_releaseCount; }
uint8_t releaseCount() const { return m_releaseCount; }

// enable wake on press
static void enableWake();
void enableWake();

#ifdef HELIOS_CLI
// these will 'inject' a short/long click without actually touching the
Expand All @@ -58,67 +61,68 @@ class Button
// will never trigger because the injected input event doesn't actually
// press the button or change the button state it just sets the 'shortClick'
// or 'longClick' values accordingly
static void doShortClick();
static void doLongClick();
static void doHoldClick();
void doShortClick();
void doLongClick();
void doHoldClick();

// this will actually press down the button, it's your responsibility to wait
// for the appropriate number of ticks and then release the button
static void doPress();
static void doRelease();
static void doToggle();
void doPress();
void doRelease();
void doToggle();

// queue up an input event for the button
static void queueInput(char input);
static uint32_t inputQueueSize();
void queueInput(char input);
uint32_t inputQueueSize() const;
#endif

private:
// ========================================
// state data that is populated each check

// the timestamp of when the button was pressed
static uint32_t m_pressTime;
uint32_t m_pressTime;
// the timestamp of when the button was released
static uint32_t m_releaseTime;
uint32_t m_releaseTime;

// the last hold duration
static uint32_t m_holdDuration;
uint32_t m_holdDuration;
// the last release duration
static uint32_t m_releaseDuration;
uint32_t m_releaseDuration;

// the number of times released, will overflow at 255
static uint8_t m_releaseCount;
uint8_t m_releaseCount;

// the active state of the button
static bool m_buttonState;
bool m_buttonState;

// whether pressed this tick
static bool m_newPress;
bool m_newPress;
// whether released this tick
static bool m_newRelease;
bool m_newRelease;
// whether currently pressed
static bool m_isPressed;
bool m_isPressed;
// whether a short click occurred
static bool m_shortClick;
bool m_shortClick;
// whether a long click occurred
static bool m_longClick;
bool m_longClick;
// whether a long hold occurred
static bool m_holdClick;
bool m_holdClick;

#ifdef HELIOS_CLI
// process pre or post input events from the queue
static bool processPreInput();
static bool processPostInput();
bool processPreInput();
bool processPostInput();

// an input queue for the button, each tick one even is processed
// out of this queue and used to produce input
static std::queue<char> m_inputQueue;
std::queue<char> m_inputQueue;
// the virtual pin state that is polled instead of a digital pin
static bool m_pinState;
bool m_pinState;
// whether the button is waiting to wake the device
static bool m_enableWake;
bool m_enableWake;
#endif
Helios &m_helios;
};

#endif // BUTTON_H
Loading
Loading