Lots of changes:

* More animations with generalized code to display them.
  * The hostname will now include a unique id of the ESP.
  * Effect can now be restricted to a smaller "window".
  * Clock is now BigClock, SmallClock is now Clock.
  * Clock shows the time as well as the sinematrix effect. Closes #8.
  * If the loop takes too long too often, the ESP will automatically be rebooted. Closes #12.
  * The text drawing methods are now much more generalized. #5.
This commit is contained in:
2019-05-23 21:18:15 +02:00
parent deb3a753c8
commit 0e82f94846
8 changed files with 350 additions and 91 deletions

14
mqtt.h
View File

@ -3,11 +3,11 @@ long mqtt_last_reconnect_attempt = 0;
void mqtt_callback(char* topic, byte* payload, unsigned int length) {
payload[length] = '\0';
for (int i=0; i<NUM_EFFECTS; i++) {
EffectEntry e = effects[i];
if (strcmp(e.name, (char*)payload)==0) {
current_effect = e.effect;
EffectEntry* e = &effects[i];
if (strcmp(e->name, (char*)payload)==0) {
//Serial.printf("Effect found in mqtt_callback: %p\n", (void *)&e->effect);
current_effect = e->effect;
clear();
return;
}
@ -15,7 +15,11 @@ void mqtt_callback(char* topic, byte* payload, unsigned int length) {
}
boolean mqtt_connect() {
if (mqtt_client.connect("pitrix", MQTT_USER, MQTT_PASS)) {
char client_id[30];
snprintf(client_id, 30, HOSTNAME, ESP.getChipId());
LOG("MQTT * Connecting to MQTT server with client id "); LOGln(client_id);
if (mqtt_client.connect(client_id, MQTT_USER, MQTT_PASS)) {
LOGln("MQTT * Connected.");
mqtt_client.subscribe(MQTT_TOPIC_MODE);
mqtt_client.publish(MQTT_TOPIC_STATUS, "ONLINE");
}