Autor Thema: Neues Modul zur Steuerung von WS2812b LED stripes  (Gelesen 41845 mal)

Offline tklein

  • Sr. Member
  • ****
  • Beiträge: 608
Antw:Neues Modul zur Steuerung von WS2812b LED stripes
« Antwort #165 am: 18 Januar 2019, 20:11:57 »
Hallo zusammen,

ich verzweifel gerade daran mit Atom oder Arduino IDE die ESP8266 Version auf den Wemos zu flashen.

Bei Atom bekomme ich diese Meldung beim Kompilieren:

Processing d1_mini_lite (platform: espressif8266; board: d1_mini_lite; framework: arduino)
 
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini_lite.html
PLATFORM: Espressif 8266 > WeMos D1 mini Lite
HARDWARE: ESP8266 80MHz 80KB RAM (1MB Flash)
Converting httpledstripe_esp_v1.ino

Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 31 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ESP8266WiFi> 1.0
|-- <Adafruit NeoPixel> 1.0.6
Compiling .pioenvs\d1_mini_lite\src\httpledstripe_esp_v1.ino.cpp.o
Compiling .pioenvs\d1_mini_lite\libf7b\ESP8266WiFi\ESP8266WiFiMulti.cpp.o
C:/Users/tklein/Documents/PlatformIO/Projects/ws8212_fhem/src/httpledstripe_esp_v1.ino: In function 'void setup()':
C:/Users/tklein/Documents/PlatformIO/Projects/ws8212_fhem/src/httpledstripe_esp_v1.ino:43:15: error: 'stripe_setup' was not declared in this scope
stripe_setup();
^
C:/Users/tklein/Documents/PlatformIO/Projects/ws8212_fhem/src/httpledstripe_esp_v1.ino: In function 'void loop()':
C:/Users/tklein/Documents/PlatformIO/Projects/ws8212_fhem/src/httpledstripe_esp_v1.ino:99:87: error: 'stripe_color' was not declared in this scope
stripe_setPixelColor(ledix++, stripe_color(redLevel,greenLevel,blueLevel));
^
C:/Users/tklein/Documents/PlatformIO/Projects/ws8212_fhem/src/httpledstripe_esp_v1.ino:99:88: error: 'stripe_setPixelColor' was not declared in this scop
e
stripe_setPixelColor(ledix++, stripe_color(redLevel,greenLevel,blueLevel));

...

C:/Users/tklein/Documents/PlatformIO/Projects/ws8212_fhem/src/httpledstripe_esp_v1.ino:256:14: error: a function-definition is not allowed here before '{
' token
void reset() {
^
C:/Users/tklein/Documents/PlatformIO/Projects/ws8212_fhem/src/httpledstripe_esp_v1.ino:342:1: error: expected '}' at end of input
}
^
*** [.pioenvs\d1_mini_lite\src\httpledstripe_esp_v1.ino.cpp.o] Error 1
 [ERROR] Took 8.35 seconds

Hatte mal gelesen, dass das evtl. auf Sonderzeichen im Pfad hindeuten könnten. Dort sind aber keine.

So ist die identische Meldung bei Arduino IDE:

C:\Users\tklein\Documents\Arduino\FHEM-LEDStripe-master\FHEM-LEDStripe-master\Arduino\httpledstripe_esp_v1\httpledstripe_esp_v1.ino: In function 'void setup()':

httpledstripe_esp_v1:43: error: 'stripe_setup' was not declared in this scope

  stripe_setup();

               ^

C:\Users\tklein\Documents\Arduino\FHEM-LEDStripe-master\FHEM-LEDStripe-master\Arduino\httpledstripe_esp_v1\httpledstripe_esp_v1.ino: In function 'void loop()':

httpledstripe_esp_v1:91: error: 'colorVal' was not declared in this scope

               redLevel = colorVal(c);

                                    ^

httpledstripe_esp_v1:99: error: 'stripe_color' was not declared in this scope

               stripe_setPixelColor(ledix++, stripe_color(redLevel,greenLevel,blueLevel));

                                                                                       ^

httpledstripe_esp_v1:99: error: 'stripe_setPixelColor' was not declared in this scope

               stripe_setPixelColor(ledix++, stripe_color(redLevel,greenLevel,blueLevel));

                                                                                        ^

