|
|
@ -7,47 +7,9 @@
|
|
|
|
#include <WebServer.h>
|
|
|
|
#include <WebServer.h>
|
|
|
|
#include "e131.h"
|
|
|
|
#include "e131.h"
|
|
|
|
#include <FastLED.h>
|
|
|
|
#include <FastLED.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
|
|
// User configurable
|
|
|
|
int strips[LED_STRIPS] = {170, 170, 170, 170, 170, 170, 170, 170};
|
|
|
|
|
|
|
|
|
|
|
|
//const char* ssid = "iPhone 14"; // WiFi SSID
|
|
|
|
|
|
|
|
//const char* password = "givemewifi"; // WiFi Password
|
|
|
|
|
|
|
|
const char* ntpserver = "pool.ntp.org"; // Address of NTP server. Example: pool.ntp.org
|
|
|
|
|
|
|
|
const char* HOSTNAME = "lighttest";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char* update_path = "/firmware";
|
|
|
|
|
|
|
|
const char* update_username = "admin";
|
|
|
|
|
|
|
|
const char* update_password = "pico-stripper";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Wiznet5500lwIP eth(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//#define DEBUG
|
|
|
|
|
|
|
|
// Total LED count
|
|
|
|
|
|
|
|
#define MAX_LEDS 150
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define LED_TYPE WS2812B
|
|
|
|
|
|
|
|
// Amount of color channels per pixel - i.e. RGB = 3, RGBW = 4
|
|
|
|
|
|
|
|
#define PIXEL_SIZE 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Number of LED strips connected
|
|
|
|
|
|
|
|
#define LED_STRIPS 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Define the data pin connection to each strip
|
|
|
|
|
|
|
|
// Only uncomment the strips you use
|
|
|
|
|
|
|
|
#define STRIP1 0
|
|
|
|
|
|
|
|
//#define STRIP2 0
|
|
|
|
|
|
|
|
//#define STRIP3 2
|
|
|
|
|
|
|
|
//#define STRIP4 3
|
|
|
|
|
|
|
|
//#define STRIP5 4
|
|
|
|
|
|
|
|
//#define STRIP6 5
|
|
|
|
|
|
|
|
//#define STRIP7 6
|
|
|
|
|
|
|
|
//#define STRIP8 7
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define RGB_ORDER RGB
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// define how many LEDs / zones are in each strip
|
|
|
|
|
|
|
|
int strips[LED_STRIPS] = {150};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Begin code
|
|
|
|
// Begin code
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG
|
|
|
@ -114,53 +76,84 @@ template <class T> T println(T in) {
|
|
|
|
void write_universe(int universe, uint8_t data[]) {
|
|
|
|
void write_universe(int universe, uint8_t data[]) {
|
|
|
|
// universe starts at 0
|
|
|
|
// universe starts at 0
|
|
|
|
|
|
|
|
|
|
|
|
PRINTFUNC("Universe: ");
|
|
|
|
//PRINTFUNC("Universe: ");
|
|
|
|
PRINTLNFUNC(universe);
|
|
|
|
//PRINTLNFUNC(universe);
|
|
|
|
int offset = calculate[universe];
|
|
|
|
int offset = calculate[universe];
|
|
|
|
PRINTFUNC("Offset: ");
|
|
|
|
//PRINTFUNC("Offset: ");
|
|
|
|
PRINTLNFUNC(offset);
|
|
|
|
//PRINTLNFUNC(offset);
|
|
|
|
int write_size = universes[universe];
|
|
|
|
int write_size = universes[universe];
|
|
|
|
PRINTFUNC("Length: ");
|
|
|
|
//PRINTFUNC("Length: ");
|
|
|
|
PRINTLNFUNC(write_size);
|
|
|
|
//PRINTLNFUNC(write_size);
|
|
|
|
status = 0;
|
|
|
|
status = 0;
|
|
|
|
for (int i = 0; i < write_size; i++) {
|
|
|
|
for (int i = 0; i < write_size; i++) {
|
|
|
|
int j = i * PIXEL_SIZE + (CHANNEL_START - 1);
|
|
|
|
int j = i * PIXEL_SIZE + (CHANNEL_START - 1);
|
|
|
|
if(debug) {
|
|
|
|
//if(debug) {
|
|
|
|
PRINTFUNC(data[j]);
|
|
|
|
// PRINTFUNC(data[j]);
|
|
|
|
PRINTFUNC(" ");
|
|
|
|
// PRINTFUNC(" ");
|
|
|
|
PRINTFUNC(data[j+1]);
|
|
|
|
// PRINTFUNC(data[j+1]);
|
|
|
|
PRINTFUNC(" ");
|
|
|
|
// PRINTFUNC(" ");
|
|
|
|
PRINTFUNC(data[j+2]);
|
|
|
|
// PRINTFUNC(data[j+2]);
|
|
|
|
PRINTFUNC(" ");
|
|
|
|
// PRINTFUNC(" ");
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
ledstrip[offset + i] = CRGB(data[j], data[j+1], data[j+2]);
|
|
|
|
ledstrip[offset + i] = CRGB(data[j], data[j+1], data[j+2]);
|
|
|
|
//ledstrip[strip].setPixelColor(i + offset, data[j], data[j+1], data[j+2]);
|
|
|
|
//ledstrip[strip].setPixelColor(i + offset, data[j], data[j+1], data[j+2]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
status = 1;
|
|
|
|
status = 1;
|
|
|
|
//FastLED.show();
|
|
|
|
//FastLED.show();
|
|
|
|
PRINTLNFUNC("Done writing.");
|
|
|
|
//PRINTLNFUNC("Done writing.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char* PARAM_INPUT_1 = "ipaddr";
|
|
|
|
|
|
|
|
const char* PARAM_INPUT_2 = "hostname";
|
|
|
|
|
|
|
|
const char* PARAM_INPUT_3 = "universe";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// HTML web page to handle 3 input fields (input1, input2, input3)
|
|
|
|
|
|
|
|
const char index_html[] PROGMEM = R"rawliteral(
|
|
|
|
|
|
|
|
<!DOCTYPE HTML><html><head>
|
|
|
|
|
|
|
|
<title>ESP Input Form</title>
|
|
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
|
|
|
|
</head><body>
|
|
|
|
|
|
|
|
All settings below will save to EEPROM flash and won't get overridden by a firmware upgrade.
|
|
|
|
|
|
|
|
Settings will take effect after reboot.
|
|
|
|
|
|
|
|
<form action="/get">
|
|
|
|
|
|
|
|
ipaddr: <input type="text" name="IP Address">
|
|
|
|
|
|
|
|
<input type="submit" value="Submit">
|
|
|
|
|
|
|
|
</form><br>
|
|
|
|
|
|
|
|
<form action="/get">
|
|
|
|
|
|
|
|
hostname: <input type="text" name="Hostname">
|
|
|
|
|
|
|
|
<input type="submit" value="Submit">
|
|
|
|
|
|
|
|
</form><br>
|
|
|
|
|
|
|
|
<form action="/get">
|
|
|
|
|
|
|
|
universe: <input type="text" name="Start Universe">
|
|
|
|
|
|
|
|
<input type="submit" value="Submit">
|
|
|
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
</body></html>)rawliteral";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//void notFound(AsyncWebServerRequest *request) {
|
|
|
|
|
|
|
|
// request->send(404, "text/plain", "Not found");
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
void setup() {
|
|
|
|
pinMode(20, OUTPUT);
|
|
|
|
pinMode(20, OUTPUT);
|
|
|
|
digitalWrite(20, LOW); // reset W5500
|
|
|
|
digitalWrite(20, LOW); // reset W5500 ethernet
|
|
|
|
delay(1);
|
|
|
|
delay(1);
|
|
|
|
digitalWrite(20, HIGH);
|
|
|
|
digitalWrite(20, HIGH);
|
|
|
|
SPI.setRX(16);
|
|
|
|
SPI.setRX(16);
|
|
|
|
SPI.setCS(17);
|
|
|
|
SPI.setCS(17);
|
|
|
|
SPI.setSCK(18);
|
|
|
|
SPI.setSCK(18);
|
|
|
|
SPI.setTX(19);
|
|
|
|
SPI.setTX(19);
|
|
|
|
pinMode(8, OUTPUT);
|
|
|
|
pinMode(ENABLEPIN, OUTPUT);
|
|
|
|
digitalWrite(8, LOW); // Enable buffer output!
|
|
|
|
digitalWrite(ENABLEPIN, LOW); // Enable buffer output!
|
|
|
|
//pinMode(0, OUTPUT);
|
|
|
|
//pinMode(0, OUTPUT);
|
|
|
|
//digitalWrite(0, HIGH);
|
|
|
|
//digitalWrite(0, HIGH);
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.begin(115200);
|
|
|
|
delay(3000);
|
|
|
|
delay(3000);
|
|
|
|
PRINTLNFUNC("========= PicoLighter v1.0 Initializing =========");
|
|
|
|
println("========= PicoLighter v1.0 Initializing =========");
|
|
|
|
if (!e131.begin()) {
|
|
|
|
if (!e131.begin()) {
|
|
|
|
PRINTFUNC("Connection failed. Retrying.");
|
|
|
|
println("Connection failed. Retrying.");
|
|
|
|
rp2040.reboot();
|
|
|
|
rp2040.reboot();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (ready == 0) {
|
|
|
|
while (ready == 0) {
|
|
|
@ -186,7 +179,7 @@ void setup() {
|
|
|
|
calculate[currentsize] = offsetcount;
|
|
|
|
calculate[currentsize] = offsetcount;
|
|
|
|
|
|
|
|
|
|
|
|
PRINTFUNC(" Universe ");
|
|
|
|
PRINTFUNC(" Universe ");
|
|
|
|
PRINTFUNC(currentsize + 1);
|
|
|
|
PRINTFUNC(currentsize + 1 + START_UNIVERSE);
|
|
|
|
PRINTFUNC(", Light count ");
|
|
|
|
PRINTFUNC(", Light count ");
|
|
|
|
PRINTFUNC(MAX_PIXELS_PER_UNIVERSE);
|
|
|
|
PRINTFUNC(MAX_PIXELS_PER_UNIVERSE);
|
|
|
|
PRINTFUNC(", Size ");
|
|
|
|
PRINTFUNC(", Size ");
|
|
|
@ -198,7 +191,7 @@ void setup() {
|
|
|
|
universes[currentsize] = tmp;
|
|
|
|
universes[currentsize] = tmp;
|
|
|
|
calculate[currentsize] = offsetcount;
|
|
|
|
calculate[currentsize] = offsetcount;
|
|
|
|
PRINTFUNC(" Universe ");
|
|
|
|
PRINTFUNC(" Universe ");
|
|
|
|
PRINTFUNC(currentsize + 1);
|
|
|
|
PRINTFUNC(currentsize + 1 + START_UNIVERSE);
|
|
|
|
PRINTFUNC(", Light count ");
|
|
|
|
PRINTFUNC(", Light count ");
|
|
|
|
PRINTFUNC(tmp);
|
|
|
|
PRINTFUNC(tmp);
|
|
|
|
PRINTFUNC(", Size ");
|
|
|
|
PRINTFUNC(", Size ");
|
|
|
@ -206,7 +199,7 @@ void setup() {
|
|
|
|
offsetcount += tmp;
|
|
|
|
offsetcount += tmp;
|
|
|
|
currentsize += 1;
|
|
|
|
currentsize += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PRINTLNFUNC("========= PicoLighter v1.0 Initialized =========");
|
|
|
|
println("========= PicoLighter v1.0 Initialized =========");
|
|
|
|
initinfo += clientbuffer;
|
|
|
|
initinfo += clientbuffer;
|
|
|
|
//e131.beginMulticast(ssid, passphrase, UNIVERSE);
|
|
|
|
//e131.beginMulticast(ssid, passphrase, UNIVERSE);
|
|
|
|
ready = 0;
|
|
|
|
ready = 0;
|
|
|
@ -251,42 +244,47 @@ void setup1() {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
// Test all lights
|
|
|
|
// Test all lights
|
|
|
|
for (int i = 0; i < MAX_LEDS; i++) {
|
|
|
|
for (int i = 0; i < MAX_LEDS; i++) {
|
|
|
|
ledstrip[i] = CRGB(50, 50, 50);
|
|
|
|
ledstrip[i] = CRGB(0, 0, 50);
|
|
|
|
FastLED.show();
|
|
|
|
FastLED.show();
|
|
|
|
delay(30);
|
|
|
|
delay(1);
|
|
|
|
ledstrip[i] = CRGB(0, 0, 0);
|
|
|
|
ledstrip[i] = CRGB(0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FastLED.show();
|
|
|
|
FastLED.show();
|
|
|
|
delay(3000);
|
|
|
|
//delay(3000);
|
|
|
|
// WiFi.noLowPowerMode();
|
|
|
|
#ifdef INT_WIFI
|
|
|
|
|
|
|
|
WiFi.noLowPowerMode();
|
|
|
|
|
|
|
|
#endif
|
|
|
|
ready = 1;
|
|
|
|
ready = 1;
|
|
|
|
while (ready == 1) {
|
|
|
|
while (ready == 1) {
|
|
|
|
delay(100);
|
|
|
|
delay(100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PRINTLNFUNC("Starting mDNS client.");
|
|
|
|
// If we get here, then network is good to go
|
|
|
|
|
|
|
|
println("Starting mDNS client.");
|
|
|
|
MDNS.begin(HOSTNAME);
|
|
|
|
MDNS.begin(HOSTNAME);
|
|
|
|
httpUpdater.setup(&httpServer, update_path, update_username, update_password);
|
|
|
|
httpUpdater.setup(&httpServer, update_path, update_username, update_password);
|
|
|
|
|
|
|
|
|
|
|
|
httpServer.begin();
|
|
|
|
httpServer.begin();
|
|
|
|
MDNS.addService("http", "tcp", 80);
|
|
|
|
MDNS.addService("http", "tcp", 80);
|
|
|
|
PRINTFUNC("OTA Updates enabled. Open http://");
|
|
|
|
print("OTA Updates enabled. Open http://");
|
|
|
|
PRINTFUNC(HOSTNAME);
|
|
|
|
print(HOSTNAME);
|
|
|
|
PRINTFUNC(update_path);
|
|
|
|
print(update_path);
|
|
|
|
PRINTFUNC(" in your browser and login with username ");
|
|
|
|
print(" in your browser and login with username ");
|
|
|
|
PRINTFUNC(update_username);
|
|
|
|
print(update_username);
|
|
|
|
PRINTFUNC(" and password ");
|
|
|
|
print(" and password ");
|
|
|
|
PRINTLNFUNC(update_password);
|
|
|
|
println(update_password);
|
|
|
|
server.begin();
|
|
|
|
server.begin();
|
|
|
|
|
|
|
|
|
|
|
|
// If we get here, then WiFi is good to go
|
|
|
|
|
|
|
|
PRINTFUNC("Starting NTP client.");
|
|
|
|
if(ENABLE_NTP) {
|
|
|
|
|
|
|
|
println("Starting NTP client.");
|
|
|
|
NTP.begin(ntpserver);
|
|
|
|
NTP.begin(ntpserver);
|
|
|
|
NTP.waitSet([]() { PRINTFUNC("."); }, 15000);
|
|
|
|
NTP.waitSet([]() { print("."); }, 15000);
|
|
|
|
time_t now = time(nullptr);
|
|
|
|
time_t now = time(nullptr);
|
|
|
|
PRINTLNFUNC("");
|
|
|
|
println("");
|
|
|
|
gmtime_r(&now, &timeinfo);
|
|
|
|
gmtime_r(&now, &timeinfo);
|
|
|
|
PRINTFUNC("Current time: ");
|
|
|
|
print("Current time: ");
|
|
|
|
PRINTFUNC(asctime(&timeinfo));
|
|
|
|
println(asctime(&timeinfo));
|
|
|
|
|
|
|
|
}
|
|
|
|
//rp2040.wdt_begin(8000);
|
|
|
|
//rp2040.wdt_begin(8000);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -295,7 +293,9 @@ void setup1() {
|
|
|
|
void loop() {
|
|
|
|
void loop() {
|
|
|
|
/* Parse a packet and update pixels */
|
|
|
|
/* Parse a packet and update pixels */
|
|
|
|
if(e131.parsePacket()) {
|
|
|
|
if(e131.parsePacket()) {
|
|
|
|
write_universe(e131.universe - 1, e131.data);
|
|
|
|
// Offset by start universe
|
|
|
|
|
|
|
|
// as all local functions count from 0
|
|
|
|
|
|
|
|
write_universe(e131.universe - START_UNIVERSE, e131.data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (blankcount > 1000) {
|
|
|
|
else if (blankcount > 1000) {
|
|
|
|
status = 0;
|
|
|
|
status = 0;
|
|
|
@ -322,7 +322,7 @@ void loop1() {
|
|
|
|
//delay(50);
|
|
|
|
//delay(50);
|
|
|
|
float temp = analogReadTemp();
|
|
|
|
float temp = analogReadTemp();
|
|
|
|
if (temp > 50.0) {
|
|
|
|
if (temp > 50.0) {
|
|
|
|
PRINTLNFUNC("ERROR: Overtemperature triggered!");
|
|
|
|
println("ERROR: Overtemperature triggered!");
|
|
|
|
rp2040.reboot();
|
|
|
|
rp2040.reboot();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WiFiClient client = server.available();
|
|
|
|
WiFiClient client = server.available();
|
|
|
@ -349,7 +349,7 @@ void loop1() {
|
|
|
|
//delay(50);
|
|
|
|
//delay(50);
|
|
|
|
float temp = analogReadTemp(); // read temp in celsius
|
|
|
|
float temp = analogReadTemp(); // read temp in celsius
|
|
|
|
if (temp > 50.0) {
|
|
|
|
if (temp > 50.0) {
|
|
|
|
PRINTLNFUNC("ERROR: Overtemperature triggered!");
|
|
|
|
println("ERROR: Overtemperature triggered!");
|
|
|
|
rp2040.reboot();
|
|
|
|
rp2040.reboot();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(clientbuffer != (String) "") {
|
|
|
|
if(clientbuffer != (String) "") {
|
|
|
|