Compare commits

...
8 Commits
61 changed files with 185 additions and 112 deletions

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
#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; }
};
-20
View File
@@ -1,20 +0,0 @@
#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"; }
};
+4 -2
View File
@@ -1,8 +1,10 @@
#pragma once #pragma once
#include "Effect.h" #include "Effect.h"
#include "effect_clock.h" #include "effects/clock.h"
#include "effect_timer.h" #include "effects/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;
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -19,9 +19,12 @@ 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+8
View File
@@ -0,0 +1,8 @@
#pragma once
#include "Effect.h"
class NightClockEffect : public Effect {
public:
virtual void loop(uint16_t ms);
String get_name() override { return "night_clock"; }
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+3
View File
@@ -1,6 +1,7 @@
#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];
@@ -31,3 +32,5 @@ 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;
+35
View File
@@ -0,0 +1,35 @@
#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);
}
}
-22
View File
@@ -1,22 +0,0 @@
#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; };
+35 -28
View File
@@ -1,31 +1,32 @@
#include "effects.h" #include "effects.h"
#include "config.h" #include "config.h"
#include "my_fastled.h" #include "my_fastled.h"
#include "effect_bell.h" #include "effects/bell.h"
#include "effect_sinematrix3.h" #include "effects/sinematrix3.h"
#include "effect_big_clock.h" #include "effects/big_clock.h"
#include "effect_clock.h" #include "effects/clock.h"
#include "effect_static.h" #include "effects/static.h"
#include "effect_animation.h" #include "effects/animation.h"
#include "effect_dynamic.h" #include "effects/dynamic.h"
#include "effect_matrix.h" #include "effects/matrix.h"
#include "effect_twirl.h" #include "effects/twirl.h"
#include "effect_cycle.h" #include "effects/cycle.h"
#include "effect_confetti.h" #include "effects/snake.h"
#include "effect_snake.h" #include "effects/fire.h"
#include "effect_fire.h" #include "effects/firework.h"
#include "effect_firework.h" #include "effects/gol.h"
#include "effect_gol.h" #include "effects/pixelclock.h"
#include "effect_pixelclock.h" #include "effects/dvd.h"
#include "effect_dvd.h" #include "effects/analogclock.h"
#include "effect_analogclock.h" #include "effects/sines.h"
#include "effect_sines.h" #include "effects/marquee.h"
#include "effect_marquee.h" #include "effects/blur2d.h"
#include "effect_blur2d.h" #include "effects/tv_static.h"
#include "effect_tv_static.h" #include "effects/lightspeed.h"
#include "effect_lightspeed.h" #include "effects/diamond.h"
#include "effect_diamond.h" #include "effects/tpm2_net.h"
#include "effect_tpm2_net.h" #include "SimpleEffect.h"
#include "effects/night_clock.h"
Effect* current_effect; Effect* current_effect;
@@ -47,8 +48,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 */ {"confetti", true, [](){ return new ConfettiEffect(); }}, /* 13 */ SIMPLE_EFFECT("confetti", true, SE_CYCLE_COLORS | SE_FADEOUT, {return random8()>252?1:0;}),
/* 14 */ {"random_confetti", true, [](){ return new RandomConfettiEffect(); }}, /* 14 */ SIMPLE_EFFECT("rainbow_confetti", true, SE_RANDOM_PIXEL_COLORS | SE_FADEOUT, {return random8()>252?1:0;}),
/* 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(); }},
@@ -68,8 +69,14 @@ 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 = 34; const uint8_t effects_size = 40;
Effect* select_effect(const char* name) { Effect* select_effect(const char* name) {
@@ -1,4 +1,4 @@
#include "effect_analogclock.h" #include "effects/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 "effect_animation.h" #include "effects/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 -1
View File
@@ -1,6 +1,6 @@
#include "Effect.h" #include "Effect.h"
#include "functions.h" #include "functions.h"
#include "effect_bell.h" #include "effects/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 "effect_big_clock.h" #include "effects/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 "effect_blur2d.h" #include "effects/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 "effect_clock.h" #include "effects/clock.h"
#include <FastLED.h> #include <FastLED.h>
#include "functions.h" #include "functions.h"
#include "fonts.h" #include "fonts.h"
@@ -1,4 +1,4 @@
#include "effect_cycle.h" #include "effects/cycle.h"
#include "effects.h" #include "effects.h"
CycleEffect::CycleEffect() { CycleEffect::CycleEffect() {
@@ -1,4 +1,4 @@
#include "effect_diamond.h" #include "effects/diamond.h"
#include "my_fastled.h" #include "my_fastled.h"
void DiamondEffect::loop(uint16_t ms) { void DiamondEffect::loop(uint16_t ms) {
+1 -1
View File
@@ -1,4 +1,4 @@
#include "effect_dvd.h" #include "effects/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 "effect_dynamic.h" #include "effects/dynamic.h"
#include "functions.h" #include "functions.h"
#include "config.h" #include "config.h"
+1 -1
View File
@@ -1,4 +1,4 @@
#include "effect_fire.h" #include "effects/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 "effect_firework.h" #include "effects/firework.h"
FireworkEffectDot::FireworkEffectDot(Window* w, FireworkEffect* e) { FireworkEffectDot::FireworkEffectDot(Window* w, FireworkEffect* e) {
_window = w; _window = w;
+1 -1
View File
@@ -1,4 +1,4 @@
#include "effect_gol.h" #include "effects/gol.h"
#include "my_fastled.h" #include "my_fastled.h"
GolEffect::GolEffect() { GolEffect::GolEffect() {
@@ -1,4 +1,4 @@
#include "effect_lightspeed.h" #include "effects/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 "effect_marquee.h" #include "effects/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 "effect_matrix.h" #include "effects/matrix.h"
#include "my_color_palettes.h" #include "my_color_palettes.h"
#include "functions.h" #include "functions.h"
+26
View File
@@ -0,0 +1,26 @@
#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);
}
}
@@ -1,4 +1,4 @@
#include "effect_pixelclock.h" #include "effects/pixelclock.h"
#include "ntp.h" #include "ntp.h"
PixelClockEffect::PixelClockEffect() { PixelClockEffect::PixelClockEffect() {
@@ -1,4 +1,4 @@
#include "effect_sinematrix3.h" #include "effects/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 "effect_sines.h" #include "effects/sines.h"
SinesEffectSinus::SinesEffectSinus(Window* w) { SinesEffectSinus::SinesEffectSinus(Window* w) {
_window = w; _window = w;
@@ -1,4 +1,4 @@
#include "effect_snake.h" #include "effects/snake.h"
#include "functions.h" #include "functions.h"
SnakeEffect::SnakeEffect() { SnakeEffect::SnakeEffect() {
@@ -1,4 +1,4 @@
#include "effect_static.h" #include "effects/static.h"
#include "functions.h" #include "functions.h"
#include "my_fastled.h" #include "my_fastled.h"
@@ -1,4 +1,4 @@
#include "effect_timer.h" #include "effects/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 "effect_tpm2_net.h" #include "effects/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 "effect_tv_static.h" #include "effects/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 "effect_twirl.h" #include "effects/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 -12
View File
@@ -2,16 +2,6 @@
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"
@@ -41,8 +31,7 @@ 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)
color_code = rgb2ansi(r, g, b) str += "\033[38;2;#{r};#{g};#{b}m●"
str += "\033[48;5;#{color_code}m "
end end
str += "\033[0m|\n" str += "\033[0m|\n"
end end
+13 -3
View File
@@ -6,11 +6,21 @@
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);
while (WiFi.waitForConnectResult() != WL_CONNECTED) { uint8_t result;
Serial.println("WiFi * Connection Failed! Rebooting..."); uint8_t counter = 0;
delay(5000); while ((result = WiFi.waitForConnectResult()) != WL_CONNECTED) {
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());