From 12d8c14cc14649e50bef5fb98adfbe810d0a4eeb Mon Sep 17 00:00:00 2001 From: starcalc Date: Fri, 7 Jul 2017 00:20:36 +0200 Subject: [PATCH] =?UTF-8?q?UDP-Pakete=20akzeptieren=20f=C3=BCr=20komplette?= =?UTF-8?q?=20Bilder=20und=20f=C3=BCr=20VU-Meter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- esp-pixelbox.ino | 42 ++++++------------------------------------ 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/esp-pixelbox.ino b/esp-pixelbox.ino index 0502579..97cf476 100644 --- a/esp-pixelbox.ino +++ b/esp-pixelbox.ino @@ -55,38 +55,6 @@ bool onSetPixel(const HomieRange& range, const String& value) { homieNode.setProperty("pixel_" + String(range.index)).send(value); } -bool onSetVU(const HomieRange& range, const String& value) { - strip.Stop(); // Do not show any "effects" anymore - strip.clear(); // All pixels to black - String remaining = value; - String current; - int i = 0; - do - { - if (remaining.length() == 1) - { - current = remaining.substring(0,1); - } else { - current = remaining.substring(0,2); - } - int currentvalue = (int) strtol(¤t[0], NULL, 10); - // White peak - strip.setPixelColor(strip.numToPos(56+i-currentvalue*8), 16777215); // White dot - // Shaded bar "below" the peak - if (currentvalue>0) - { - for (int j=currentvalue-1;j>-1;j--) - { - strip.setPixelColor(strip.numToPos(56+i-j*8), 4276545); // Greyscale - } - } - i++; - remaining = remaining.substring(2); - } while (remaining.length()>0); // TODO: Not bigger than strip - strip.show(); - homieNode.setProperty("VU_" + String(range.index)).send(value); -} - bool onSetBrightness(const HomieRange& range, const String& value) { long brightness = value.toInt(); if (brightness < 0 || brightness > 255) { @@ -219,7 +187,7 @@ void loopHandler() { void setup() { Serial.begin(115200); - Homie_setFirmware("pixelbox", "1.0.0"); + Homie_setFirmware("pixelprojektor", "1.0.0"); Homie.setLoopFunction(loopHandler); homieNode.advertiseRange("pixel", 0, NUMPIXELS - 1).settable(onSetPixel); @@ -230,19 +198,19 @@ void setup() { homieNode.advertise("length").settable(onSetLength); homieNode.advertise("icon").settable(onSetIcon); homieNode.advertiseRange("pixels", 0, (NUMPIXELS - 1)*7).settable(onSetPixels); - homieNode.advertiseRange("vu", 0, sqrt(NUMPIXELS)-1).settable(onSetVU); Homie.setup(); strip.begin(); strip.clear(); // strip.setBrightness(64); - strip.setBrightness(255); // HEEELLLLLLL :) + // strip.setBrightness(255); // HEEELLLLLLL :) + strip.setBrightness(10); // DEBUG! strip.show(); stopAfterCompletion = false; // Default // strip.Plasma(); // Default effect - ArduinoOTA.setHostname("pixelbox"); + ArduinoOTA.setHostname("pixelprojektor"); ArduinoOTA.onStart([]() { strip.clear(); strip.setBrightness(64); @@ -261,3 +229,5 @@ void loop() { Homie.loop(); ArduinoOTA.handle(); } + +