From 281a9041e7c6e94a46ca02a70c57cb0ff79bc8c8 Mon Sep 17 00:00:00 2001 From: Fisch Date: Thu, 1 Feb 2018 19:03:13 +0100 Subject: [PATCH 1/3] add pinout notes --- pinbelegung.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 pinbelegung.txt diff --git a/pinbelegung.txt b/pinbelegung.txt new file mode 100644 index 0000000..77e5a98 --- /dev/null +++ b/pinbelegung.txt @@ -0,0 +1,17 @@ +Serial - ESP + +GND - GND +5V - 5V +TX - D1 +RX - D2 + +MC14050 - +1 - LM7805(Out) +2 - Widerstand - LED Data +3 - D7 +8 - GND + +ESP - +5V - LM7805(Out) +GND - LM7805(GND) +In - LED(12V) From 699f1e12e7e944957872b69661783bdd667023ff Mon Sep 17 00:00:00 2001 From: Fisch Date: Thu, 1 Feb 2018 22:18:58 +0100 Subject: [PATCH 2/3] add config.json preset --- config.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 config.json diff --git a/config.json b/config.json new file mode 100644 index 0000000..757b4a5 --- /dev/null +++ b/config.json @@ -0,0 +1,16 @@ +{ +"name": "esp-videoswitcher", +"device_id": "esp-videoswitcher", +"wifi": { +"ssid": "", +"password": "" +}, +"mqtt": { +"host": "raum.ctdo.de", +"port": 1883, +"auth": false +}, +"ota": { +"enabled": false +} +} \ No newline at end of file From 7ee666afa789f03c89b511c4b6be5b06cc42d5b8 Mon Sep 17 00:00:00 2001 From: Fisch Date: Thu, 1 Feb 2018 22:19:32 +0100 Subject: [PATCH 3/3] add working equalizer --- NeoPatterns.cpp | 39 +++++++++++++++++++++++++++++ NeoPatterns.h | 26 ++++++++++++++++++- esp-videoswitcher.ino | 58 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+), 1 deletion(-) diff --git a/NeoPatterns.cpp b/NeoPatterns.cpp index 6a6ded8..bb39dc3 100644 --- a/NeoPatterns.cpp +++ b/NeoPatterns.cpp @@ -690,6 +690,7 @@ void NeoPatterns::setupboxs() { boxs[0].right = 39; } + void NeoPatterns::colorCircleSegment(uint8_t wheelid, uint32_t c){ //color a wheel segment for (int i=0;i<6;i++) { setPixelColor(boxcircle[wheelid][i], c); @@ -847,4 +848,42 @@ uint32_t NeoPatterns::parseColor(String value) { +void NeoPatterns::Equalizer(uint8_t eqvalues[]){ //display equalizer (not used as "effect") + //eqvalues[] of size 8, each contains a value from 0 to 8 (inclusive) + setEqBar(0,eqvalues[0]); + setEqBar(1,eqvalues[1]); + setEqBar(2,eqvalues[2]); + setEqBar(3,eqvalues[3]); + setEqBar(4,eqvalues[4]); + setEqBar(5,eqvalues[5]); + setEqBar(6,eqvalues[6]); + setEqBar(7,eqvalues[7]); + setEqBar(8,eqvalues[7]); + + setEqBar(17,eqvalues[0]); + setEqBar(16,eqvalues[1]); + setEqBar(15,eqvalues[2]); + setEqBar(14,eqvalues[3]); + setEqBar(13,eqvalues[4]); + setEqBar(12,eqvalues[5]); + setEqBar(11,eqvalues[6]); + setEqBar(10,eqvalues[7]); + setEqBar(9,eqvalues[7]); + + + show(); +} +//helper function +void NeoPatterns::setEqBar(uint8_t barid,uint8_t pvalue){ //barid is the bar from ledEq array (vertical),pvalue is the amplitude + for (uint8_t i=0;i<8;i++){ + uint8_t ledId=ledEq[barid][i]; + uint32_t backgroundColor=Color(0,0,0); + if (i #include #include #include #include "NeoPatterns.h" +#include #define PIN D7 // #define BIGPIXELS 20 @@ -29,6 +34,10 @@ String output2 = ""; unsigned long lastMillis = 0; +WiFiUDP Udp; +unsigned int localUdpPort = 4210; // local port to listen on +char incomingPacket[255]; // buffer for incoming packets + /* * 25 Boxen insgesamt @@ -313,6 +322,7 @@ void setup() { Homie.setup(); + strip.begin(); strip.clear(); strip.show(); @@ -337,6 +347,14 @@ void setup() { }); ArduinoOTA.begin(); + + while(WiFi.localIP().toString()=="0.0.0.0"){ + Serial.println(WiFi.localIP()); + delay(10); + } + Udp.begin(localUdpPort); + Serial.printf("Now listening on UDP port %d \n", localUdpPort); + Serial.println(WiFi.localIP()); } void loop() { @@ -392,4 +410,44 @@ void loop() { currentnumber = 0; } } + + //UDP + int packetSize = Udp.parsePacket(); + if (packetSize) + { + // receive incoming UDP packets + //Serial.printf("Received %d bytes from %s, port %d\n", packetSize, Udp.remoteIP().toString().c_str(), Udp.remotePort()); + int len = Udp.read(incomingPacket, 255); + if (len > 0) + { + incomingPacket[len] = 0; + } + //uint16_t data=incomingPacket[0]<<8 | incomingPacket[1]; + + //Serial.printf("UDP packet contents: %s\n", incomingPacket); + + uint8_t bar[8]; + + + bar[0]=incomingPacket[0]%16; + bar[1]=incomingPacket[0]/16; + bar[2]=incomingPacket[1]%16; + bar[3]=incomingPacket[1]/16; + bar[4]=incomingPacket[2]%16; + bar[5]=incomingPacket[2]/16; + bar[6]=incomingPacket[3]%16; + bar[7]=incomingPacket[3]/16; + + strip.Equalizer(bar); + + strip.Stop(); //Stop effect + + //bar_ contains a number from 0 to 7 (inclusive) + + + //printBinary(mapData(data)); + //shiftRelais(mapData(data)); + + } } +