Skip to content

Commit

Permalink
v0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vascofazza committed Nov 3, 2020
1 parent 259a8c4 commit 8782cf4
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 54 deletions.
4 changes: 2 additions & 2 deletions nixie_firmware/src/clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void ClockDriver::loop()
{
blink_dots(static_on);
}

print_timer();
}
else if (display_time)
Expand Down Expand Up @@ -97,7 +97,7 @@ void ClockDriver::print_timer()
if (val <= 0)
reset_timer();

unsigned long durCS = (val % 1000) / 10; //Cent-seconds
unsigned long durCS = (val % 1000) / 10; //Cent-seconds
unsigned long durSS = (val / 1000) % 60; //Seconds
unsigned long durMM = (val / (60000)) % 60; //Minutes
unsigned long durHH = (val / (3600000)); //Hours
Expand Down
25 changes: 12 additions & 13 deletions nixie_firmware/src/clock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using namespace ace_time::clock;
class ClockDriver
{
private:
TubeDriver* tube_driver;
TubeDriver *tube_driver;
BasicZoneProcessor zoneProcessor;
NtpClock ntpClock;
SystemClockLoop *systemClock;
Expand All @@ -28,28 +28,27 @@ class ClockDriver
void blink_dots(void (*)(TubeDriver *, bool, elapsedMillis *));

public:
ClockDriver(TubeDriver *);

ClockDriver(TubeDriver*);
void loop();

void loop();
void show_time(bool);

void show_time(bool);
void show_date(bool);

void show_date(bool);
void show_timer(bool);

void show_timer(bool);
void start_timer(long duration);

void start_timer(long duration);
void stop_timer();

void stop_timer();
void reset_timer();

void reset_timer();
bool is_timer_set();

bool is_timer_set();
bool is_timer_running();

bool is_timer_running();

void set_alarm(long offset);
void set_alarm(long offset);
};

typedef void (*BlinkPatternList[])(TubeDriver *, bool, elapsedMillis *);
Expand Down
9 changes: 4 additions & 5 deletions nixie_firmware/src/cloxie_firmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ void setup()
led_driver = new LedDriver(tube_driver, NUM_LEDS);
sensor_driver = new SensorDriver(tube_driver);

check_for_updates();
ota_handler.Every(60000, check_for_updates);
ota_handler.Every(GHOTA_INTERVAL, check_for_updates);

cycle_handler.OneShot(0, next_cycle);

// test the tubes
//tube_driver->run_test();
tube_driver->run_test();
}

void next_cycle()
Expand All @@ -75,8 +74,8 @@ void next_cycle()
case CYCLE::TIMER:
if (clock_driver->is_timer_set())
{
cycle_handler.OneShot(TIMER_CYCLE, next_cycle);
break;
cycle_handler.OneShot(TIMER_CYCLE, next_cycle);
break;
}
default:
cycle = CYCLE::CLOCK;
Expand Down
1 change: 0 additions & 1 deletion nixie_firmware/src/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ void check_params()
config.shutdown_delay = config.shutdown_delay > 10000 || config.shutdown_delay < -1 ? 3600 : config.shutdown_delay;
config.led_configuration = config.led_configuration > 3 || config.led_configuration < 0 ? 0 : config.led_configuration;
config.blink_mode = config.blink_mode > 3 || config.blink_mode < 0 ? 0 : config.blink_mode;
//TODO add default values
}

void setup_configuration()
Expand Down
3 changes: 1 addition & 2 deletions nixie_firmware/src/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
//MISC
#define TEST_TIME 10
#define DEFAULT_BRIGHTNESS PWMRANGE / 2
#define TRANSITION_TIME 10 * 1000 //5s
#define TRANSITION_TIME 10 * 1000 //10s

//GITHUB
#define GHOTA_USER PSTR("vascofazza")
Expand All @@ -51,7 +51,6 @@
#define GHOTA_ACCEPT_PRERELEASE 0
#define GHOTA_INTERVAL 3600 * 6 * 1000 //6h