httpledstripe_esp_v1:103: error: 'stripe_show' was not declared in this scope


...


httpledstripe_esp_v1:252: error: 'blinkerEffect' was not declared in this scope

   if (blinker) blinkerEffect();

                              ^

httpledstripe_esp_v1:256: error: a function-definition is not allowed here before '{' token

 void reset() {

              ^

vstripe:50: error: expected '}' at end of input

 }

 ^

exit status 1
'stripe_setup' was not declared in this scope

Die *.ino Datei hat folgenden Inhalt:

#include <Adafruit_NeoPixel.h>
#include <ESP8266WiFi.h>

const char* ssid     = "xyz";
const char* password = "123456789..";
WiFiServer server(80);
// Which pin on the Arduino is connected to the NeoPixels?
#define LEDPIN1           4
#define LEDPIN2           0

// How many NeoPixels are attached to the Arduino?
//#define NUMPIXELS1     8
#define NUMPIXELS1     140
#define NUMPIXELS2     0
int xfrom;
int yto;
int myredLevel;
int mygreenLevel;
int myblueLevel;
int myOn;
int myOff;


void reset();
// control special effects
boolean fire=false;
boolean rainbow=false;
boolean blinker=false;
uint16_t rainbowColor=0;



// setup network and output pins
void setup() {
// Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial.println(F("Booting"));

 // Initialize all pixels to 'off'
 stripe_setup();
  WiFi.mode(WIFI_STA);
Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  server.begin();
 
}

