Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 10 additions & 10 deletions Helios/Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ void Button::enableWake()
ISR(PCINT0_vect) {
PCMSK &= ~(1 << PCINT3);
GIMSK &= ~(1 << PCIE);
Helios::wakeup();
}
#endif

Expand All @@ -108,8 +107,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;
Expand Down Expand Up @@ -138,10 +137,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));
Expand Down Expand Up @@ -171,13 +171,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();
Expand Down Expand Up @@ -205,10 +205,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
Expand Down
5 changes: 5 additions & 0 deletions Helios/Button.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef BUTTON_H
#define BUTTON_H

#include <stdint.h>

#ifdef HELIOS_CLI
Expand Down Expand Up @@ -117,3 +120,5 @@ class Button
static bool m_enableWake;
#endif
};

#endif // BUTTON_H
5 changes: 4 additions & 1 deletion Helios/ColorConstants.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#ifndef COLOR_CONSTANTS_H
#define COLOR_CONSTANTS_H

#include <inttypes.h>

Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions Helios/Colortypes.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef COLOR_H
#define COLOR_H
#ifndef COLORTYPES_H
#define COLORTYPES_H

#include <inttypes.h>

Expand Down
5 changes: 5 additions & 0 deletions Helios/Helios.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef HELIOS_H
#define HELIOS_H

#include <stdint.h>

#include "HeliosConfig.h"
Expand Down Expand Up @@ -126,3 +129,5 @@ class Helios
static bool sleeping;
#endif
};

#endif // HELIOS_H
5 changes: 5 additions & 0 deletions Helios/Led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Helios/Led.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion Helios/Pattern.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "Pattern.h"

//#include "../Patterns/PatternBuilder.h"
#include "TimeControl.h"
#include "Colorset.h"

Expand Down
5 changes: 4 additions & 1 deletion Helios/Random.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#ifndef RANDOM_H
#define RANDOM_H

#include <stdint.h>

Expand All @@ -18,3 +19,5 @@ class Random
uint32_t m_seed;
};

#endif // RANDOM_H

5 changes: 1 addition & 4 deletions Helios/TimeControl.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#include "TimeControl.h"

#include <math.h>

#include "Timings.h"

#include "Led.h"
#include <math.h>

#ifdef HELIOS_EMBEDDED
#include <avr/sleep.h>
Expand Down
21 changes: 9 additions & 12 deletions Helios/TimeControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,24 @@

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();

// 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
Expand Down