This commit is contained in:
starcalc 2018-02-11 18:48:02 +01:00
commit bba6d4cf8a
5 changed files with 158 additions and 1 deletions

View File

@ -718,6 +718,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);
@ -875,4 +876,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<pvalue){
setPixelColor(ledId,Wheel((i*32+100)%256));
}else{
setPixelColor(ledId,backgroundColor);
}
}
}

View File

@ -36,8 +36,13 @@ class NeoPatterns : public Adafruit_NeoPixel
void PlasmaUpdate();
void Radar(float radarspeed = 0.5,float radarthickness = 1, uint8_t interval = 50);
void RadarUpdate();
<<<<<<< HEAD
void ShowInput();
void ShowInputUpdate();
=======
void Equalizer(uint8_t eqvalues[]);
void setEqBar(uint8_t barid,uint8_t pvalue);
>>>>>>> cff73c87e375c2766ab0a7beebffd403d37b21d8
void SetColor1(uint32_t color);
void SetColor2(uint32_t color);
@ -73,7 +78,7 @@ class NeoPatterns : public Adafruit_NeoPixel
{58,59,60,60,60,60},
{61,62,63,63,63,63},
{64,65,66,66,66,66},
{67,68,69,69,69,69},
{67,68,69,69,69,69}
};
/*uint8_t boxcircle[32][4]={
{0,0,0,0}, //0
@ -109,6 +114,28 @@ class NeoPatterns : public Adafruit_NeoPixel
{67,68,68,68},
{69,69,69,69} //31
};*/
uint8_t ledEq[18][8]={
{23,20,17,14,11,8,8,8},
{22,19,16,13,10,7,7,7},
{21,18,15,12,9,6,6,6},
{26,29,255,255,255,5,5,5},
{25,28,255,255,255,4,4,4},
{24,27,255,255,255,3,3,3},
{34,33,32,31,30,2,2,2},
{255,255,255,255,255,1,1,1},
{255,255,255,255,255,0,0,0},
{255,255,255,255,255,69,69,69},
{255,255,255,255,255,68,68,68},
{39,38,37,36,35,67,67,67},
{45,42,255,255,255,66,66,66},
{44,41,255,255,255,65,65,65},
{43,40,255,255,255,64,64,64},
{48,51,54,57,60,63,63,63},
{47,50,53,56,59,62,62,62},
{46,49,52,55,58,61,61,61}
};
void setupboxs();
void colorBox(uint8_t boxid, uint32_t c);

16
config.json Normal file
View File

@ -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
}
}

View File

@ -1,8 +1,13 @@
//Wemos D1 R2 mini
//4M (1M SPIFFS)
//80 MHz
//115200
#include <Homie.h>
#include <ArduinoOTA.h>
#include <Arduino.h>
#include <SoftwareSerial.h>
#include "NeoPatterns.h"
#include <WiFiUdp.h>
#define PIN D7
// #define BIGPIXELS 20
@ -31,6 +36,10 @@ uint8_t currentoutput;
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
@ -317,6 +326,7 @@ void setup() {
Homie.setup();
strip.begin();
strip.clear();
strip.show();
@ -341,6 +351,14 @@ void setup() {
});
strip.setCurrentInput(255);
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() {
@ -405,4 +423,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));
}
}

17
pinbelegung.txt Normal file
View File

@ -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)