// request receive loop
void loop() {
// listen for incoming clients
  WiFiClient client = server.available();  // Check if a client has connected
  if (client) {
    Serial.println(F("new client"));
   
    String inputLine = "";
   // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    boolean isGet = false;
    boolean isPost = false;
    boolean isPostData = false;
    int postDataLength;
    int ledix = 0;
    int tupel = 0;
    int redLevel = 0;
    int greenLevel = 0;
    int blueLevel = 0;
   
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if (isPostData && postDataLength > 0) {
          switch (tupel++) {
            case 0:
              redLevel = colorVal(c);
              break;
            case 1:
              greenLevel = colorVal(c);
              break;
            case 2:
              blueLevel = colorVal(c);
              tupel = 0;
              stripe_setPixelColor(ledix++, stripe_color(redLevel,greenLevel,blueLevel));
              break;
          }
          if (--postDataLength == 0) {
            stripe_show();
            sendOkResponse(client);
            break;
          }
        }
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          if (isPost) {
            isPostData = true;
            continue;
          } else {
            // send http response
            if (isGet) {
              sendOkResponse(client);
            } else {
              client.println(F("HTTP/1.1 500 Invalid request"));
              client.println(F("Connection: close"));  // the connection will be closed after completion of the response
              client.println();
            }
            break;
          }
        }
        if (c == '\n') {
          // http starting a new line, evaluate current line
          currentLineIsBlank = true;
          Serial.println(inputLine);
         
// SET SINGLE PIXEL url should be GET /rgb/n/rrr,ggg,bbb
          if (inputLine.length() > 3 && inputLine.substring(0,9) == F("GET /rgb/")) {
            int slash = inputLine.indexOf('/', 9 );
            ledix = inputLine.substring(9,slash).toInt();
            int urlend = inputLine.indexOf(' ', 9 );
            String getParam = inputLine.substring(slash+1,urlend+1);
            int komma1 = getParam.indexOf(',');
            int komma2 = getParam.indexOf(',',komma1+1);
            redLevel = getParam.substring(0,komma1).toInt();
            greenLevel = getParam.substring(komma1+1,komma2).toInt();
            blueLevel = getParam.substring(komma2+1).toInt();
            stripe_setPixelColor(ledix, stripe_color(redLevel,greenLevel,blueLevel));
            stripe_show();
            isGet = true;
          }
          // SET PIXEL RANGE url should be GET /range/x,y/rrr,ggg,bbb
          if (inputLine.length() > 3 && inputLine.substring(0,11) == F("GET /range/")) {
            int slash = inputLine.indexOf('/', 11 );
            int komma1 = inputLine.indexOf(',');
            int x = inputLine.substring(11, komma1).toInt();
            int y = inputLine.substring(komma1+1, slash).toInt();
            int urlend = inputLine.indexOf(' ', 11 );
            String getParam = inputLine.substring(slash+1,urlend+1);
            komma1 = getParam.indexOf(',');
            int komma2 = getParam.indexOf(',',komma1+1);
            redLevel = getParam.substring(0,komma1).toInt();
            greenLevel = getParam.substring(komma1+1,komma2).toInt();
            blueLevel = getParam.substring(komma2+1).toInt();
            for(int i=x; i<=y; i++) {
              stripe_setPixelColor(i, stripe_color(redLevel,greenLevel,blueLevel));
            }
            stripe_show();
            isGet = true;
          }
          // POST PIXEL DATA
          if (inputLine.length() > 3 && inputLine.substring(0,10) == F("POST /leds")) {
            isPost = true;
          }
          if (inputLine.length() > 3 && inputLine.substring(0,16) == F("Content-Length: ")) {
            postDataLength = inputLine.substring(16).toInt();
          }
          // SET ALL PIXELS OFF url should be GET /off
          if (inputLine.length() > 3 && inputLine.substring(0,8) == F("GET /off")) {
            reset();
            isGet = true;
          }
         
          // GET STATUS url should be GET /status
          if (inputLine.length() > 3 && inputLine.substring(0,11) == F("GET /status")) {
            isGet = true;
          }
          // SET FIRE EFFECT
          if (inputLine.length() > 3 && inputLine.substring(0,9) == F("GET /fire")) {
            fire = true;
            rainbow = false;
            stripe_setBrightness(128);
            isGet = true;

         // SET EFFECT 1
          if (inputLine.length() > 3 && inputLine.substring(0,9) == F("GET /fx_1")) {
            fire = true;
            rainbow = false;
            stripe_setBrightness(50);
            isGet = true;
          }
          // SET RAINBOW EFFECT
          if (inputLine.length() > 3 && inputLine.substring(0,12) == F("GET /rainbow")) {
            rainbow = true;
            fire = false;
            stripe_setBrightness(128);
            isGet = true;
          }
          // SET no_effects
          if (inputLine.length() > 3 && inputLine.substring(0,9) == F("GET /nofx")) {
            rainbow = false;
            fire = false;
            blinker = false;
            isGet = true;
          }
          if (inputLine.length() > 3 && inputLine.substring(0,11) == F("GET /blink/")) {
            int slash = inputLine.indexOf('/', 11 );
            int komma1 = inputLine.indexOf(',');
            xfrom = inputLine.substring(11, komma1).toInt();
            yto = inputLine.substring(komma1+1, slash).toInt();
            int urlend = inputLine.indexOf(' ', 11 );
            String getParam = inputLine.substring(slash+1,urlend+1);
            komma1 = getParam.indexOf(',');
            int komma2 = getParam.indexOf(',',komma1+1);
            int komma3 = getParam.indexOf(',',komma2+1);
            int komma4 = getParam.indexOf(',',komma3+1);
            myredLevel = getParam.substring(0,komma1).toInt();
            mygreenLevel = getParam.substring(komma1+1, komma2).toInt();
            myblueLevel = getParam.substring(komma2+1, komma3).toInt();
           
            myOn = getParam.substring(komma3+1, komma4).toInt();
            myOff = getParam.substring(komma4+1).toInt();

            blinker = true;
            rainbow = false;
            fire = false;
           
            isGet = true;
          }
          inputLine = "";
        }
        else if (c != '\r') {
          // add character to the current line
          currentLineIsBlank = false;
          inputLine += c;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println(F("client disconnected"));
  }
  if (fire) fireEffect();
  if (rainbow) rainbowCycle();
  if (blinker) blinkerEffect();
}

// Reset stripe, all LED off and no effects
void reset() {
  for(int i=0; i<stripe_numPixels(); i++) {
    stripe_setPixelColor(i, 0);
  }
  stripe_setBrightness(255);
  stripe_show();
  fire = false;
  rainbow = false;
  blinker = false;
}

// LED flicker fire effect
void fireEffect() {
  for(int x = 0; x <stripe_numPixels(); x++) {
    int flicker = random(0,55);
    int r1 = 226-flicker;
    int g1 = 121-flicker;
    int b1 = 35-flicker;
    if(g1<0) g1=0;
    if(r1<0) r1=0;
    if(b1<0) b1=0;
    stripe_setPixelColor(x,stripe_color(r1,g1, b1));
  }
  stripe_show();
  delay(random(10,113));
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle() {
  uint16_t i;

  if (rainbowColor++>255) rainbowColor=0;
  for(i=0; i< stripe_numPixels(); i++) {
    stripe_setPixelColor(i, Wheel(((i * 256 / stripe_numPixels()) + rainbowColor) & 255));
  }
  stripe_show();
  delay(20);
}

void blinkerEffect() {
 for(int i=xfrom; i<=yto; i++) {
    stripe_setPixelColor(i, stripe_color(myredLevel,mygreenLevel,myblueLevel));
  }
  stripe_show();
 delay(myOn);
 for(int i=xfrom; i<= yto; i++) {
    stripe_setPixelColor(i, stripe_color(0,0,0));
  }
  stripe_show();
delay(myOff);
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return stripe_color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return stripe_color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return stripe_color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

int colorVal(char c) {
  int i = (c>='0' && c<='9') ? (c-'0') : (c - 'A' + 10);
  return i*i + i*2;
}

void sendOkResponse(WiFiClient client) {
  client.println(F("HTTP/1.1 200 OK"));
  client.println(F("Content-Type: text/html"));
  client.println(F("Connection: close"));  // the connection will be closed after completion of the response
  client.println();
  // standard response
  client.print(F("OK,"));
  client.print(stripe_numPixels());
  client.print(F(","));
  int oncount=0;
  for(int i=0; i<stripe_numPixels(); i++) {
    if (stripe_getPixelColor(i) != 0) oncount++;
  }
  client.println(oncount);
}

Wo ist der Fehler? Kann mir da jemand bitte weiterhelfen?
Muss ich noch eine Library einbinden?


Viele Grüße
Thomas
FHEM auf Pi 3, Echo (Plus, Dot und Connect), CUL868/433, HM Komponenten, Broadlink, Enigma (VU DUO2), Alexa/Homebridge, Sonoffs (POW, RF, Basic), Wemos D1 (IR, DHT, BH1750, OLED, BMP180), IT/Steckdosen, Fritzbox mit SIP, Wifilight, MQTT, Pilight, Xiaomi Flower Sensor, Spotify, Dooya, Shelly

Offline tklein

  • Sr. Member
  • ****
  • Beiträge: 608
Antw:Neues Modul zur Steuerung von WS2812b LED stripes
« Antwort #166 am: 18 Januar 2019, 20:53:16 »
das wird bestimmt etwas mit der Aussgae von exciter zu tun haben: "Mit der vstripe aus dem Originalfile zu kompilieren. Pin, SSID, KEY, nach Bedarf anpassen."
--Allerdings verstehe ich das nicht so richtig, was da gemacht werden muss.
FHEM auf Pi 3, Echo (Plus, Dot und Connect), CUL868/433, HM Komponenten, Broadlink, Enigma (VU DUO2), Alexa/Homebridge, Sonoffs (POW, RF, Basic), Wemos D1 (IR, DHT, BH1750, OLED, BMP180), IT/Steckdosen, Fritzbox mit SIP, Wifilight, MQTT, Pilight, Xiaomi Flower Sensor, Spotify, Dooya, Shelly

Offline Maui

  • Sr. Member
  • ****
  • Beiträge: 533
Antw:Neues Modul zur Steuerung von WS2812b LED stripes
« Antwort #167 am: 18 Januar 2019, 21:05:35 »
Ist lange her aber ich meine du musst noch eine Library einbinden. Hab's mit Arduino IDE geflasht.
Neopixel brauchst du noch.
Hast du auch die auf wemos angepasste ino genommen?

Offline tklein

  • Sr. Member
  • ****
  • Beiträge: 608
Antw:Neues Modul zur Steuerung von WS2812b LED stripes
« Antwort #168 am: 18 Januar 2019, 21:22:55 »
so sehen meine libs aus. Die ESP Version habe ich nur angepasst (SSID,PW,PIN, LED Anzahl)
FHEM auf Pi 3, Echo (Plus, Dot und Connect), CUL868/433, HM Komponenten, Broadlink, Enigma (VU DUO2), Alexa/Homebridge, Sonoffs (POW, RF, Basic), Wemos D1 (IR, DHT, BH1750, OLED, BMP180), IT/Steckdosen, Fritzbox mit SIP, Wifilight, MQTT, Pilight, Xiaomi Flower Sensor, Spotify, Dooya, Shelly

Offline Maui

  • Sr. Member
  • ****
  • Beiträge: 533
Antw:Neues Modul zur Steuerung von WS2812b LED stripes
« Antwort #169 am: 18 Januar 2019, 22:34:43 »
Wo hast den Sketch denn her? Direkt aus Github per console gezogen?

Offline tklein

  • Sr. Member
  • ****
  • Beiträge: 608
Antw:Neues Modul zur Steuerung von WS2812b LED stripes
« Antwort #170 am: 18 Januar 2019, 22:38:04 »
von Seite 2 dieses Post glaube mich noch dran zu erinnern. --> https://forum.fhem.de/index.php/topic,50174.15.html
Wo kann ich mir den sonst ziehen?
FHEM auf Pi 3, Echo (Plus, Dot und Connect), CUL868/433, HM Komponenten, Broadlink, Enigma (VU DUO2), Alexa/Homebridge, Sonoffs (POW, RF, Basic), Wemos D1 (IR, DHT, BH1750, OLED, BMP180), IT/Steckdosen, Fritzbox mit SIP, Wifilight, MQTT, Pilight, Xiaomi Flower Sensor, Spotify, Dooya, Shelly

Offline Maui

  • Sr. Member
  • ****
  • Beiträge: 533
« Letzte Änderung: 19 Januar 2019, 08:44:05 von Maui »

Offline tklein

  • Sr. Member
  • ****
  • Beiträge: 608
Antw:Neues Modul zur Steuerung von WS2812b LED stripes
« Antwort #172 am: 19 Januar 2019, 12:02:38 »
besten dank für deine infos!! jetzt hat es geklappt.
habe allerdings die ordnerstruktur ein bißchen modifiziert. evtl passen jetzt die pfade die zuvor nicht korrekt waren.
gibt es noch andere sketchs/module die per fhem ws2812b ansteuern können?
FHEM auf Pi 3, Echo (Plus, Dot und Connect), CUL868/433, HM Komponenten, Broadlink, Enigma (VU DUO2), Alexa/Homebridge, Sonoffs (POW, RF, Basic), Wemos D1 (IR, DHT, BH1750, OLED, BMP180), IT/Steckdosen, Fritzbox mit SIP, Wifilight, MQTT, Pilight, Xiaomi Flower Sensor, Spotify, Dooya, Shelly

Offline DazDavid

  • Jr. Member
  • **
  • Beiträge: 98
Antw:Neues Modul zur Steuerung von WS2812b LED stripes
« Antwort #173 am: 21 Januar 2019, 11:55:45 »
Hallo,

erst einmal danke für das Modul.
Ich habe vor meine Treppenstufen zu beleuchten und bei 60LEDs/m werden es am Ende ca. 420 LEDs sein.
Ich habe mir dazu ein "Wemos D1 Mini kompatibles Board" mit 4MBit Speicher in der Bucht geholt.
Tendenziell sollte das von der Größe des Speichers kein Problem darstellen oder?
Brauche ich für das Wemos Board auch noch einen Level-Shifter für die Datenleitung oder ist dafür der Vorwiderstand von 470Ohm gedacht?

Gruß David
« Letzte Änderung: 21 Januar 2019, 12:34:17 von DazDavid »
FHEM (up2date) on Raspberry Pi 3B | nanoCUL 868 MHz | Raspbee Zigbee Gateway | Philips Hue | Osram Lightify | MAX Thermostate

Offline Maui

  • Sr. Member
  • ****
  • Beiträge: 533
Antw:Neues Modul zur Steuerung von WS2812b LED stripes
« Antwort #174 am: 21 Januar 2019, 19:21:15 »
Also ich hab meine stripes direkt am wemos hängen.
Vom Speicher her sollte es gehen. Ich hab allerdings nur 120 am wemos hängen.