Compare commits

..

No commits in common. "b5c1f350d27e4b9924a89f493326e01dbe89430f" and "205a0df8425496e848ffb578a5f8286dace025f7" have entirely different histories.

6 changed files with 32 additions and 42 deletions

View File

@ -9,7 +9,7 @@
class MatrixEffectColumn {
protected:
Window* window;
saccum78 x, y;
accum88 x, y;
uint8_t length = 1;
uint8_t _direction = 2;
bool _random_direction = false;

View File

@ -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;
uint16_t speed_min = 1;
uint16_t speed_max = 10;
} 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;

View File

@ -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

View File

@ -47,7 +47,7 @@ void MatrixEffectColumn::advance(uint16_t ms) {
switch(_direction) {
case DIR_NORTH:
y-=speed * ms;
if ((y>>8) + length < 0) running=false;
if ((y>>8) > window->height && (y>>8) + length > window->height) 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) + length < 0) running=false;
if ((x>>8) > window->width && (y>>8) + length > window->width) running=false;
break;
}
}

View File

@ -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;
@ -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><p><a href='/settings'>Settings</a></p><p><a href='/effects'>Effect</a></p><p>Known animations:</p>";
String message = "<html><head><title>Pitrix</title></head><body><h1>Pitrix</h1><a href='/settings'>Settings</a><p>Known animations:</p>";
if (!SPIFFS.begin()) {
message += "<strong>No SPIFFS file system found.</strong>";
} else {
@ -76,23 +76,13 @@ 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 = "<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) {
@ -159,7 +149,7 @@ void http_server_setup() {
}
});
http_server.begin();
MDNS.addService("_http", "_tcp", 80);
}

View File

@ -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;