Compare commits

...

6 Commits

9 changed files with 65 additions and 11 deletions

View File

@ -10,7 +10,7 @@ protected:
Window* window = new Window(0, LED_HEIGHT - 6, LED_WIDTH, 6);
public:
~ClockEffect();
virtual ~ClockEffect();
virtual void loop(uint16_t ms);
String get_name() override { return "clock"; }
void loop_with_invert(bool invert);
@ -20,5 +20,6 @@ public:
class NightClockEffect : public ClockEffect {
public:
NightClockEffect();
~NightClockEffect();
void loop(uint16_t ms) override;
};

View File

@ -48,6 +48,15 @@ public:
RandomMatrixEffectColumn(Window* win, uint8_t dir, bool rnd=false) : MatrixEffectColumn(win, dir, rnd) {};
};
class ColumnMatrixEffectColumn : public MatrixEffectColumn {
protected:
uint8_t _hue;
CRGB _getColor(uint8_t height) override;
void restart(bool completely_random) override;
public:
ColumnMatrixEffectColumn(Window* win, uint8_t dir, bool rnd=false) : MatrixEffectColumn(win, dir, rnd) {};
};
class MatrixEffectBase : public Effect {
protected:
MatrixEffectColumn** _columns;
@ -86,3 +95,11 @@ public:
RandomMatrixEffect();
String get_name() override { return "random_matrix"; }
};
class ColumnMatrixEffect : public MatrixEffectBase {
protected:
void _create() override;
public:
ColumnMatrixEffect();
String get_name() override { return "column_matrix"; }
};

View File

@ -2,6 +2,7 @@
#include "prototypes.h"
extern Font font_numbers3x5;
extern Font font_numbers3x3;
extern Font font_numbers3x5_blocky;
extern Font font_numbers4x7;
extern Font font5x7;

View File

@ -19,7 +19,7 @@ lib_deps =
https://github.com/me-no-dev/ESPAsyncWebServer.git
[env:ota]
upload_port = 10.10.2.80
upload_port = 10.10.2.78 ; .78=prod, .80=dev
upload_protocol = espota
platform = espressif8266
board = esp07

View File

@ -66,3 +66,7 @@ void ClockEffect::loop(boolean invert, CRGB fg_color, CRGB bg_color, uint8_t yPo
ClockEffect::~ClockEffect() {
delete window;
}
NightClockEffect::~NightClockEffect() {
delete window;
}

View File

@ -47,7 +47,7 @@ void LightspeedEffectStar::_init() {
_start = 0;
_speed = random16(128, 2<<8);
_target = random16(25<<8, 35<<8);
_saturation = random8(20);
_saturation = random8(100);
}
void LightspeedEffectStar::loop(Window* win) {

View File

@ -127,6 +127,18 @@ void RandomMatrixEffectColumn::restart(bool completely_random) {
_hue = random8();
}
CRGB ColumnMatrixEffectColumn::_getColor(uint8_t i) {
CRGB color;
uint8_t dist = abs(length / 2 - i);
color = CHSV(_hue, 255, 255 - dist * 5);
return color;
}
void ColumnMatrixEffectColumn::restart(bool completely_random) {
MatrixEffectColumn::restart(completely_random);
_hue = random8();
}
@ -174,6 +186,15 @@ void RainbowMatrixEffect::_create() {
for (int i=0; i<_count; i++) _columns[i] = new RainbowMatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
}
ColumnMatrixEffect::ColumnMatrixEffect() {
_init();
_create();
}
void ColumnMatrixEffect::_create() {
for (int i=0; i<_count; i++) _columns[i] = new ColumnMatrixEffectColumn(window, MatrixEffectColumn::DIR_NORTH);
}
MatrixEffectBase::~MatrixEffectBase() {
_delete();
}

View File

@ -16,6 +16,22 @@ bool font_numbers3x5_check(const char c) { return c>='0' && c<='9'; }
uint16_t font_numbers3x5_get(const char c) { return c - '0'; }
Font font_numbers3x5 = {3, 5, &font_numbers3x5_data[0], font_numbers3x5_check, font_numbers3x5_get};
const uint8_t font_numbers3x3_data[] PROGMEM = {
B111, B101, B111, // 0
B101, B111, B001, // 1
B100, B111, B001, // 2
B101, B111, B111, // 3
B110, B010, B111, // 4
B001, B111, B100, // 5
B111, B011, B011, // 6
B100, B100, B111, // 7
B011, B111, B111, // 8
B110, B110, B111, // 9
};
bool font_numbers3x3_check(const char c) { return c>='0' && c<='9'; }
uint16_t font_numbers3x3_get(const char c) { return c - '0'; }
Font font_numbers3x3 = {3, 3, &font_numbers3x3_data[0], font_numbers3x3_check, font_numbers3x3_get};
const uint8_t font_numbers3x5_blocky_data[] PROGMEM = {
B11111, B10001, B11111, // 0
B00000, B11111, B00000, // 1
@ -150,12 +166,6 @@ const uint8_t font5x7_data[] PROGMEM = {
0x08, 0x08, 0x2A, 0x1C, 0x08, // ->
0x08, 0x1C, 0x2A, 0x08, 0x08, // <-
};
bool font5x7_check(const char c) { return c>=' ' && c<='}'; }
uint16_t font5x7_get(const char c) { return c - ' '; }
Font font5x7 = {5, 7, &font5x7_data[0], font5x7_check, font5x7_get};

View File

@ -201,9 +201,9 @@ void http_server_setup() {
});
http_server.on("/effects", HTTP_GET, [&](AsyncWebServerRequest* request) {
String message = F("<html><head><title>Pitrix effects</title></head><body><h1>Pitrix settings</h1><a href='/'>Back to main page</a><table>");
char buffer[150];
char buffer[500];
for (int i=0; i<effects_size; i++) {
snprintf_P(buffer, 150, PSTR("<tr><td>%s</td><td><form method='post' action='/effects'><input type='hidden' name='name' value='%s'><input type='hidden' name='redir' value='1'><input type='submit' value='Select'></form></td></tr>"), effects[i].name, effects[i].name);
snprintf_P(buffer, 500, PSTR("<tr><td>%s</td><td><form method='post' action='/effects'><input type='hidden' name='name' value='%s'><input type='hidden' name='redir' value='1'><input type='submit' value='Select'></form></td></tr>"), effects[i].name, effects[i].name);
message += buffer;
}
message += F("</table></body></html>");