diff --git a/Helios/Button.cpp b/Helios/Button.cpp index 20dd5bde..e9721bef 100644 --- a/Helios/Button.cpp +++ b/Helios/Button.cpp @@ -103,7 +103,6 @@ void button_enable_wake(void) ISR(PCINT0_vect) { PCMSK &= ~(1 << PCINT3); GIMSK &= ~(1 << PCIE); - helios_wakeup(); } #endif @@ -158,10 +157,11 @@ void button_update(void) m_releaseCount++; } } + const uint32_t curtime = time_get_current_time(); if (m_isPressed) { - m_holdDuration = (time_get_current_time() >= m_pressTime) ? (uint32_t)(time_get_current_time() - m_pressTime) : 0; + m_holdDuration = (curtime >= m_pressTime) ? (uint32_t)(curtime - m_pressTime) : 0; } else { - m_releaseDuration = (time_get_current_time() >= m_releaseTime) ? (uint32_t)(time_get_current_time() - 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)); 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/Colortypes.h b/Helios/Colortypes.h index b1f0616b..11d39ce7 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 diff --git a/Helios/TimeControl.cpp b/Helios/TimeControl.cpp index ff33a894..42d63592 100644 --- a/Helios/TimeControl.cpp +++ b/Helios/TimeControl.cpp @@ -4,12 +4,9 @@ #endif #include "TimeControl.h" - -#include - #include "Timings.h" -#include "Led.h" +#include #ifdef HELIOS_EMBEDDED #include diff --git a/Helios/TimeControl.h b/Helios/TimeControl.h index 587bddb8..37c6ec5e 100644 --- a/Helios/TimeControl.h +++ b/Helios/TimeControl.h @@ -20,15 +20,17 @@ void time_cleanup(void); // Tick the clock forward to millis() void time_tick_clock(void); -// Get the current tick, offset by any active simulation (simulation only exists in vortexlib) -// Exposing this as inline or macro 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 repetitive calls +// Get the current engine tick number (1 tick per millisecond) uint32_t time_get_current_time(void); -// 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 time_get_current_time() 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 time_get_current_time() +// Current microseconds since startup *DO NOT USE THIS API!* +// +// If you just need to perform regular time checks for a pattern or some +// logic then use time_get_current_time() 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 time_get_current_time(). The engine thinks in +// ticks, only the timestep system sees microseconds, purely to maintain a +// stable tickrate. uint32_t time_microseconds(void); // Delay for some number of microseconds or milliseconds, these are bad