Compare commits
	
		
			4 Commits
		
	
	
		
			205a0df842
			...
			b5c1f350d2
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| b5c1f350d2 | |||
| 5eba691429 | |||
| d8fe055e3d | |||
| 6b4f75b8bc | 
@@ -9,7 +9,7 @@
 | 
				
			|||||||
class MatrixEffectColumn {
 | 
					class MatrixEffectColumn {
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
    Window* window;
 | 
					    Window* window;
 | 
				
			||||||
    accum88 x, y;
 | 
					    saccum78 x, y;
 | 
				
			||||||
    uint8_t length = 1;
 | 
					    uint8_t length = 1;
 | 
				
			||||||
    uint8_t _direction = 2;
 | 
					    uint8_t _direction = 2;
 | 
				
			||||||
    bool _random_direction = false;
 | 
					    bool _random_direction = false;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,53 +22,53 @@ struct Settings {
 | 
				
			|||||||
			uint16_t time = 300;
 | 
								uint16_t time = 300;
 | 
				
			||||||
			uint16_t random = 1;
 | 
								uint16_t random = 1;
 | 
				
			||||||
		} cycle ;
 | 
							} cycle ;
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		struct /* matrix */ {
 | 
							struct /* matrix */ {
 | 
				
			||||||
			uint16_t length_min = 4;
 | 
								uint16_t length_min = 4;
 | 
				
			||||||
			uint16_t length_max = 20;
 | 
								uint16_t length_max = 20;
 | 
				
			||||||
			uint16_t speed_min = 1;
 | 
								uint16_t speed_min = 3;
 | 
				
			||||||
			uint16_t speed_max = 10;
 | 
								uint16_t speed_max = 7;
 | 
				
			||||||
		} matrix;
 | 
							} matrix;
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		struct /* confetti */ {
 | 
							struct /* confetti */ {
 | 
				
			||||||
			uint16_t pixels_per_loop = 2;
 | 
								uint16_t pixels_per_loop = 2;
 | 
				
			||||||
		} confetti;
 | 
							} confetti;
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		struct /* dvd */ {
 | 
							struct /* dvd */ {
 | 
				
			||||||
			uint16_t width = 3;
 | 
								uint16_t width = 3;
 | 
				
			||||||
			uint16_t height = 2;
 | 
								uint16_t height = 2;
 | 
				
			||||||
			uint16_t speed = 50;
 | 
								uint16_t speed = 50;
 | 
				
			||||||
		} dvd;
 | 
							} dvd;
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		struct /* dynamic */ {
 | 
							struct /* dynamic */ {
 | 
				
			||||||
			uint16_t single_loop_time = 40;
 | 
								uint16_t single_loop_time = 40;
 | 
				
			||||||
			uint16_t multi_loop_time = 1400;
 | 
								uint16_t multi_loop_time = 1400;
 | 
				
			||||||
			uint16_t big_loop_time = 50;
 | 
								uint16_t big_loop_time = 50;
 | 
				
			||||||
			uint16_t big_size = 3;
 | 
								uint16_t big_size = 3;
 | 
				
			||||||
		} dynamic;
 | 
							} dynamic;
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		struct /* fire */ {
 | 
							struct /* fire */ {
 | 
				
			||||||
			uint16_t cooldown = 192;
 | 
								uint16_t cooldown = 192;
 | 
				
			||||||
			uint16_t spark_chance = 5;
 | 
								uint16_t spark_chance = 5;
 | 
				
			||||||
		} fire;
 | 
							} fire;
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		struct /* firework */ {
 | 
							struct /* firework */ {
 | 
				
			||||||
			uint16_t drag = 255;
 | 
								uint16_t drag = 255;
 | 
				
			||||||
			uint16_t bounce = 200;
 | 
								uint16_t bounce = 200;
 | 
				
			||||||
			uint16_t gravity = 10;
 | 
								uint16_t gravity = 10;
 | 
				
			||||||
			uint16_t sparks = 12;
 | 
								uint16_t sparks = 12;
 | 
				
			||||||
		} firework;
 | 
							} firework;
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		struct /* gol */ {
 | 
							struct /* gol */ {
 | 
				
			||||||
			uint16_t start_percentage = 90;
 | 
								uint16_t start_percentage = 90;
 | 
				
			||||||
			uint16_t blend_speed = 10;
 | 
								uint16_t blend_speed = 10;
 | 
				
			||||||
			uint16_t restart_after_steps = 100;
 | 
								uint16_t restart_after_steps = 100;
 | 
				
			||||||
		} gol;
 | 
							} gol;
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		struct /* sines */ {
 | 
							struct /* sines */ {
 | 
				
			||||||
			uint16_t count = 5;
 | 
								uint16_t count = 5;
 | 
				
			||||||
		} sines;
 | 
							} sines;
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		struct /* snake */ {
 | 
							struct /* snake */ {
 | 
				
			||||||
			uint16_t direction_change = 5;
 | 
								uint16_t direction_change = 5;
 | 
				
			||||||
			uint16_t slowdown = 2;
 | 
								uint16_t slowdown = 2;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,7 +27,7 @@ void BigClockEffect::_draw_seconds() {
 | 
				
			|||||||
	for (int i=1; i<=seconds; i++) {
 | 
						for (int i=1; i<=seconds; i++) {
 | 
				
			||||||
		_draw_border_pixel(i, 0, (i%5==0) ? &_color_seconds_light : &_color_seconds_dark);
 | 
							_draw_border_pixel(i, 0, (i%5==0) ? &_color_seconds_light : &_color_seconds_dark);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	uint16_t millis = ntpClient.getEpochMillis() % 1000;
 | 
						uint16_t millis = ntpClient.getEpochMillis() % 1000;
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	// Enable this to have the next pixel move smoothly to its position
 | 
						// Enable this to have the next pixel move smoothly to its position
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,7 +47,7 @@ void MatrixEffectColumn::advance(uint16_t ms) {
 | 
				
			|||||||
	switch(_direction) {
 | 
						switch(_direction) {
 | 
				
			||||||
		case DIR_NORTH:
 | 
							case DIR_NORTH:
 | 
				
			||||||
			y-=speed * ms;
 | 
								y-=speed * ms;
 | 
				
			||||||
			if ((y>>8) > window->height && (y>>8) + length > window->height) running=false;
 | 
								if ((y>>8) + length < 0) running=false;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case DIR_EAST:
 | 
							case DIR_EAST:
 | 
				
			||||||
			x+=speed * ms;
 | 
								x+=speed * ms;
 | 
				
			||||||
@@ -59,7 +59,7 @@ void MatrixEffectColumn::advance(uint16_t ms) {
 | 
				
			|||||||
			break;
 | 
								break;
 | 
				
			||||||
		case DIR_WEST:
 | 
							case DIR_WEST:
 | 
				
			||||||
			x-=speed * ms;
 | 
								x-=speed * ms;
 | 
				
			||||||
			if ((x>>8) > window->width && (y>>8) + length > window->width) running=false;
 | 
								if ((x>>8) + length < 0) running=false;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,9 +18,9 @@ File upload_file;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void http_server_handle_file_upload() {
 | 
					void http_server_handle_file_upload() {
 | 
				
			||||||
	if (http_server.uri() != "/upload") return;
 | 
						if (http_server.uri() != "/upload") return;
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	HTTPUpload upload = http_server.upload();
 | 
						HTTPUpload upload = http_server.upload();
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	if (upload.status == UPLOAD_FILE_START) {
 | 
						if (upload.status == UPLOAD_FILE_START) {
 | 
				
			||||||
		String filename = upload.filename;
 | 
							String filename = upload.filename;
 | 
				
			||||||
		if (!filename.startsWith("/")) filename = "/" + filename;
 | 
							if (!filename.startsWith("/")) filename = "/" + filename;
 | 
				
			||||||
@@ -42,7 +42,7 @@ void http_server_setup() {
 | 
				
			|||||||
	PGM_P text_plain = PSTR("text/plain");
 | 
						PGM_P text_plain = PSTR("text/plain");
 | 
				
			||||||
	http_server.on("/", HTTP_GET, [&](){
 | 
						http_server.on("/", HTTP_GET, [&](){
 | 
				
			||||||
		LOGln("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()) {
 | 
							if (!SPIFFS.begin()) {
 | 
				
			||||||
			message += "<strong>No SPIFFS file system found.</strong>";
 | 
								message += "<strong>No SPIFFS file system found.</strong>";
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
@@ -76,13 +76,23 @@ void http_server_setup() {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		String name = http_server.arg("key");
 | 
							String name = http_server.arg("key");
 | 
				
			||||||
		uint16_t value = http_server.arg("value").toInt();
 | 
							uint16_t value = http_server.arg("value").toInt();
 | 
				
			||||||
		
 | 
					
 | 
				
			||||||
		if (change_setting(name.c_str(), value)) {
 | 
							if (change_setting(name.c_str(), value)) {
 | 
				
			||||||
			http_server.send(200, "text/plain", "OK");
 | 
								http_server.send(200, "text/plain", "OK");
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			http_server.send(400, "text/plain", "Could not change setting.");
 | 
								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, [&]() {
 | 
						http_server.on("/delete", HTTP_GET, [&]() {
 | 
				
			||||||
		LOGln("HTTP * GET /delete");
 | 
							LOGln("HTTP * GET /delete");
 | 
				
			||||||
		if (http_server.args()==0) {
 | 
							if (http_server.args()==0) {
 | 
				
			||||||
@@ -149,7 +159,7 @@ void http_server_setup() {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
	http_server.begin();
 | 
						http_server.begin();
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	MDNS.addService("_http", "_tcp", 80);
 | 
						MDNS.addService("_http", "_tcp", 80);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,40 +5,40 @@ Settings settings;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Setting all_settings[] = {
 | 
					Setting all_settings[] = {
 | 
				
			||||||
	{"fps", &settings.fps, TYPE_UINT8},
 | 
						{"fps", &settings.fps, TYPE_UINT8},
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	{"effects.confetti.pixels_per_loop", &settings.effects.confetti.pixels_per_loop, 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.random", &settings.effects.cycle.random, TYPE_BOOL},
 | 
				
			||||||
	{"effects.cycle.time", &settings.effects.cycle.time, TYPE_UINT16},
 | 
						{"effects.cycle.time", &settings.effects.cycle.time, TYPE_UINT16},
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	{"effects.dvd.width", &settings.effects.dvd.width, TYPE_UINT8},
 | 
						{"effects.dvd.width", &settings.effects.dvd.width, TYPE_UINT8},
 | 
				
			||||||
	{"effects.dvd.height", &settings.effects.dvd.height, TYPE_UINT8},
 | 
						{"effects.dvd.height", &settings.effects.dvd.height, TYPE_UINT8},
 | 
				
			||||||
	{"effects.dvd.speed", &settings.effects.dvd.speed, 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.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.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_loop_time", &settings.effects.dynamic.big_loop_time, TYPE_UINT16},
 | 
				
			||||||
	{"effects.dynamic.big_size", &settings.effects.dynamic.big_size, TYPE_UINT8},
 | 
						{"effects.dynamic.big_size", &settings.effects.dynamic.big_size, TYPE_UINT8},
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	{"effects.fire.cooldown", &settings.effects.fire.cooldown, TYPE_UINT8},
 | 
						{"effects.fire.cooldown", &settings.effects.fire.cooldown, TYPE_UINT8},
 | 
				
			||||||
	{"effects.fire.spark_chance", &settings.effects.fire.spark_chance, TYPE_UINT8},
 | 
						{"effects.fire.spark_chance", &settings.effects.fire.spark_chance, TYPE_UINT8},
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	{"effects.firework.drag", &settings.effects.firework.drag, TYPE_UINT8},
 | 
						{"effects.firework.drag", &settings.effects.firework.drag, TYPE_UINT8},
 | 
				
			||||||
	{"effects.firework.bounce", &settings.effects.firework.bounce, TYPE_UINT8},
 | 
						{"effects.firework.bounce", &settings.effects.firework.bounce, TYPE_UINT8},
 | 
				
			||||||
	{"effects.firework.gravity", &settings.effects.firework.gravity, TYPE_UINT8},
 | 
						{"effects.firework.gravity", &settings.effects.firework.gravity, TYPE_UINT8},
 | 
				
			||||||
	{"effects.firework.sparks", &settings.effects.firework.sparks, TYPE_UINT8},
 | 
						{"effects.firework.sparks", &settings.effects.firework.sparks, TYPE_UINT8},
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	{"effects.gol.start_percentage", &settings.effects.gol.start_percentage, 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.blend_speed", &settings.effects.gol.blend_speed, TYPE_UINT8},
 | 
				
			||||||
	{"effects.gol.restart_after_steps", &settings.effects.gol.restart_after_steps, 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_min", &settings.effects.matrix.length_min, TYPE_UINT8},
 | 
				
			||||||
	{"effects.matrix.length_max", &settings.effects.matrix.length_max, 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_min", &settings.effects.matrix.speed_min, TYPE_UINT8},
 | 
				
			||||||
	{"effects.matrix.speed_max", &settings.effects.matrix.speed_max, TYPE_UINT8},
 | 
						{"effects.matrix.speed_max", &settings.effects.matrix.speed_max, TYPE_UINT8},
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	{"effects.sines.count", &settings.effects.sines.count, TYPE_UINT8},
 | 
						{"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}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -57,7 +57,7 @@ bool change_setting(const char* key, uint16_t new_value) {
 | 
				
			|||||||
		LOGln("Settings * No setting matching the name %s found.", key);
 | 
							LOGln("Settings * No setting matching the name %s found.", key);
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	// Check data size
 | 
						// Check data size
 | 
				
			||||||
	if (s->type == TYPE_BOOL && new_value > 1) {
 | 
						if (s->type == TYPE_BOOL && new_value > 1) {
 | 
				
			||||||
		LOGln("Settings * Data type of %s is boolean, but new value is > 1.", key);
 | 
							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);
 | 
							LOGln("Settings * Data type of %s is uint8_t, but new value is > 0xFF.", key);
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	*(s->value) = new_value;
 | 
						*(s->value) = new_value;
 | 
				
			||||||
	LOGln("Settings * Success. New value for %s is %d.", key, new_value);
 | 
						LOGln("Settings * Success. New value for %s is %d.", key, new_value);
 | 
				
			||||||
	return true;
 | 
						return true;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user