Compare commits
No commits in common. "ae997ef8020419f6323d61a02213d76b21be4d53" and "ecf5998510bf1f8230d070cebccb4c89f95ce856" have entirely different histories.
ae997ef802
...
ecf5998510
@ -1,32 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Effect.h"
|
|
||||||
#include "prototypes.h"
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
#define SE_CYCLE_COLORS 1 // Slowly cycle through the rainbow.
|
|
||||||
#define SE_RANDOM_PIXEL_COLORS 2 // Every pixel gets a random color every frame.
|
|
||||||
#define SE_ONLY_POSITIVE 4 // Only use colors, not white. This is equivalent to running your output through abs()
|
|
||||||
#define SE_FADEOUT 8 // Fades the old image out. Returning 0 doesn't change the pixel's value.
|
|
||||||
#define SE_RANDOM_STATIC_COLOR 16 // Sets a random static color at start of the effect.
|
|
||||||
#define SE_DEBUG 32 // Prints debug messages.
|
|
||||||
|
|
||||||
class SimpleEffect : public Effect {
|
|
||||||
protected:
|
|
||||||
Window* window = &Window::window_full; // Use a full screen window per default.
|
|
||||||
uint8_t _color = 0;
|
|
||||||
uint16_t _flags;
|
|
||||||
String _name;
|
|
||||||
simple_effect_t _method;
|
|
||||||
public:
|
|
||||||
SimpleEffect(String name, uint16_t flags, simple_effect_t method): _name { name }, _method { method } {
|
|
||||||
_flags = flags;
|
|
||||||
if (_flags & SE_RANDOM_STATIC_COLOR) {
|
|
||||||
_color = random8();
|
|
||||||
_flags &= ~SE_CYCLE_COLORS & ~SE_RANDOM_PIXEL_COLORS;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
void loop(uint16_t ms) override;
|
|
||||||
String get_name() { return _name; };
|
|
||||||
boolean can_be_shown_with_clock() { return true; }
|
|
||||||
|
|
||||||
};
|
|
@ -19,12 +19,9 @@ public:
|
|||||||
virtual void loop(uint16_t ms);
|
virtual void loop(uint16_t ms);
|
||||||
String get_name() override { return "big_clock"; }
|
String get_name() override { return "big_clock"; }
|
||||||
};
|
};
|
||||||
<<<<<<< HEAD:include/effects/big_clock.h
|
|
||||||
=======
|
|
||||||
|
|
||||||
class NightClockEffect : public BigClockEffect {
|
class NightClockEffect : public BigClockEffect {
|
||||||
private:
|
private:
|
||||||
void _draw_border_pixel(accum88 pos, CRGB* color) { };
|
void _draw_border_pixel(accum88 pos, CRGB* color) { };
|
||||||
CRGB _get_color_font() { return CRGB(0x220000); }
|
CRGB _get_color_font() { return CRGB(0x220000); }
|
||||||
};
|
};
|
||||||
>>>>>>> ecf5998510bf1f8230d070cebccb4c89f95ce856:include/effect_big_clock.h
|
|
20
include/effect_confetti.h
Normal file
20
include/effect_confetti.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Effect.h"
|
||||||
|
#include "my_fastled.h"
|
||||||
|
|
||||||
|
class ConfettiEffect : public Effect {
|
||||||
|
protected:
|
||||||
|
virtual CRGB _getColor();
|
||||||
|
public:
|
||||||
|
void loop(uint16_t ms);
|
||||||
|
boolean can_be_shown_with_clock();
|
||||||
|
String get_name() override { return "confetti"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class RandomConfettiEffect : public ConfettiEffect {
|
||||||
|
protected:
|
||||||
|
CRGB _getColor() override;
|
||||||
|
String get_name() override { return "random_confetti"; }
|
||||||
|
};
|
||||||
|
|
@ -1,10 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Effect.h"
|
#include "Effect.h"
|
||||||
#include "effects/clock.h"
|
#include "effect_clock.h"
|
||||||
#include "effects/timer.h"
|
#include "effect_timer.h"
|
||||||
|
|
||||||
#define SIMPLE_EFFECT(name, use_in_cycle, flags, ...) {name, use_in_cycle, [](){ return new SimpleEffect(name, flags, [](double t, uint16_t i, uint8_t x, uint8_t y)->double __VA_ARGS__ ); }}
|
|
||||||
|
|
||||||
struct EffectEntry {
|
struct EffectEntry {
|
||||||
const char* name;
|
const char* name;
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Effect.h"
|
|
||||||
|
|
||||||
class NightClockEffect : public Effect {
|
|
||||||
public:
|
|
||||||
virtual void loop(uint16_t ms);
|
|
||||||
String get_name() override { return "night_clock"; }
|
|
||||||
};
|
|
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "my_fastled.h"
|
|
||||||
|
|
||||||
extern uint8_t baseHue;
|
extern uint8_t baseHue;
|
||||||
extern char hostname[30];
|
extern char hostname[30];
|
||||||
@ -32,5 +31,3 @@ typedef struct {
|
|||||||
uint16_t x;
|
uint16_t x;
|
||||||
uint16_t y;
|
uint16_t y;
|
||||||
} Coords;
|
} Coords;
|
||||||
|
|
||||||
typedef std::function<double(double, uint16_t, uint8_t, uint8_t)> simple_effect_t;
|
|
@ -1,35 +0,0 @@
|
|||||||
#include "SimpleEffect.h"
|
|
||||||
|
|
||||||
void SimpleEffect::loop(uint16_t ms) {
|
|
||||||
if (_flags & SE_FADEOUT) window->fadeToBlackBy(3);
|
|
||||||
double t = 0.001 * millis();
|
|
||||||
for(uint8_t x=0; x<window->width; x++) for(uint8_t y=0; y<window->height; y++) {
|
|
||||||
uint16_t i = y*window->width + x;
|
|
||||||
double r = _method(t, i, x, y);
|
|
||||||
//if (i==0) Serial.printf("t=%f i=%d x=%d y=%d => r=%f, abs(r)=%d\n", t, i, x, y, r, abs(r)*255);
|
|
||||||
if ((_flags & SE_DEBUG) && i==17) Serial.printf("t=%f i=%d x=%d y=%d => r=%f, abs(r*255)=%d\n", t, i, x, y, r, (int)abs(r*255));
|
|
||||||
if ((_flags & SE_FADEOUT) && r==0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clamp r between -1.0 and +1.0
|
|
||||||
if (r<-1.0) {
|
|
||||||
r = -1.0;
|
|
||||||
} else if (r>1.0) {
|
|
||||||
r = 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_flags & SE_ONLY_POSITIVE) {
|
|
||||||
r = abs(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
CRGB color;
|
|
||||||
if (_flags & SE_RANDOM_PIXEL_COLORS) {
|
|
||||||
color = CHSV(random8(), 255, abs(r*255));
|
|
||||||
} else {
|
|
||||||
color = CHSV(_flags & SE_CYCLE_COLORS ? baseHue : _color, r<0?0:255, abs(r*255));
|
|
||||||
}
|
|
||||||
|
|
||||||
window->setPixel(x, y, &color);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/analogclock.h"
|
#include "effect_analogclock.h"
|
||||||
#include "my_fastled.h"
|
#include "my_fastled.h"
|
||||||
#include "ntp.h"
|
#include "ntp.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/animation.h"
|
#include "effect_animation.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
|
||||||
AnimationEffect::AnimationEffect(const char* name, uint32_t bg, int x, int y) {
|
AnimationEffect::AnimationEffect(const char* name, uint32_t bg, int x, int y) {
|
@ -1,6 +1,6 @@
|
|||||||
#include "Effect.h"
|
#include "Effect.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "effects/bell.h"
|
#include "effect_bell.h"
|
||||||
#include "sprites.h"
|
#include "sprites.h"
|
||||||
|
|
||||||
void BellEffect::loop(uint16_t ms) {
|
void BellEffect::loop(uint16_t ms) {
|
@ -1,5 +1,5 @@
|
|||||||
#include "Effect.h"
|
#include "Effect.h"
|
||||||
#include "effects/big_clock.h"
|
#include "effect_big_clock.h"
|
||||||
#include "fonts.h"
|
#include "fonts.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "settings.h"
|
#include "settings.h"
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/blur2d.h"
|
#include "effect_blur2d.h"
|
||||||
Blur2DBlob::Blur2DBlob() {
|
Blur2DBlob::Blur2DBlob() {
|
||||||
_x_freq = random16(6<<8, 15<<8);
|
_x_freq = random16(6<<8, 15<<8);
|
||||||
_y_freq = random16(6<<8, 15<<8);
|
_y_freq = random16(6<<8, 15<<8);
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/clock.h"
|
#include "effect_clock.h"
|
||||||
#include <FastLED.h>
|
#include <FastLED.h>
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "fonts.h"
|
#include "fonts.h"
|
22
src/effect_confetti.cpp
Normal file
22
src/effect_confetti.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include "effect_confetti.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "functions.h"
|
||||||
|
#include "prototypes.h"
|
||||||
|
|
||||||
|
void ConfettiEffect::loop(uint16_t ms) {
|
||||||
|
window->fadeToBlackBy(3);
|
||||||
|
for (int i=0; i<settings.effects.confetti.pixels_per_loop; i++) {
|
||||||
|
CRGB color = _getColor();
|
||||||
|
window->addPixelColor(random16(LED_COUNT), &color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CRGB ConfettiEffect::_getColor() {
|
||||||
|
return CHSV(baseHue + random8(64), 255, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
CRGB RandomConfettiEffect::_getColor() {
|
||||||
|
return CHSV(random8(), 255, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean ConfettiEffect::can_be_shown_with_clock() { return true; };
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/cycle.h"
|
#include "effect_cycle.h"
|
||||||
#include "effects.h"
|
#include "effects.h"
|
||||||
|
|
||||||
CycleEffect::CycleEffect() {
|
CycleEffect::CycleEffect() {
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/diamond.h"
|
#include "effect_diamond.h"
|
||||||
#include "my_fastled.h"
|
#include "my_fastled.h"
|
||||||
|
|
||||||
void DiamondEffect::loop(uint16_t ms) {
|
void DiamondEffect::loop(uint16_t ms) {
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/dvd.h"
|
#include "effect_dvd.h"
|
||||||
#include "my_fastled.h"
|
#include "my_fastled.h"
|
||||||
|
|
||||||
void DvdEffect::loop(uint16_t ms) {
|
void DvdEffect::loop(uint16_t ms) {
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/dynamic.h"
|
#include "effect_dynamic.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/fire.h"
|
#include "effect_fire.h"
|
||||||
#include "my_color_palettes.h"
|
#include "my_color_palettes.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "my_fastled.h"
|
#include "my_fastled.h"
|
@ -1,5 +1,5 @@
|
|||||||
// Based on https://gist.github.com/kriegsman/68929cbd1d6de4535b20
|
// Based on https://gist.github.com/kriegsman/68929cbd1d6de4535b20
|
||||||
#include "effects/firework.h"
|
#include "effect_firework.h"
|
||||||
|
|
||||||
FireworkEffectDot::FireworkEffectDot(Window* w, FireworkEffect* e) {
|
FireworkEffectDot::FireworkEffectDot(Window* w, FireworkEffect* e) {
|
||||||
_window = w;
|
_window = w;
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/gol.h"
|
#include "effect_gol.h"
|
||||||
#include "my_fastled.h"
|
#include "my_fastled.h"
|
||||||
|
|
||||||
GolEffect::GolEffect() {
|
GolEffect::GolEffect() {
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/lightspeed.h"
|
#include "effect_lightspeed.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/marquee.h"
|
#include "effect_marquee.h"
|
||||||
#include "fonts.h"
|
#include "fonts.h"
|
||||||
|
|
||||||
boolean MarqueeEffect::can_be_shown_with_clock() {
|
boolean MarqueeEffect::can_be_shown_with_clock() {
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/matrix.h"
|
#include "effect_matrix.h"
|
||||||
#include "my_color_palettes.h"
|
#include "my_color_palettes.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/pixelclock.h"
|
#include "effect_pixelclock.h"
|
||||||
#include "ntp.h"
|
#include "ntp.h"
|
||||||
|
|
||||||
PixelClockEffect::PixelClockEffect() {
|
PixelClockEffect::PixelClockEffect() {
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/sinematrix3.h"
|
#include "effect_sinematrix3.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "Effect.h"
|
#include "Effect.h"
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/sines.h"
|
#include "effect_sines.h"
|
||||||
|
|
||||||
SinesEffectSinus::SinesEffectSinus(Window* w) {
|
SinesEffectSinus::SinesEffectSinus(Window* w) {
|
||||||
_window = w;
|
_window = w;
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/snake.h"
|
#include "effect_snake.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
|
||||||
SnakeEffect::SnakeEffect() {
|
SnakeEffect::SnakeEffect() {
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/static.h"
|
#include "effect_static.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "my_fastled.h"
|
#include "my_fastled.h"
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/timer.h"
|
#include "effect_timer.h"
|
||||||
#include <FastLED.h>
|
#include <FastLED.h>
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "fonts.h"
|
#include "fonts.h"
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/tpm2_net.h"
|
#include "effect_tpm2_net.h"
|
||||||
#include "my_fastled.h"
|
#include "my_fastled.h"
|
||||||
|
|
||||||
void Tpm2NetEffect::loop(uint16_t ms) {
|
void Tpm2NetEffect::loop(uint16_t ms) {
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/tv_static.h"
|
#include "effect_tv_static.h"
|
||||||
|
|
||||||
void TvStaticEffect::loop(uint16_t ms) {
|
void TvStaticEffect::loop(uint16_t ms) {
|
||||||
//uint8_t dark_position = (millis() % settings.effects.tv_static.black_bar_speed) * _window->width / settings.effects.tv_static.black_bar_speed;
|
//uint8_t dark_position = (millis() % settings.effects.tv_static.black_bar_speed) * _window->width / settings.effects.tv_static.black_bar_speed;
|
@ -1,4 +1,4 @@
|
|||||||
#include "effects/twirl.h"
|
#include "effect_twirl.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
|
||||||
boolean TwirlEffect::can_be_shown_with_clock() { return true; };
|
boolean TwirlEffect::can_be_shown_with_clock() { return true; };
|
@ -1,32 +1,31 @@
|
|||||||
#include "effects.h"
|
#include "effects.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "my_fastled.h"
|
#include "my_fastled.h"
|
||||||
#include "effects/bell.h"
|
#include "effect_bell.h"
|
||||||
#include "effects/sinematrix3.h"
|
#include "effect_sinematrix3.h"
|
||||||
#include "effects/big_clock.h"
|
#include "effect_big_clock.h"
|
||||||
#include "effects/clock.h"
|
#include "effect_clock.h"
|
||||||
#include "effects/static.h"
|
#include "effect_static.h"
|
||||||
#include "effects/animation.h"
|
#include "effect_animation.h"
|
||||||
#include "effects/dynamic.h"
|
#include "effect_dynamic.h"
|
||||||
#include "effects/matrix.h"
|
#include "effect_matrix.h"
|
||||||
#include "effects/twirl.h"
|
#include "effect_twirl.h"
|
||||||
#include "effects/cycle.h"
|
#include "effect_cycle.h"
|
||||||
#include "effects/snake.h"
|
#include "effect_confetti.h"
|
||||||
#include "effects/fire.h"
|
#include "effect_snake.h"
|
||||||
#include "effects/firework.h"
|
#include "effect_fire.h"
|
||||||
#include "effects/gol.h"
|
#include "effect_firework.h"
|
||||||
#include "effects/pixelclock.h"
|
#include "effect_gol.h"
|
||||||
#include "effects/dvd.h"
|
#include "effect_pixelclock.h"
|
||||||
#include "effects/analogclock.h"
|
#include "effect_dvd.h"
|
||||||
#include "effects/sines.h"
|
#include "effect_analogclock.h"
|
||||||
#include "effects/marquee.h"
|
#include "effect_sines.h"
|
||||||
#include "effects/blur2d.h"
|
#include "effect_marquee.h"
|
||||||
#include "effects/tv_static.h"
|
#include "effect_blur2d.h"
|
||||||
#include "effects/lightspeed.h"
|
#include "effect_tv_static.h"
|
||||||
#include "effects/diamond.h"
|
#include "effect_lightspeed.h"
|
||||||
#include "effects/tpm2_net.h"
|
#include "effect_diamond.h"
|
||||||
#include "SimpleEffect.h"
|
#include "effect_tpm2_net.h"
|
||||||
#include "effects/night_clock.h"
|
|
||||||
|
|
||||||
Effect* current_effect;
|
Effect* current_effect;
|
||||||
|
|
||||||
@ -48,8 +47,8 @@ EffectEntry effects[] = {
|
|||||||
/* 10 */ {"rainbow_matrix", true, [](){ return new RainbowMatrixEffect(); }},
|
/* 10 */ {"rainbow_matrix", true, [](){ return new RainbowMatrixEffect(); }},
|
||||||
/* 11 */ {"cycle", 0, [](){ return new CycleEffect(); }},
|
/* 11 */ {"cycle", 0, [](){ return new CycleEffect(); }},
|
||||||
/* 12 */ {"twirl", true, [](){ return new TwirlEffect(); }},
|
/* 12 */ {"twirl", true, [](){ return new TwirlEffect(); }},
|
||||||
/* 13 */ SIMPLE_EFFECT("confetti", true, SE_CYCLE_COLORS | SE_FADEOUT, {return random8()>252?1:0;}),
|
/* 13 */ {"confetti", true, [](){ return new ConfettiEffect(); }},
|
||||||
/* 14 */ SIMPLE_EFFECT("rainbow_confetti", true, SE_RANDOM_PIXEL_COLORS | SE_FADEOUT, {return random8()>252?1:0;}),
|
/* 14 */ {"random_confetti", true, [](){ return new RandomConfettiEffect(); }},
|
||||||
/* 15 */ {"snake", true, [](){ return new SnakeEffect(); }},
|
/* 15 */ {"snake", true, [](){ return new SnakeEffect(); }},
|
||||||
/* 16 */ {"firework", true, [](){ return new FireworkEffect(); }},
|
/* 16 */ {"firework", true, [](){ return new FireworkEffect(); }},
|
||||||
/* 17 */ {"gol", true, [](){ return new GolEffect(); }},
|
/* 17 */ {"gol", true, [](){ return new GolEffect(); }},
|
||||||
@ -69,14 +68,8 @@ EffectEntry effects[] = {
|
|||||||
/* 31 */ {"child", 0, [](){ return AnimationEffect::Blinker("/child.pia", 300, 0xFFFF00); }},
|
/* 31 */ {"child", 0, [](){ return AnimationEffect::Blinker("/child.pia", 300, 0xFFFF00); }},
|
||||||
/* 32 */ {"diamond", true, [](){ return new DiamondEffect(); }},
|
/* 32 */ {"diamond", true, [](){ return new DiamondEffect(); }},
|
||||||
/* 33 */ {"tpm2.net", 0, [](){ return new Tpm2NetEffect(); }},
|
/* 33 */ {"tpm2.net", 0, [](){ return new Tpm2NetEffect(); }},
|
||||||
/* 34 */ SIMPLE_EFFECT("slow_blinking", true, SE_CYCLE_COLORS, {return sin(t + (x+1)*(y+1)*i);} ),
|
|
||||||
/* 35 */ SIMPLE_EFFECT("upwave", true, SE_CYCLE_COLORS, {return (cos(t+y/2));} ),
|
|
||||||
/* 36 */ SIMPLE_EFFECT("centerwave", true, SE_CYCLE_COLORS, {return sin(t*2 - sqrt((x-4)*(x-4) + (y-7)*(y-7)));} ),
|
|
||||||
/* 37 */ SIMPLE_EFFECT("sineline", true, SE_RANDOM_STATIC_COLOR, {return sin(x/2)-sin(x-t)-y+6;} ),
|
|
||||||
/* 38 */ SIMPLE_EFFECT("barbershop", true, SE_RANDOM_STATIC_COLOR, {return 1*cos(0.8*i-t*5);} ),
|
|
||||||
/* 39 */ SIMPLE_EFFECT("zigzag", true, SE_CYCLE_COLORS, { return cos(cos(x+y)-y*cos(t/8+x/16));} ),
|
|
||||||
};
|
};
|
||||||
const uint8_t effects_size = 40;
|
const uint8_t effects_size = 34;
|
||||||
|
|
||||||
|
|
||||||
Effect* select_effect(const char* name) {
|
Effect* select_effect(const char* name) {
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
#include "Effect.h"
|
|
||||||
#include "effects/night_clock.h"
|
|
||||||
#include "fonts.h"
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
void NightClockEffect::loop(uint16_t ms) {
|
|
||||||
window->clear();
|
|
||||||
time_t now;
|
|
||||||
tm timeinfo;
|
|
||||||
time(&now);
|
|
||||||
localtime_r(&now, &timeinfo);
|
|
||||||
uint8_t h = timeinfo.tm_hour;
|
|
||||||
CRGB color = CRGB(0x440000);
|
|
||||||
window->drawChar(&font5x7, 4<<8, 0<<8, '0' + (h / 10), &color);
|
|
||||||
window->drawChar(&font5x7, 10<<8, 0<<8, '0' + (h % 10), &color);
|
|
||||||
|
|
||||||
uint8_t m = timeinfo.tm_min;
|
|
||||||
window->drawChar(&font5x7, 4<<8, 9<<8, '0' + (m / 10), &color);
|
|
||||||
window->drawChar(&font5x7, 10<<8, 9<<8, '0' + (m % 10), &color);
|
|
||||||
|
|
||||||
uint8_t s = timeinfo.tm_sec;
|
|
||||||
if(s & 1) {
|
|
||||||
window->setPixel(2, 11, &color);
|
|
||||||
window->setPixel(2, 13, &color);
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,6 +2,16 @@
|
|||||||
require 'websocket-eventmachine-client'
|
require 'websocket-eventmachine-client'
|
||||||
require 'pp'
|
require 'pp'
|
||||||
|
|
||||||
|
def rgb2ansi(r, g, b)
|
||||||
|
if r==g && g==b
|
||||||
|
return 16 if r<8
|
||||||
|
return 231 if r>248
|
||||||
|
return (((r - 8) / 247.0) * 24).round + 232
|
||||||
|
end
|
||||||
|
|
||||||
|
return 16 + 36*(r/51.0).round + 6*(g/51.0).round + (b/51.0).round
|
||||||
|
end
|
||||||
|
|
||||||
IP = ARGV[0]
|
IP = ARGV[0]
|
||||||
EFFECT = ARGV[1]
|
EFFECT = ARGV[1]
|
||||||
uri = "ws://#{IP}:80/ws"
|
uri = "ws://#{IP}:80/ws"
|
||||||
@ -31,7 +41,8 @@ EM.run do
|
|||||||
str += "|"
|
str += "|"
|
||||||
(0...width).each do |x|
|
(0...width).each do |x|
|
||||||
r, g, b = *data.shift(3)
|
r, g, b = *data.shift(3)
|
||||||
str += "\033[38;2;#{r};#{g};#{b}m●"
|
color_code = rgb2ansi(r, g, b)
|
||||||
|
str += "\033[48;5;#{color_code}m "
|
||||||
end
|
end
|
||||||
str += "\033[0m|\n"
|
str += "\033[0m|\n"
|
||||||
end
|
end
|
||||||
|
16
src/wifi.cpp
16
src/wifi.cpp
@ -6,21 +6,11 @@
|
|||||||
void wifi_setup() {
|
void wifi_setup() {
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.begin(WIFI_SSID, WIFI_PASS);
|
WiFi.begin(WIFI_SSID, WIFI_PASS);
|
||||||
uint8_t result;
|
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
|
||||||
uint8_t counter = 0;
|
Serial.println("WiFi * Connection Failed! Rebooting...");
|
||||||
while ((result = WiFi.waitForConnectResult()) != WL_CONNECTED) {
|
delay(5000);
|
||||||
counter++;
|
|
||||||
if (counter > 100) {
|
|
||||||
Serial.print("WiFi * Connection Failed! Last result was: ");
|
|
||||||
Serial.print(result);
|
|
||||||
Serial.println(" Rebooting...");
|
|
||||||
delay(100);
|
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
Serial.print("WiFi * Still waiting for WiFi to connect. This is loop number ");
|
|
||||||
Serial.println(counter);
|
|
||||||
delay(100);
|
|
||||||
}
|
|
||||||
Serial.println("WiFi * Ready");
|
Serial.println("WiFi * Ready");
|
||||||
Serial.print("WiFi * IP address: ");
|
Serial.print("WiFi * IP address: ");
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
|
Loading…
Reference in New Issue
Block a user