Merge branch 'master' of https://git.schle.nz/fabian/pitrix; added new effect tv_static.
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Some checks reported errors
continuous-integration/drone/push Build encountered an error
This commit is contained in:
commit
359b7a7826
@ -9,7 +9,7 @@
|
||||
class MatrixEffectColumn {
|
||||
protected:
|
||||
Window* window;
|
||||
accum88 x, y;
|
||||
saccum78 x, y;
|
||||
uint8_t length = 1;
|
||||
uint8_t _direction = 2;
|
||||
bool _random_direction = false;
|
||||
|
12
include/effect_tv_static.h
Normal file
12
include/effect_tv_static.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "Effect.h"
|
||||
|
||||
class TvStaticEffect : public Effect {
|
||||
private:
|
||||
Window* _window = new Window(0, 0, LED_WIDTH, LED_HEIGHT-6);
|
||||
public:
|
||||
~TvStaticEffect();
|
||||
void loop(uint16_t ms) override;
|
||||
bool can_be_shown_with_clock() override;
|
||||
String get_name() override { return "tv_static"; }
|
||||
};
|
@ -26,8 +26,8 @@ struct Settings {
|
||||
struct /* matrix */ {
|
||||
uint16_t length_min = 4;
|
||||
uint16_t length_max = 20;
|
||||
uint16_t speed_min = 1;
|
||||
uint16_t speed_max = 10;
|
||||
uint16_t speed_min = 3;
|
||||
uint16_t speed_max = 7;
|
||||
} matrix;
|
||||
|
||||
struct /* confetti */ {
|
||||
@ -73,6 +73,10 @@ struct Settings {
|
||||
uint16_t direction_change = 5;
|
||||
uint16_t slowdown = 2;
|
||||
} snake;
|
||||
|
||||
struct /* tv_static */ {
|
||||
uint16_t black_bar_speed = 3500;
|
||||
} tv_static;
|
||||
} effects;
|
||||
};
|
||||
|
||||
|
@ -21,7 +21,7 @@ lib_deps =
|
||||
ESPAsyncTCP
|
||||
|
||||
[env:ota]
|
||||
upload_port = 10.10.2.78
|
||||
upload_port = 10.10.2.80
|
||||
upload_protocol = espota
|
||||
platform = espressif8266
|
||||
board = esp07
|
||||
|
@ -29,15 +29,8 @@ void BigClockEffect::_draw_seconds() {
|
||||
}
|
||||
|
||||
uint16_t millis = ntpClient.getEpochMillis() % 1000;
|
||||
/*
|
||||
// Enable this to have the next pixel move smoothly to its position
|
||||
if (millis > 0) {
|
||||
uint8_t part = 60 - ((60 - seconds) * millis / 1000);
|
||||
_draw_border_pixel(part, &_color_seconds);
|
||||
}
|
||||
*/
|
||||
uint8_t offset = 5 - ((millis % 1000) / 200);
|
||||
uint8_t part = scale8(millis % 200, 200);
|
||||
uint8_t offset = 5 - (millis / 200);
|
||||
uint8_t part = 255 - ((millis % 200) * 256 / 200);
|
||||
uint8_t number_to_show = (60 - seconds - offset) / 5 + 1;
|
||||
for(uint8_t i = 0; i<number_to_show; i++) {
|
||||
uint8_t pos = seconds + offset + i*5;
|
||||
@ -46,26 +39,6 @@ void BigClockEffect::_draw_seconds() {
|
||||
}
|
||||
|
||||
void BigClockEffect::_draw_border_pixel(uint8_t i, uint8_t part, CRGB* color) {
|
||||
/*uint8_t x, y;
|
||||
if (i<=8) {
|
||||
x = 7 + i;
|
||||
y = 0;
|
||||
} else if (i<=23) {
|
||||
x = 15;
|
||||
y = i - 8;
|
||||
} else if (i<= 38) {
|
||||
x = 15 - i + 23;
|
||||
y = 15;
|
||||
} else if (i <= 53) {
|
||||
x = 0;
|
||||
y = 15 - i + 38;
|
||||
} else if (i <= 60) {
|
||||
x = i - 53;
|
||||
y = 0;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
window->setPixel(x, y, color);*/
|
||||
accum88 x, y;
|
||||
if (i<=8) {
|
||||
x = ((7+i)<<8) + part;
|
||||
|
@ -47,7 +47,7 @@ void MatrixEffectColumn::advance(uint16_t ms) {
|
||||
switch(_direction) {
|
||||
case DIR_NORTH:
|
||||
y-=speed * ms;
|
||||
if ((y>>8) > window->height && (y>>8) + length > window->height) running=false;
|
||||
if ((y>>8) + length < 0) running=false;
|
||||
break;
|
||||
case DIR_EAST:
|
||||
x+=speed * ms;
|
||||
@ -59,7 +59,7 @@ void MatrixEffectColumn::advance(uint16_t ms) {
|
||||
break;
|
||||
case DIR_WEST:
|
||||
x-=speed * ms;
|
||||
if ((x>>8) > window->width && (y>>8) + length > window->width) running=false;
|
||||
if ((x>>8) + length < 0) running=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
27
src/effect_tv_static.cpp
Normal file
27
src/effect_tv_static.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "effect_tv_static.h"
|
||||
|
||||
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;
|
||||
for (uint8_t y=0; y<_window->height; y++) {
|
||||
uint8_t row_dark_position = (dark_position + y/3) % _window->width;
|
||||
for (uint8_t x=0; x<_window->width; x++) {
|
||||
uint8_t brightness = random8();
|
||||
uint8_t darkening = 0;
|
||||
uint8_t distance = x - row_dark_position;
|
||||
if (distance == 0) darkening = random8(192, 255);
|
||||
else if (distance == 1) darkening = random8(128, 255);
|
||||
else if (distance == 2) darkening = random8(92, 192);
|
||||
else if (distance == 3) darkening = random8(32, 128);
|
||||
if (darkening > brightness) brightness = 0;
|
||||
else brightness -= darkening;
|
||||
CRGB color(brightness, brightness, brightness);
|
||||
_window->setPixel(x, y, &color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TvStaticEffect::can_be_shown_with_clock() { return true; }
|
||||
|
||||
TvStaticEffect::~TvStaticEffect() {
|
||||
delete _window;
|
||||
}
|
@ -22,6 +22,7 @@
|
||||
#include "effect_sines.h"
|
||||
#include "effect_marquee.h"
|
||||
#include "effect_blur2d.h"
|
||||
#include "effect_tv_static.h"
|
||||
|
||||
Effect* current_effect;
|
||||
|
||||
@ -52,9 +53,10 @@ const EffectEntry effects[] = {
|
||||
/* 21 */ {"sines", true, [](){ return new SinesEffect(); }},
|
||||
/* 22 */ {"blur2d", true, [](){ return new Blur2DEffect(); }},
|
||||
/* 23 */ {"marquee", 0, [](){ return new MarqueeEffect(); }},
|
||||
/* 24 */ {"night_clock", false, [](){ return new NightClockEffect(); }}
|
||||
/* 24 */ {"night_clock", false, [](){ return new NightClockEffect(); }},
|
||||
/* 25 */ {"tv_static", false, [](){ return new TvStaticEffect(); }},
|
||||
};
|
||||
const uint8_t effects_size = 25;
|
||||
const uint8_t effects_size = 26;
|
||||
|
||||
|
||||
Effect* select_effect(const char* name) {
|
||||
|
@ -42,7 +42,7 @@ void http_server_setup() {
|
||||
PGM_P text_plain = PSTR("text/plain");
|
||||
http_server.on("/", HTTP_GET, [&](){
|
||||
LOGln("HTTP * GET /");
|
||||
String message = "<html><head><title>Pitrix</title></head><body><h1>Pitrix</h1><a href='/settings'>Settings</a><p>Known animations:</p>";
|
||||
String message = "<html><head><title>Pitrix</title></head><body><h1>Pitrix</h1><p><a href='/settings'>Settings</a></p><p><a href='/effects'>Effect</a></p><p>Known animations:</p>";
|
||||
if (!SPIFFS.begin()) {
|
||||
message += "<strong>No SPIFFS file system found.</strong>";
|
||||
} else {
|
||||
@ -150,6 +150,16 @@ void http_server_setup() {
|
||||
}
|
||||
http_server.send(500, "text/plain", "Could not read settings.");
|
||||
});
|
||||
http_server.on("/effects", HTTP_GET, [&]() {
|
||||
String message = "<html><head><title>Pitrix effects</title></head><body><h1>Pitrix settings</h1><a href='/'>Back to main page</a><table>";
|
||||
for (int i=0; i<effects_size; i++) {
|
||||
message += "<tr><td>";
|
||||
message += effects[i].name;
|
||||
message += "</td></tr>";
|
||||
}
|
||||
message += "</table></body></html>";
|
||||
http_server.send(200, "text/html", message);
|
||||
});
|
||||
http_server.on("/delete", HTTP_GET, [&]() {
|
||||
LOGln("HTTP * GET /delete");
|
||||
if (http_server.args()==0) {
|
||||
|
@ -40,10 +40,12 @@ Setting all_settings[] = {
|
||||
|
||||
{"effects.sines.count", &settings.effects.sines.count, TYPE_UINT8},
|
||||
|
||||
{"effects.snake.direction_change", &settings.effects.snake.direction_change, TYPE_UINT8}
|
||||
{"effects.snake.direction_change", &settings.effects.snake.direction_change, TYPE_UINT8},
|
||||
|
||||
{"effects.tv_static.black_bar_speed", &settings.effects.tv_static.black_bar_speed, TYPE_UINT16},
|
||||
};
|
||||
|
||||
const uint8_t all_settings_size = 25;
|
||||
const uint8_t all_settings_size = 26;
|
||||
|
||||
bool change_setting(const char* key, uint16_t new_value) {
|
||||
LOGln("Settings * Setting %s to new value %d.", key, new_value);
|
||||
|
Loading…
Reference in New Issue
Block a user