add led panel guides

This commit is contained in:
interfisch 2019-05-11 19:56:31 +02:00
parent f894134310
commit f9e04c8dbf
8 changed files with 34740 additions and 28 deletions

View File

@ -4,9 +4,20 @@
* topics und handler implementieren * topics und handler implementieren
*/ */
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define LEDPIN 8 //PB0 = D8
Adafruit_NeoPixel leds = Adafruit_NeoPixel(9, LEDPIN, NEO_GRB + NEO_KHZ800);
uint8_t wheelpos=0;
#include "Ethernet.h" #include "Ethernet.h"
#include "PubSubClient.h" #include "PubSubClient.h"
boolean useethernet=false;
//Ethernet and MQTT //Ethernet and MQTT
String ip = ""; String ip = "";
uint8_t mac[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x06}; uint8_t mac[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x06};
@ -98,14 +109,23 @@ void setup() {
while (!Serial) {}; while (!Serial) {};
Serial.println("Booting"); Serial.println("Booting");
leds.begin();
if (Ethernet.begin(mac) == 0) { // setup ethernet communication using DHCP for(uint8_t i=0;i<leds.numPixels();i++){ //set color of all leds
Serial.println("Unable to configure Ethernet using DHCP"); leds.setPixelColor(i, leds.Color(100,100,100));
Serial.flush();
delay(200);
for (;;);
} }
leds.show();
if (Ethernet.begin(mac) == 0) { // setup ethernet communication using DHCP
//Unable to configure Ethernet using DHCP
Serial.println("Unable to configure Ethernet using DHCP");
delay(200);
//for (;;);
}else{
useethernet=true;
Serial.println("Ethernet configured via DHCP"); Serial.println("Ethernet configured via DHCP");
Serial.print("IP address: "); Serial.print("IP address: ");
Serial.println(Ethernet.localIP()); Serial.println(Ethernet.localIP());
@ -128,6 +148,8 @@ void setup() {
Serial.println("Ready"); Serial.println("Ready");
}
last_send = millis(); last_send = millis();
@ -154,10 +176,13 @@ void reconnect() {
void loop() { void loop() {
long loopmillis=millis(); long loopmillis=millis();
if (useethernet){
if (!mqttClient.connected()) { if (!mqttClient.connected()) {
reconnect(); reconnect();
} }
mqttClient.loop(); mqttClient.loop();
}
@ -272,6 +297,15 @@ void loop() {
button_flag=false; //clear flag to reenable button triggering. button_flag=false; //clear flag to reenable button triggering.
} }
for(uint8_t i=0;i<leds.numPixels();i++){ //set color of all leds
leds.setPixelColor(i, Wheel(wheelpos+i*10));
}
wheelpos+=5;
leds.show();
} }
@ -341,3 +375,17 @@ void srWrite(uint8_t pin, boolean state){
boolean srRead(uint8_t pin){ boolean srRead(uint8_t pin){
return (srbits >> pin) & 1U; return (srbits >> pin) & 1U;
} }
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return leds.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return leds.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return leds.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

16994
inventor/ledpanel_guide.dxf Normal file

File diff suppressed because it is too large Load Diff

BIN
inventor/ledpanel_guide.ipt Normal file

Binary file not shown.