rename client
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#define NUM_LEDS 150
|
||||
#define DATA_PIN D8
|
||||
#define LED_TYPE WS2811
|
||||
#define COLOR_ORDER GRB
|
||||
|
||||
#define MILLI_AMPS 2000 // IMPORTANT: set the max milli-Amps of your power supply (4A = 4000mA)
|
||||
#define FRAMES_PER_SECOND 120 // here you can control the speed. With the Access Point / Web Server the animations run a bit slower.
|
||||
|
||||
const char* ssid = "none";
|
||||
const char* password = "none";
|
||||
|
||||
//RecipientIP is overridden after wl connect, getting localip and set last octet to 255 (Broadcast)
|
||||
//this will only work for /24 networks. If you want to set an other BC or a sinle IP adress set overriderecipient to true
|
||||
bool overriderecipient = false;
|
||||
IPAddress RecipientIP = IPAddress(0, 0, 0, 0);
|
||||
|
||||
unsigned int RecipientPort = 8002;
|
||||
@@ -0,0 +1,19 @@
|
||||
#define NUM_LEDS 150
|
||||
#define DATA_PIN D8
|
||||
#define LED_TYPE WS2811
|
||||
#define COLOR_ORDER GRB
|
||||
|
||||
#define MILLI_AMPS 2000 // IMPORTANT: set the max milli-Amps of your power supply (4A = 4000mA)
|
||||
#define FRAMES_PER_SECOND 120 // here you can control the speed. With the Access Point / Web Server the animations run a bit slower.
|
||||
|
||||
String StripName = "Regal";
|
||||
|
||||
const char* ssid = "zy-intern";
|
||||
const char* password = "Rg>379rqQX$*h-Tx";
|
||||
|
||||
//RecipientIP is overridden after wl connect, getting localip and set last octet to 255 (Broadcast)
|
||||
//this will only work for /24 networks. If you want to set an other BC or a sinle IP adress set overriderecipient to true
|
||||
bool overriderecipient = false;
|
||||
IPAddress RecipientIP = IPAddress(0, 0, 0, 0);
|
||||
|
||||
unsigned int RecipientPort = 8002;
|
||||
@@ -0,0 +1,92 @@
|
||||
|
||||
//#define FASTLED_ALLOW_INTERRUPTS 0
|
||||
//#define FASTLED_INTERRUPT_RETRY_COUNT 0
|
||||
//#define WEBSOCKETS_NETWORK_TYPE NETWORK_ESP8266_ASYNC
|
||||
#define UDP_TX_PACKET_MAX_SIZE = 50*12+1;
|
||||
|
||||
#include <FastLED.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <WiFiUdp.h>
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
CRGB leds[NUM_LEDS];
|
||||
|
||||
WiFiClient client;
|
||||
|
||||
// buffers for receiving and sending data
|
||||
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];
|
||||
WiFiUDP Udp;
|
||||
|
||||
int c = -1;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS); // for WS2812 (Neopixel)
|
||||
//FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS); // for APA102 (Dotstar)
|
||||
FastLED.setDither(false);
|
||||
FastLED.setCorrection(TypicalLEDStrip);
|
||||
FastLED.setBrightness(255);
|
||||
FastLED.setMaxPowerInVoltsAndMilliamps(5, MILLI_AMPS);
|
||||
fill_solid(leds, NUM_LEDS, CRGB::Black);
|
||||
wdt_enable(WDTO_4S); // Watchdog auf 4 s stellen
|
||||
FastLED.show();
|
||||
Udp.begin(random(5000,5500));
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
EVERY_N_MILLISECONDS( 250 ) {
|
||||
sendUDP(String("s:ping"));
|
||||
}
|
||||
EVERY_N_MILLISECONDS( 15 ) {
|
||||
wdt_reset();
|
||||
if (WiFi.status() != WL_CONNECTED) { // FIX FOR USING 2.3.0 CORE (only .begin if not connected)
|
||||
WiFi.begin(ssid, password); // connect to the network
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
}
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
// Start UDP
|
||||
Serial.println("start udp");
|
||||
if(!overriderecipient){
|
||||
RecipientIP = WiFi.localIP();
|
||||
RecipientIP[3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
int packetSize = Udp.parsePacket();
|
||||
if(packetSize)
|
||||
{
|
||||
// read the packet into packetBufffer
|
||||
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
|
||||
if(packetBuffer[0] == 's' && packetBuffer[1] == 'r'){
|
||||
sendUDP("r:1:"+StripName+":"+String(NUM_LEDS)+":0");
|
||||
}
|
||||
if(packetBuffer[0] == 's' && packetBuffer[1] == 'u'){
|
||||
FastLED.show();
|
||||
}
|
||||
if(packetBuffer[0] == 'd'){
|
||||
c=1;
|
||||
while(c<strlen(packetBuffer)){
|
||||
leds[getledvalue(c)] = CRGB( getledvalue(c+3), getledvalue(c+6), getledvalue(c+9));
|
||||
c=c+12;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int getledvalue(int startpoint){
|
||||
return 100 * int(packetBuffer[startpoint] - '0') + 10 * int(packetBuffer[startpoint+1] - '0') + int(packetBuffer[startpoint+2] - '0');
|
||||
}
|
||||
|
||||
// Function to send UDP packets
|
||||
void sendUDP(String text)
|
||||
{
|
||||
//Serial.println(text);
|
||||
Udp.beginPacket(RecipientIP, RecipientPort);
|
||||
Udp.print(text);
|
||||
Udp.endPacket();
|
||||
}
|
||||
Reference in New Issue
Block a user