struct Config
{
int timezone = 0;
Expand Down
2 changes: 1 addition & 1 deletion nixie_firmware/src/leds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

LedPatternList gPatterns = {rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm};

LedDriver::LedDriver(TubeDriver* tube_driver, int num_leds)
LedDriver::LedDriver(TubeDriver *tube_driver, int num_leds)
{
this->tube_driver = tube_driver;
leds = new CRGB[num_leds];
Expand Down
1 change: 1 addition & 0 deletions nixie_firmware/src/leds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class LedDriver
CRGB *leds;
int pattern;
int brightness;

public:
LedDriver(TubeDriver *, int);

Expand Down
46 changes: 25 additions & 21 deletions nixie_firmware/src/leds_patterns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,63 @@

#include <FastLED.h>

void rainbow(CRGB* leds, int num_leds, int gHue)
void rainbow(CRGB *leds, int num_leds, int gHue)
{
// FastLED's built-in rainbow generator
fill_rainbow( leds, num_leds, gHue, 7);
fill_rainbow(leds, num_leds, gHue, 7);
}

void addGlitter(CRGB* leds, int num_leds, fract8 chanceOfGlitter)
void addGlitter(CRGB *leds, int num_leds, fract8 chanceOfGlitter)
{
if( random8() < chanceOfGlitter) {
leds[ random16(num_leds) ] += CRGB::White;
if (random8() < chanceOfGlitter)
{
leds[random16(num_leds)] += CRGB::White;
}
}

void rainbowWithGlitter(CRGB* leds, int num_leds, int gHue)
void rainbowWithGlitter(CRGB *leds, int num_leds, int gHue)
{
// built-in FastLED rainbow, plus some random sparkly glitter
rainbow(leds, num_leds, gHue);
addGlitter(leds, num_leds, 80);
}

void confetti(CRGB* leds, int num_leds, int gHue)
void confetti(CRGB *leds, int num_leds, int gHue)
{
// random colored speckles that blink in and fade smoothly
fadeToBlackBy( leds, num_leds, 10);
fadeToBlackBy(leds, num_leds, 10);
int pos = random16(num_leds);
leds[pos] += CHSV( gHue + random8(64), 200, 255);
leds[pos] += CHSV(gHue + random8(64), 200, 255);
}

void sinelon(CRGB* leds, int num_leds, int gHue)
void sinelon(CRGB *leds, int 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 );
leds[pos] += CHSV( gHue, 255, 192);
fadeToBlackBy(leds, num_leds, 20);
int pos = beatsin16(13, 0, num_leds - 1);
leds[pos] += CHSV(gHue, 255, 192);
}

void bpm(CRGB* leds, int num_leds, int gHue)
void bpm(CRGB *leds, int num_leds, int gHue)
{
// colored stripes pulsing at a defined Beats-Per-Minute (BPM)
uint8_t BeatsPerMinute = 62;
CRGBPalette16 palette = PartyColors_p;
uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
for( int i = 0; i < num_leds; i++) { //9948
leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
uint8_t beat = beatsin8(BeatsPerMinute, 64, 255);
for (int i = 0; i < num_leds; i++)
{ //9948
leds[i] = ColorFromPalette(palette, gHue + (i * 2), beat - gHue + (i * 10));
}
}

void juggle(CRGB* leds, int num_leds, int gHue) {
void juggle(CRGB *leds, int num_leds, int gHue)
{
// eight colored dots, weaving in and out of sync with each other
fadeToBlackBy( leds, num_leds, 20);
fadeToBlackBy(leds, num_leds, 20);
byte dothue = 0;
for( int i = 0; i < 8; i++) {
leds[beatsin16( i+7, 0, num_leds-1 )] |= CHSV(dothue, 200, 255);
for (int i = 0; i < 8; i++)
{
leds[beatsin16(i + 7, 0, num_leds - 1)] |= CHSV(dothue, 200, 255);
dothue += 32;
}
}
Expand Down
14 changes: 7 additions & 7 deletions nixie_firmware/src/serial_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,38 @@ static char serial_command_buffer_[32];
static SerialCommands serial_commands_(&Serial, serial_command_buffer_, sizeof(serial_command_buffer_), "\r\n", " ");

//This is the default handler, and gets called when no other command matches.
void cmd_unrecognized(SerialCommands* sender, const char* cmd)
void cmd_unrecognized(SerialCommands *sender, const char *cmd)
{
sender->GetSerial()->print(F("Unrecognized command ["));
sender->GetSerial()->print(cmd);
sender->GetSerial()->println(F("]"));
}

void cmd_reset_wifi(SerialCommands* sender)
void cmd_reset_wifi(SerialCommands *sender)
{
sender->GetSerial()->println(F("Resetting Wifi settings."));
reset_wifi_settings();
}

void cmd_start_timer(SerialCommands* sender)
void cmd_start_timer(SerialCommands *sender)
{
sender->GetSerial()->println(F("Starting timer for 61 minute"));
clock_driver->start_timer(60*61*1000);
clock_driver->start_timer(60 * 61 * 1000);
}

void cmd_stop_timer(SerialCommands* sender)
void cmd_stop_timer(SerialCommands *sender)
{
sender->GetSerial()->println(F("Stopping timer."));
clock_driver->stop_timer();
}

void cmd_reset_timer(SerialCommands* sender)
void cmd_reset_timer(SerialCommands *sender)
{
sender->GetSerial()->println(F("Resetting timer."));
clock_driver->reset_timer();
}

void cmd_resume_timer(SerialCommands* sender)
void cmd_resume_timer(SerialCommands *sender)
{
sender->GetSerial()->println(F("Resuming timer."));
clock_driver->start_timer(-1);
Expand Down
1 change: 1 addition & 0 deletions nixie_firmware/src/tube_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class TubeDriver
EveryTimer cathode_poisoning_cycle;

void set_tube_brightness(int, int, int);

public:
TubeDriver();

Expand Down
2 changes: 1 addition & 1 deletion nixie_firmware/src/wifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void saveParamsCallback()
Serial.println(google_token->getValue());
Serial.print(F("PARAM timezone_field = "));
Serial.println(getParam(F("timezone_field")));
Serial.print(F("PARAM h24_field = "));
Serial.print(F("PARAM h24_field = "));
Serial.println(getParam(F("h24_field")));
Serial.print(F("PARAM blink_field = "));
Serial.println(getParam(F("blink_field")));
Expand Down
2 changes: 1 addition & 1 deletion nixie_firmware/src/wifi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ static WiFiManager wifiManager;

String getParam(String);

void saveParamsCallback ();
void saveParamsCallback();

void setup_wifi();

Expand Down

0 comments on commit 8782cf4

Please sign in to comment.