INPUT-Box als Effekt
This commit is contained in:
parent
206e043bd8
commit
f80f8a9617
|
@ -55,6 +55,9 @@ void NeoPatterns::Update() {
|
||||||
break;
|
break;
|
||||||
case RANDOM:
|
case RANDOM:
|
||||||
break;
|
break;
|
||||||
|
case SHOWINPUT:
|
||||||
|
ShowInputUpdate();
|
||||||
|
break;
|
||||||
case NONE:
|
case NONE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -545,6 +548,31 @@ void NeoPatterns::RadarUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**** Input ****/
|
||||||
|
|
||||||
|
void NeoPatterns::ShowInput() {
|
||||||
|
if (ActivePattern != SHOWINPUT) {
|
||||||
|
clear();
|
||||||
|
colorBox(currentinput, Color(255, 255, 255));
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
ActivePattern = SHOWINPUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NeoPatterns::ShowInputUpdate() {
|
||||||
|
clear();
|
||||||
|
colorBox(currentinput, Color(255, 255, 255));
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// setCurrentInput
|
||||||
|
void NeoPatterns::setCurrentInput(uint8_t input) {
|
||||||
|
currentinput = input;
|
||||||
|
}
|
||||||
|
|
||||||
|
/********/
|
||||||
|
|
||||||
/****************** Helper functions ******************/
|
/****************** Helper functions ******************/
|
||||||
|
|
||||||
void NeoPatterns::SetColor1(uint32_t color) {
|
void NeoPatterns::SetColor1(uint32_t color) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <Adafruit_NeoPixel.h>
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
|
||||||
// Pattern types supported:
|
// Pattern types supported:
|
||||||
enum pattern { NONE, RAINBOW_CYCLE, THEATER_CHASE, COLOR_WIPE, SCANNER, FADE, RANDOM_FADE, SMOOTH, ICON, RANDOM_FADE_SINGLE, PLASMA, RADAR, FILL, RANDOM };
|
enum pattern { NONE, RAINBOW_CYCLE, THEATER_CHASE, COLOR_WIPE, SCANNER, FADE, RANDOM_FADE, SMOOTH, ICON, RANDOM_FADE_SINGLE, PLASMA, RADAR, FILL, RANDOM, SHOWINPUT };
|
||||||
// Patern directions supported:
|
// Patern directions supported:
|
||||||
enum direction { FORWARD, REVERSE };
|
enum direction { FORWARD, REVERSE };
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ class NeoPatterns : public Adafruit_NeoPixel
|
||||||
void PlasmaUpdate();
|
void PlasmaUpdate();
|
||||||
void Radar(float radarspeed = 0.5,float radarthickness = 1, uint8_t interval = 50);
|
void Radar(float radarspeed = 0.5,float radarthickness = 1, uint8_t interval = 50);
|
||||||
void RadarUpdate();
|
void RadarUpdate();
|
||||||
|
void ShowInput();
|
||||||
|
void ShowInputUpdate();
|
||||||
|
|
||||||
void SetColor1(uint32_t color);
|
void SetColor1(uint32_t color);
|
||||||
void SetColor2(uint32_t color);
|
void SetColor2(uint32_t color);
|
||||||
|
@ -121,6 +123,7 @@ class NeoPatterns : public Adafruit_NeoPixel
|
||||||
uint8_t numToPos(int num);
|
uint8_t numToPos(int num);
|
||||||
uint8_t getAverage(uint8_t array[], uint8_t i, int x, int y);
|
uint8_t getAverage(uint8_t array[], uint8_t i, int x, int y);
|
||||||
uint32_t parseColor(String value);
|
uint32_t parseColor(String value);
|
||||||
|
void setCurrentInput(uint8_t input);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Member Variables:
|
// Member Variables:
|
||||||
|
@ -172,6 +175,7 @@ class NeoPatterns : public Adafruit_NeoPixel
|
||||||
uint8_t Radardotbrightness;
|
uint8_t Radardotbrightness;
|
||||||
uint8_t Radardotfadespeed;
|
uint8_t Radardotfadespeed;
|
||||||
|
|
||||||
|
uint8_t currentinput;
|
||||||
|
|
||||||
uint32_t DimColor(uint32_t color);
|
uint32_t DimColor(uint32_t color);
|
||||||
void Increment();
|
void Increment();
|
||||||
|
|
|
@ -18,7 +18,7 @@ HomieNode homieNode("pixel", "commands");
|
||||||
#define TIMEOUT 500
|
#define TIMEOUT 500
|
||||||
|
|
||||||
#define FW_NAME "esp-videoswitcher"
|
#define FW_NAME "esp-videoswitcher"
|
||||||
#define FW_VERSION "1.0.3"
|
#define FW_VERSION "1.0.4"
|
||||||
|
|
||||||
SoftwareSerial swSer(D2, D1);
|
SoftwareSerial swSer(D2, D1);
|
||||||
int currentnumber = 0;
|
int currentnumber = 0;
|
||||||
|
@ -26,6 +26,8 @@ int inputbytes[4];
|
||||||
int commandbytes[4];
|
int commandbytes[4];
|
||||||
String output = "";
|
String output = "";
|
||||||
String output2 = "";
|
String output2 = "";
|
||||||
|
uint8_t currentinput = 255; // Override
|
||||||
|
uint8_t currentoutput;
|
||||||
|
|
||||||
unsigned long lastMillis = 0;
|
unsigned long lastMillis = 0;
|
||||||
|
|
||||||
|
@ -197,6 +199,9 @@ bool onSetEffect(const HomieRange& range, const String& value) {
|
||||||
else if (effect == "radar") {
|
else if (effect == "radar") {
|
||||||
strip.Radar();
|
strip.Radar();
|
||||||
}
|
}
|
||||||
|
else if (effect == "input") {
|
||||||
|
strip.ShowInput();
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// Test whether command with parameters was sent
|
// Test whether command with parameters was sent
|
||||||
int sep = value.indexOf("|");
|
int sep = value.indexOf("|");
|
||||||
|
@ -267,11 +272,11 @@ bool switchHandler(const HomieRange& range, const String& value) {
|
||||||
swSer.write(commandbytes[2]);
|
swSer.write(commandbytes[2]);
|
||||||
swSer.write(commandbytes[3]);
|
swSer.write(commandbytes[3]);
|
||||||
// Zeige aktuelle Quelle auf dem Strip an
|
// Zeige aktuelle Quelle auf dem Strip an
|
||||||
strip.None();
|
// strip.None();
|
||||||
strip.clear();
|
// strip.clear();
|
||||||
strip.show();
|
// strip.show();
|
||||||
strip.colorBox(commandbytes[1]-128, strip.Color(255, 255, 255));
|
// strip.colorBox(commandbytes[1]-128, strip.Color(255, 255, 255));
|
||||||
strip.show();
|
// strip.show();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -310,7 +315,6 @@ void setup() {
|
||||||
// homieNode.advertiseRange("pixels", 0, (NUMPIXELS - 1)*7).settable(onSetPixels);
|
// homieNode.advertiseRange("pixels", 0, (NUMPIXELS - 1)*7).settable(onSetPixels);
|
||||||
// homieNode.advertiseRange("boxs", 0, (BIGPIXELS - 1)*7).settable(onSetBoxs);
|
// homieNode.advertiseRange("boxs", 0, (BIGPIXELS - 1)*7).settable(onSetBoxs);
|
||||||
|
|
||||||
|
|
||||||
Homie.setup();
|
Homie.setup();
|
||||||
|
|
||||||
strip.begin();
|
strip.begin();
|
||||||
|
@ -335,7 +339,7 @@ void setup() {
|
||||||
// strip.setPixelColor(progress / (total / NUMPIXELS), strip.Color(100, 0, 0));
|
// strip.setPixelColor(progress / (total / NUMPIXELS), strip.Color(100, 0, 0));
|
||||||
// strip.show();
|
// strip.show();
|
||||||
});
|
});
|
||||||
|
strip.setCurrentInput(255);
|
||||||
ArduinoOTA.begin();
|
ArduinoOTA.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,6 +355,7 @@ void loop() {
|
||||||
Serial.print(": ");
|
Serial.print(": ");
|
||||||
Serial.print(r1);
|
Serial.print(r1);
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
|
switchNode.setProperty("dataSeq").send(String(r1));
|
||||||
inputbytes[currentnumber] = r1;
|
inputbytes[currentnumber] = r1;
|
||||||
|
|
||||||
output += String(r1, DEC);
|
output += String(r1, DEC);
|
||||||
|
@ -366,13 +371,16 @@ void loop() {
|
||||||
switchNode.setProperty("input").send(String(inputbytes[1]-128, DEC));
|
switchNode.setProperty("input").send(String(inputbytes[1]-128, DEC));
|
||||||
switchNode.setProperty("output").send(String(inputbytes[2]-128, DEC));
|
switchNode.setProperty("output").send(String(inputbytes[2]-128, DEC));
|
||||||
|
|
||||||
|
// Merke aktuelle Quelle zur Anzeige auf dem Strip
|
||||||
|
currentinput = inputbytes[1]-128;
|
||||||
|
strip.setCurrentInput(currentinput);
|
||||||
|
currentoutput = inputbytes[2]-128;
|
||||||
|
|
||||||
// Zeige aktuelle Quelle auf dem Strip an
|
// strip.None();
|
||||||
strip.None();
|
// strip.clear();
|
||||||
strip.clear();
|
// strip.show();
|
||||||
strip.show();
|
// strip.colorBox(inputbytes[1]-128, strip.Color(255, 255, 255));
|
||||||
strip.colorBox(inputbytes[1]-128, strip.Color(255, 255, 255));
|
// strip.show();
|
||||||
strip.show();
|
|
||||||
|
|
||||||
currentnumber = 0;
|
currentnumber = 0;
|
||||||
inputbytes[0] = 0;
|
inputbytes[0] = 0;
|
||||||
|
@ -382,12 +390,17 @@ void loop() {
|
||||||
output = "";
|
output = "";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
if ((currentnumber == 0) && (r1 != 65))
|
||||||
|
{
|
||||||
|
// Wrong input.
|
||||||
|
break;
|
||||||
|
}
|
||||||
Serial.print(">");
|
Serial.print(">");
|
||||||
Serial.print(currentnumber);
|
Serial.print(currentnumber);
|
||||||
Serial.print("<");
|
Serial.print("<");
|
||||||
currentnumber++;
|
currentnumber++;
|
||||||
}
|
}
|
||||||
if (millis() > lastMillis + 1000) // Timeout
|
if (millis() > lastMillis + TIMEOUT) // Timeout
|
||||||
{
|
{
|
||||||
currentnumber = 0;
|
currentnumber = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue