From 36f08c4f48349a118057bfbe2d83f250a4d830ae Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Fri, 27 Feb 2026 21:19:47 +0100 Subject: [PATCH 1/8] Add header guards and clean up unnecessary self-qualification in Button - Add proper #ifndef/#define header guards to Button.h, Helios.h, ColorConstants.h, and Random.h (replacing #pragma once where used) - Remove unnecessary Button:: self-qualification on static method calls within Button.cpp (holdPressing, processPreInput, processPostInput) - Extract repeated Time::getCurtime() calls into const local variable in Button::update() Made-with: Cursor --- Helios/Button.cpp | 19 ++++++++++--------- Helios/Button.h | 5 +++++ Helios/ColorConstants.h | 5 ++++- Helios/Helios.h | 5 +++++ Helios/Random.h | 5 ++++- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Helios/Button.cpp b/Helios/Button.cpp index b58ed095..dd7f46a7 100644 --- a/Helios/Button.cpp +++ b/Helios/Button.cpp @@ -108,8 +108,8 @@ bool Button::check() // detect if the button is being held for a long hold (past long click) bool Button::holdPressing() { - uint16_t holDur = (uint16_t)(Button::holdDuration()); - if (holDur > HOLD_CLICK_START && holDur <= HOLD_CLICK_END && Button::isPressed()) { + uint16_t holDur = (uint16_t)holdDuration(); + if (holDur > HOLD_CLICK_START && holDur <= HOLD_CLICK_END && isPressed()) { return true; } return false; @@ -138,10 +138,11 @@ void Button::update() m_releaseCount++; } } + const uint32_t curtime = Time::getCurtime(); if (m_isPressed) { - m_holdDuration = (Time::getCurtime() >= m_pressTime) ? (uint32_t)(Time::getCurtime() - m_pressTime) : 0; + m_holdDuration = (curtime >= m_pressTime) ? (uint32_t)(curtime - m_pressTime) : 0; } else { - m_releaseDuration = (Time::getCurtime() >= m_releaseTime) ? (uint32_t)(Time::getCurtime() - m_releaseTime) : 0; + m_releaseDuration = (curtime >= m_releaseTime) ? (uint32_t)(curtime - m_releaseTime) : 0; } m_shortClick = (m_newRelease && (m_holdDuration <= SHORT_CLICK_THRESHOLD)); m_longClick = (m_newRelease && (m_holdDuration > SHORT_CLICK_THRESHOLD) && (m_holdDuration < HOLD_CLICK_START)); @@ -171,13 +172,13 @@ bool Button::processPreInput() char command = m_inputQueue.front(); switch (command) { case 'p': // press - Button::doPress(); + doPress(); break; case 'r': // release - Button::doRelease(); + doRelease(); break; case 't': // toggle - Button::doToggle(); + doToggle(); break; case 'q': // quit Helios::terminate(); @@ -205,10 +206,10 @@ bool Button::processPostInput() char command = m_inputQueue.front(); switch (command) { case 'c': // click button - Button::doShortClick(); + doShortClick(); break; case 'l': // long click button - Button::doLongClick(); + doLongClick(); break; default: // should never happen diff --git a/Helios/Button.h b/Helios/Button.h index 33d26ecf..161e246b 100644 --- a/Helios/Button.h +++ b/Helios/Button.h @@ -1,3 +1,6 @@ +#ifndef BUTTON_H +#define BUTTON_H + #include #ifdef HELIOS_CLI @@ -117,3 +120,5 @@ class Button static bool m_enableWake; #endif }; + +#endif // BUTTON_H diff --git a/Helios/ColorConstants.h b/Helios/ColorConstants.h index 8801d4ac..e5c7c2e4 100644 --- a/Helios/ColorConstants.h +++ b/Helios/ColorConstants.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef COLOR_CONSTANTS_H +#define COLOR_CONSTANTS_H #include @@ -159,3 +160,5 @@ #define RGB_PINK_SAT_LOWEST (uint32_t)0xE87DFF // 232, 125, 255 #define RGB_HOT_PINK_SAT_LOWEST (uint32_t)0xFF7DD8 // 255, 125, 216 #define RGB_MAGENTA_SAT_LOWEST (uint32_t)0xFF7D9B // 255, 125, 155 + +#endif // COLOR_CONSTANTS_H diff --git a/Helios/Helios.h b/Helios/Helios.h index eef2d972..3e2ec9d3 100644 --- a/Helios/Helios.h +++ b/Helios/Helios.h @@ -1,3 +1,6 @@ +#ifndef HELIOS_H +#define HELIOS_H + #include #include "HeliosConfig.h" @@ -126,3 +129,5 @@ class Helios static bool sleeping; #endif }; + +#endif // HELIOS_H diff --git a/Helios/Random.h b/Helios/Random.h index 1f556f42..9dbb482e 100644 --- a/Helios/Random.h +++ b/Helios/Random.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef RANDOM_H +#define RANDOM_H #include @@ -18,3 +19,5 @@ class Random uint32_t m_seed; }; +#endif // RANDOM_H + From 5086b3c3e58bcb38017cb5b691c78b35d055b526 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 3 Mar 2026 00:48:12 -0800 Subject: [PATCH 2/8] testing removing useless wakeup call --- Helios/Button.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Helios/Button.cpp b/Helios/Button.cpp index dd7f46a7..7eaa40eb 100644 --- a/Helios/Button.cpp +++ b/Helios/Button.cpp @@ -85,7 +85,6 @@ void Button::enableWake() ISR(PCINT0_vect) { PCMSK &= ~(1 << PCINT3); GIMSK &= ~(1 << PCIE); - Helios::wakeup(); } #endif From dcb853789077c9f64e9075ff829b6b3d048a2686 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 4 Mar 2026 09:51:33 -0800 Subject: [PATCH 3/8] small fix to header guard --- Helios/Colortypes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Helios/Colortypes.h b/Helios/Colortypes.h index 2a579de7..cd924c05 100644 --- a/Helios/Colortypes.h +++ b/Helios/Colortypes.h @@ -1,5 +1,5 @@ -#ifndef COLOR_H -#define COLOR_H +#ifndef COLORTYPES_H +#define COLORTYPES_H #include From e405a3c1c3871b983ede5932ee2c14421aa4c412 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 4 Mar 2026 09:59:14 -0800 Subject: [PATCH 4/8] minor code relocation --- Helios/Led.cpp | 5 +++++ Helios/Led.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Helios/Led.cpp b/Helios/Led.cpp index 13052f1e..711b9c21 100644 --- a/Helios/Led.cpp +++ b/Helios/Led.cpp @@ -67,6 +67,11 @@ void Led::adjustBrightness(uint8_t fadeBy) m_ledColor.adjustBrightness(fadeBy); } +void Led::setBrightness(uint8_t brightness) +{ + m_brightness = brightness; +} + void Led::strobe(uint16_t on_time, uint16_t off_time, RGBColor off_col, RGBColor on_col) { set(((Time::getCurtime() % (on_time + off_time)) > on_time) ? off_col : on_col); diff --git a/Helios/Led.h b/Helios/Led.h index 34c5faad..8e2658f7 100644 --- a/Helios/Led.h +++ b/Helios/Led.h @@ -42,7 +42,7 @@ class Led // global brightness static uint8_t getBrightness() { return m_brightness; } - static void setBrightness(uint8_t brightness) { m_brightness = brightness; } + static void setBrightness(uint8_t brightness); // actually update the LEDs and show the changes static void update(); From 5aaf98eb4a31afd1f39a4629987b31dc021568bf Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 4 Mar 2026 10:00:25 -0800 Subject: [PATCH 5/8] removed useless include --- Helios/Pattern.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Helios/Pattern.cpp b/Helios/Pattern.cpp index 19c4497e..ba41486f 100644 --- a/Helios/Pattern.cpp +++ b/Helios/Pattern.cpp @@ -1,6 +1,5 @@ #include "Pattern.h" -//#include "../Patterns/PatternBuilder.h" #include "TimeControl.h" #include "Colorset.h" From ce742a0a363954bcbaaa3ee4711d7faa158e19a1 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 4 Mar 2026 23:33:19 -0800 Subject: [PATCH 6/8] adjusted includes in timecontrol --- Helios/TimeControl.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Helios/TimeControl.cpp b/Helios/TimeControl.cpp index 904be2a3..e79e3721 100644 --- a/Helios/TimeControl.cpp +++ b/Helios/TimeControl.cpp @@ -1,10 +1,7 @@ #include "TimeControl.h" - -#include - #include "Timings.h" -#include "Led.h" +#include #ifdef HELIOS_EMBEDDED #include From 2e985b70b33fab08102b77784100eec87c34391c Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 4 Mar 2026 23:37:33 -0800 Subject: [PATCH 7/8] adjusted time control class in header --- Helios/TimeControl.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Helios/TimeControl.h b/Helios/TimeControl.h index b5f316d8..b4e7caee 100644 --- a/Helios/TimeControl.h +++ b/Helios/TimeControl.h @@ -11,12 +11,8 @@ class Time { - // private unimplemented constructor - Time(); - public: - // opting for static class here because there should only ever be one - // Settings control object and I don't like singletons + // initialization and cleanup of time system static bool init(); static void cleanup(); From b315663539aa396a13e6cf57630ae08a1140ac3b Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 4 Mar 2026 23:46:50 -0800 Subject: [PATCH 8/8] improve comments on timecontrol --- Helios/TimeControl.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Helios/TimeControl.h b/Helios/TimeControl.h index b4e7caee..f407c93a 100644 --- a/Helios/TimeControl.h +++ b/Helios/TimeControl.h @@ -19,15 +19,16 @@ class Time // tick the clock forward to millis() static void tickClock(); - // get the current tick, offset by any active simulation (simulation only exists in vortexlib) - // Exposing this in the header seems to save on space a non negligible amount, it is used a lot - // and exposing in the header probably allows the compiler to optimize away repititive calls + // get the current engine tick number (1 tick per millisecond) static uint32_t getCurtime() { return m_curTick; } - // Current microseconds since startup, only use this for things like measuring rapid data transfer timings. - // If you just need to perform regular time checks for a pattern or some logic then use getCurtime() and measure - // time in ticks, use the SEC_TO_TICKS() or MS_TO_TICKS() macros to convert timings to measures of ticks for - // purpose of comparing against getCurtime() + // Current microseconds since startup *DO NOT USE USING THIS API!* + // + // If you just need to perform regular time checks for a pattern or some + // logic then use getCurtime() and measure time in ticks. Use the macros + // SEC_TO_TICKS() or MS_TO_TICKS() to convert timings to measures of ticks + // then compare against getCurtime(). The engine thinks in ticks, only the + // timestep system sees microseconds, purely to maintain a stable tickrate. static uint32_t microseconds(); // delay for some number of microseconds or milliseconds, these are bad