From 6b4f75b8bcad5a9c1222039445184e451ebefd10 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Thu, 10 Oct 2019 06:43:01 +0200 Subject: [PATCH 1/4] Fixed random_matrix effect. --- include/effect_matrix.h | 2 +- src/effect_matrix.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/effect_matrix.h b/include/effect_matrix.h index 9105525..8b75c30 100644 --- a/include/effect_matrix.h +++ b/include/effect_matrix.h @@ -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; diff --git a/src/effect_matrix.cpp b/src/effect_matrix.cpp index 33f8ff4..476f8f5 100644 --- a/src/effect_matrix.cpp +++ b/src/effect_matrix.cpp @@ -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; } } From d8fe055e3d0824a6481da26efd20ba4799635975 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Thu, 10 Oct 2019 06:44:35 +0200 Subject: [PATCH 2/4] Better default values for matrix* effects. --- include/settings.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/settings.h b/include/settings.h index bf1b3f0..e405d04 100644 --- a/include/settings.h +++ b/include/settings.h @@ -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 */ { From 5eba6914297db6b58ed4a8951da1cf79528767a8 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Thu, 10 Oct 2019 06:45:49 +0200 Subject: [PATCH 3/4] Extended the webinterface to list all available effects. --- src/http_server.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/http_server.cpp b/src/http_server.cpp index 6846230..3efdaec 100644 --- a/src/http_server.cpp +++ b/src/http_server.cpp @@ -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 = "Pitrix

Pitrix

Settings

Known animations:

"; + String message = "Pitrix

Pitrix

Settings

Effect

Known animations:

"; if (!SPIFFS.begin()) { message += "No SPIFFS file system found."; } else { @@ -76,13 +76,23 @@ void http_server_setup() { } String name = http_server.arg("key"); uint16_t value = http_server.arg("value").toInt(); - + if (change_setting(name.c_str(), value)) { http_server.send(200, "text/plain", "OK"); } else { http_server.send(400, "text/plain", "Could not change setting."); } }); + http_server.on("/effects", HTTP_GET, [&]() { + String message = "Pitrix effects

Pitrix settings

Back to main page"; + for (int i=0; i Date: Thu, 10 Oct 2019 06:47:17 +0200 Subject: [PATCH 4/4] Whitespace changes. --- include/settings.h | 18 +++++++++--------- src/effect_big_clock.cpp | 2 +- src/http_server.cpp | 6 +++--- src/settings.cpp | 24 ++++++++++++------------ 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/settings.h b/include/settings.h index e405d04..8b3c3d7 100644 --- a/include/settings.h +++ b/include/settings.h @@ -22,53 +22,53 @@ struct Settings { uint16_t time = 300; uint16_t random = 1; } cycle ; - + struct /* matrix */ { uint16_t length_min = 4; uint16_t length_max = 20; uint16_t speed_min = 3; uint16_t speed_max = 7; } matrix; - + struct /* confetti */ { uint16_t pixels_per_loop = 2; } confetti; - + struct /* dvd */ { uint16_t width = 3; uint16_t height = 2; uint16_t speed = 50; } dvd; - + struct /* dynamic */ { uint16_t single_loop_time = 40; uint16_t multi_loop_time = 1400; uint16_t big_loop_time = 50; uint16_t big_size = 3; } dynamic; - + struct /* fire */ { uint16_t cooldown = 192; uint16_t spark_chance = 5; } fire; - + struct /* firework */ { uint16_t drag = 255; uint16_t bounce = 200; uint16_t gravity = 10; uint16_t sparks = 12; } firework; - + struct /* gol */ { uint16_t start_percentage = 90; uint16_t blend_speed = 10; uint16_t restart_after_steps = 100; } gol; - + struct /* sines */ { uint16_t count = 5; } sines; - + struct /* snake */ { uint16_t direction_change = 5; uint16_t slowdown = 2; diff --git a/src/effect_big_clock.cpp b/src/effect_big_clock.cpp index 854cb36..bd42fc8 100644 --- a/src/effect_big_clock.cpp +++ b/src/effect_big_clock.cpp @@ -27,7 +27,7 @@ void BigClockEffect::_draw_seconds() { for (int i=1; i<=seconds; i++) { _draw_border_pixel(i, 0, (i%5==0) ? &_color_seconds_light : &_color_seconds_dark); } - + uint16_t millis = ntpClient.getEpochMillis() % 1000; /* // Enable this to have the next pixel move smoothly to its position diff --git a/src/http_server.cpp b/src/http_server.cpp index 3efdaec..29a0262 100644 --- a/src/http_server.cpp +++ b/src/http_server.cpp @@ -18,9 +18,9 @@ File upload_file; void http_server_handle_file_upload() { if (http_server.uri() != "/upload") return; - + HTTPUpload upload = http_server.upload(); - + if (upload.status == UPLOAD_FILE_START) { String filename = upload.filename; if (!filename.startsWith("/")) filename = "/" + filename; @@ -159,7 +159,7 @@ void http_server_setup() { } }); http_server.begin(); - + MDNS.addService("_http", "_tcp", 80); } diff --git a/src/settings.cpp b/src/settings.cpp index fd0ca02..d6a8f54 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -5,40 +5,40 @@ Settings settings; Setting all_settings[] = { {"fps", &settings.fps, TYPE_UINT8}, - + {"effects.confetti.pixels_per_loop", &settings.effects.confetti.pixels_per_loop, TYPE_UINT8}, - + {"effects.cycle.random", &settings.effects.cycle.random, TYPE_BOOL}, {"effects.cycle.time", &settings.effects.cycle.time, TYPE_UINT16}, - + {"effects.dvd.width", &settings.effects.dvd.width, TYPE_UINT8}, {"effects.dvd.height", &settings.effects.dvd.height, TYPE_UINT8}, {"effects.dvd.speed", &settings.effects.dvd.speed, TYPE_UINT8}, - + {"effects.dynamic.single_loop_time", &settings.effects.dynamic.single_loop_time, TYPE_UINT16}, {"effects.dynamic.multi_loop_time", &settings.effects.dynamic.multi_loop_time, TYPE_UINT16}, {"effects.dynamic.big_loop_time", &settings.effects.dynamic.big_loop_time, TYPE_UINT16}, {"effects.dynamic.big_size", &settings.effects.dynamic.big_size, TYPE_UINT8}, - + {"effects.fire.cooldown", &settings.effects.fire.cooldown, TYPE_UINT8}, {"effects.fire.spark_chance", &settings.effects.fire.spark_chance, TYPE_UINT8}, - + {"effects.firework.drag", &settings.effects.firework.drag, TYPE_UINT8}, {"effects.firework.bounce", &settings.effects.firework.bounce, TYPE_UINT8}, {"effects.firework.gravity", &settings.effects.firework.gravity, TYPE_UINT8}, {"effects.firework.sparks", &settings.effects.firework.sparks, TYPE_UINT8}, - + {"effects.gol.start_percentage", &settings.effects.gol.start_percentage, TYPE_UINT8}, {"effects.gol.blend_speed", &settings.effects.gol.blend_speed, TYPE_UINT8}, {"effects.gol.restart_after_steps", &settings.effects.gol.restart_after_steps, TYPE_UINT8}, - + {"effects.matrix.length_min", &settings.effects.matrix.length_min, TYPE_UINT8}, {"effects.matrix.length_max", &settings.effects.matrix.length_max, TYPE_UINT8}, {"effects.matrix.speed_min", &settings.effects.matrix.speed_min, TYPE_UINT8}, {"effects.matrix.speed_max", &settings.effects.matrix.speed_max, TYPE_UINT8}, - + {"effects.sines.count", &settings.effects.sines.count, TYPE_UINT8}, - + {"effects.snake.direction_change", &settings.effects.snake.direction_change, TYPE_UINT8} }; @@ -57,7 +57,7 @@ bool change_setting(const char* key, uint16_t new_value) { LOGln("Settings * No setting matching the name %s found.", key); return false; } - + // Check data size if (s->type == TYPE_BOOL && new_value > 1) { LOGln("Settings * Data type of %s is boolean, but new value is > 1.", key); @@ -67,7 +67,7 @@ bool change_setting(const char* key, uint16_t new_value) { LOGln("Settings * Data type of %s is uint8_t, but new value is > 0xFF.", key); return false; } - + *(s->value) = new_value; LOGln("Settings * Success. New value for %s is %d.", key, new_value); return true;