Skip to content

Commit

Permalink
led patterns bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vascofazza committed Jan 7, 2021
1 parent c627720 commit 514521c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
8 changes: 6 additions & 2 deletions nixie_firmware/src/cloxie_firmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ bool sleeping = false;
bool calibration = false;

LedPatternList clock_patterns = {lava, lava_beat};
LedPatternList random_patterns = {rainbow, confetti, juggle, pacifica, pride};
LedPatternList random_patterns = {lava, rainbow, confetti, juggle, lava_beat, pacifica, pride};
LedPatternList date_patterns = {rainbowWithGlitter};
LedPatternList temp_patterns = {pulse};
LedPatternList timer_patterns = {sinelon};
Expand Down Expand Up @@ -180,6 +180,7 @@ void handle_loop()
{
timer_running = false;
cycle_handler.OneShot(clock_driver->is_timer_running() ? TIMER_CYCLE : STOPWATCH_CYCLE, next_cycle);
set_led_patterns(cycle);
}
else
{
Expand Down Expand Up @@ -289,7 +290,10 @@ void set_led_patterns(uint8_t cycle)
break;
case CYCLE::STOPWATCH:
case CYCLE::TIMER:
led_driver->set_patterns(timer_patterns, ARRAY_SIZE(timer_patterns), &(pattern_status[cycle]));
if (clock_driver->is_timer_running() || clock_driver->is_stopwatch_running())
led_driver->set_patterns(timer_patterns, ARRAY_SIZE(timer_patterns), &(pattern_status[cycle]));
else
led_driver->set_patterns(notify_patterns, ARRAY_SIZE(timer_patterns), &(pattern_status[cycle]));
break;
case CYCLE::CLOCK:
default:
Expand Down
4 changes: 2 additions & 2 deletions nixie_firmware/src/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <EEPROM.h>
#include "utils.hpp"

#define FIRMWARE_VERSION PSTR("1.4.1")
#define FIRMWARE_VERSION PSTR("1.4.2")

//#define DEBUG

Expand Down Expand Up @@ -45,7 +45,7 @@
//LEDS
#define NUM_LEDS 6
#define FRAMES_PER_SECOND 30
#define PATTERN_DELAY 600000
#define PATTERN_DELAY 600000 //10 mins
#define HUE_DELAY 250
#define MIN_LED_BRIGHTNESS 15
#define MAX_LED_BRIGHNTESS 100
Expand Down
3 changes: 3 additions & 0 deletions nixie_firmware/src/drivers/leds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ void LedDriver::set_patterns(LedPatternList patterns, uint8_t patterns_num, uint
this->pattern = pattern;
this->patterns = patterns;
this->patterns_num = patterns_num;

if (*(this->pattern) >= patterns_num)
*(this->pattern) = 0;
}

void LedDriver::turn_off(bool fade)
Expand Down
11 changes: 5 additions & 6 deletions nixie_firmware/src/drivers/leds_patterns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ void confetti(CRGB *leds, uint8_t num_leds, int gHue)
void sinelon(CRGB *leds, uint8_t num_leds, int gHue)
{
// a colored dot sweeping back and forth, with fading trails
fadeToBlackBy(leds, num_leds, 20);
int pos = beatsin16(13, 0, num_leds - 1);
fadeToBlackBy(leds, num_leds, 15);
int pos = beatsin16(30, 0, num_leds - 1);
leds[pos] += CHSV(gHue, 255, 100);
}

Expand Down Expand Up @@ -134,12 +134,11 @@ void pride(CRGB *leds, uint8_t num_leds, int gHue)
void pulse(CRGB *leds, uint8_t num_leds, int gHue)
{
// colored stripes pulsing at a defined Beats-Per-Minute (BPM)
uint8_t BeatsPerMinute = 60;
CRGBPalette16 palette = PartyColors_p;
uint8_t BeatsPerMinute = 30;
uint8_t beat = beatsin8(BeatsPerMinute, 64, 255);
for (int i = 0; i < num_leds; i++)
{ //9948
leds[i] = ColorFromPalette(palette, gHue, beat);
{
leds[i] = CHSV(gHue, 255, beat);
}
}

Expand Down

0 comments on commit 514521c

Please sign in to comment.