diff --git a/platformio.ini b/platformio.ini index e6fbced..6454f13 100644 --- a/platformio.ini +++ b/platformio.ini @@ -18,4 +18,4 @@ monitor_port = /dev/cu.wchusbserial* monitor_speed = 74880 monitor_filters = default, time, send_on_enter, esp8266_exception_decoder lib_deps = fastled/FastLED @ 3.4.0 - PubSubClient \ No newline at end of file + PubSubClient @ 2.8 \ No newline at end of file diff --git a/src/corner.cpp b/src/corner.cpp index fd27148..eddfaa2 100644 --- a/src/corner.cpp +++ b/src/corner.cpp @@ -44,13 +44,13 @@ bool Corner::reached_level(uint16_t level) { } void Corner::blend_to(CRGB target, uint16_t eid, uint8_t effect_speed) { - LOGln("blendTo called. Corner: %p, target: %d,%d,%d, eid: %d, 'old' effect_id: %d, speed: %d", this, target.r, target.g, target.b, eid, effect_id, effect_speed); + //LOGln("blendTo called. Corner: %p, target: %d,%d,%d, eid: %d, 'old' effect_id: %d, speed: %d", this, target.r, target.g, target.b, eid, effect_id, effect_speed); if (eid==0) { this->effect_id = random16(); - LOGln("Set effect_id to %d", this->effect_id); + //LOGln("Set effect_id to %d", this->effect_id); } else { if (this->effect_id == eid) { - LOGln("'Old' effect. Doing nothing."); + //LOGln("'Old' effect. Doing nothing."); return; } this->effect_id = eid; diff --git a/src/main.cpp b/src/main.cpp index dc8e5ce..9a0be10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -77,7 +77,7 @@ void setup_fastled() { FastLED.addLeds(leds, LEDS_PER_CORNER * CORNERS_PER_PART * NODE_COUNT).setCorrection(TypicalLEDStrip); LOGln("LEDs: %3d", LED_COUNT); FastLED.setBrightness(255); - FastLED.setDither(DISABLE_DITHER); + //FastLED.setDither(DISABLE_DITHER); FastLED.setMaxPowerInVoltsAndMilliamps(5, MAX_MILLIAMPS); set_all_leds(CRGB::Black); } @@ -195,14 +195,19 @@ void loop() { } } else if (active_mode == AM_OFF) { + LOGln("Blanking."); for(Node* node : nodes) { node->set_color(CRGB::Black); + node->draw(); } } else { // This includes AM_ERROR for(Node* node : nodes) { node->set_color(CRGB::Black); } nodes[0]->set_color(CRGB::Red); + for(Node* node : nodes) { + node->draw(); + } } last_loop = millis(); diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 0260612..18d4f4c 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -24,16 +24,24 @@ void callback(char* topic, byte* pl, unsigned int length) { uint16_t duration = 0; AnimationMode new_mode = AM_NONE; String current_part; + LOGln("Received command %s", payload.c_str()); while (payload.length() > 0) { int offset = payload.indexOf("&"); if (offset != -1) { current_part = payload.substring(0, offset); payload = payload.substring(offset + 1); + } else { + current_part = payload; + payload = ""; } offset = current_part.indexOf("="); - if (offset==-1) continue; + if (offset==-1) { + LOGln("Parameter without '=' detected: %s", current_part.c_str()); + continue; + } String key = current_part.substring(0, offset); String value = current_part.substring(offset+1); + LOGln(" Processing key %s with value %s", key.c_str(), value.c_str()); if (key.equals("mode")) { if (value.equals("nodes")) { new_mode = AM_NODES; } @@ -59,6 +67,7 @@ void callback(char* topic, byte* pl, unsigned int length) { LOGln("Unknown key '%s'. (For reference: Value is '%s'.)", key.c_str(), value.c_str()); } } + LOGln("Finished processing the command."); if (new_mode != AM_NONE) { if (duration > 0) { diff --git a/src/node.cpp b/src/node.cpp index 8f2c463..e7c99ed 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -57,7 +57,7 @@ Node* Node::create_neighbour(uint8_t edge) { } void Node::blend_to(CRGB color, uint16_t effect_id, uint8_t effect_speed) { - LOGln("Node::blend_to called. this:%p", this); + //LOGln("Node::blend_to called. this:%p", this); if (effect_speed == 0) effect_speed = random8(2)+1; if (effect_id == 0) effect_id = random16(); for(Corner* corner : this->_corners) {