|
|
|
@ -7,47 +7,9 @@
|
|
|
|
|
#include <WebServer.h>
|
|
|
|
|
#include "e131.h"
|
|
|
|
|
#include <FastLED.h>
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
// User configurable
|
|
|
|
|
|
|
|
|
|
//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};
|
|
|
|
|
|
|
|
|
|
int strips[LED_STRIPS] = {170, 170, 170, 170, 170, 170, 170, 170};
|
|
|
|
|
// Begin code
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
@ -114,53 +76,84 @@ template <class T> T println(T in) {
|
|
|
|
|
void write_universe(int universe, uint8_t data[]) {
|
|
|
|
|
// universe starts at 0
|
|
|
|
|
|
|
|
|
|
PRINTFUNC("Universe: ");
|
|
|
|
|
PRINTLNFUNC(universe);
|
|
|
|
|
//PRINTFUNC("Universe: ");
|
|
|
|
|
//PRINTLNFUNC(universe);
|
|
|
|
|
int offset = calculate[universe];
|
|
|
|
|
PRINTFUNC("Offset: ");
|
|
|
|
|
PRINTLNFUNC(offset);
|
|
|
|
|
//PRINTFUNC("Offset: ");
|
|
|
|
|
//PRINTLNFUNC(offset);
|
|
|
|
|
int write_size = universes[universe];
|
|
|
|
|
PRINTFUNC("Length: ");
|
|
|
|
|
PRINTLNFUNC(write_size);
|
|
|
|
|
//PRINTFUNC("Length: ");
|
|
|
|
|
//PRINTLNFUNC(write_size);
|
|
|
|
|
status = 0;
|
|
|
|
|
for (int i = 0; i < write_size; i++) {
|
|
|
|
|
int j = i * PIXEL_SIZE + (CHANNEL_START - 1);
|
|
|
|
|
if(debug) {
|
|
|
|
|
PRINTFUNC(data[j]);
|
|
|
|
|
PRINTFUNC(" ");
|
|
|
|
|
PRINTFUNC(data[j+1]);
|
|
|
|
|
PRINTFUNC(" ");
|
|
|
|
|
PRINTFUNC(data[j+2]);
|
|
|
|
|
PRINTFUNC(" ");
|
|
|
|
|
}
|
|
|
|
|
//if(debug) {
|
|
|
|
|
// PRINTFUNC(data[j]);
|
|
|
|
|
// PRINTFUNC(" ");
|
|
|
|
|
// PRINTFUNC(data[j+1]);
|
|
|
|
|
// PRINTFUNC(" ");
|
|
|
|
|
// PRINTFUNC(data[j+2]);
|
|
|
|
|
// PRINTFUNC(" ");
|
|
|
|
|
//}
|
|
|
|
|
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]);
|
|
|
|
|
}
|
|
|
|
|
status = 1;
|
|
|
|
|
//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() {
|
|
|
|
|
pinMode(20, OUTPUT);
|
|
|
|
|
digitalWrite(20, LOW); // reset W5500
|
|
|
|
|
digitalWrite(20, LOW); // reset W5500 ethernet
|
|
|
|
|
delay(1);
|
|
|
|
|
digitalWrite(20, HIGH);
|
|
|
|
|
SPI.setRX(16);
|
|
|
|
|
SPI.setCS(17);
|
|
|
|
|
SPI.setSCK(18);
|
|
|
|
|
SPI.setTX(19);
|
|
|
|
|
pinMode(8, OUTPUT);
|
|
|
|
|
digitalWrite(8, LOW); // Enable buffer output!
|
|
|
|
|
pinMode(ENABLEPIN, OUTPUT);
|
|
|
|
|
digitalWrite(ENABLEPIN, LOW); // Enable buffer output!
|
|
|
|
|
//pinMode(0, OUTPUT);
|
|
|
|
|
//digitalWrite(0, HIGH);
|
|
|
|
|
Serial.begin(115200);
|
|
|
|
|
delay(3000);
|
|
|
|
|
PRINTLNFUNC("========= PicoLighter v1.0 Initializing =========");
|
|
|
|
|
println("========= PicoLighter v1.0 Initializing =========");
|
|
|
|
|
if (!e131.begin()) {
|
|
|
|
|
PRINTFUNC("Connection failed. Retrying.");
|
|
|
|
|
println("Connection failed. Retrying.");
|
|
|
|
|
rp2040.reboot();
|
|
|
|
|
}
|
|
|
|
|
while (ready == 0) {
|
|
|
|
@ -186,7 +179,7 @@ void setup() {
|
|
|
|
|
calculate[currentsize] = offsetcount;
|
|
|
|
|
|
|
|
|
|
PRINTFUNC(" Universe ");
|
|
|
|
|
PRINTFUNC(currentsize + 1);
|
|
|
|
|
PRINTFUNC(currentsize + 1 + START_UNIVERSE);
|
|
|
|
|
PRINTFUNC(", Light count ");
|
|
|
|
|
PRINTFUNC(MAX_PIXELS_PER_UNIVERSE);
|
|
|
|
|
PRINTFUNC(", Size ");
|
|
|
|
@ -198,7 +191,7 @@ void setup() {
|
|
|
|
|
universes[currentsize] = tmp;
|
|
|
|
|
calculate[currentsize] = offsetcount;
|
|
|
|
|
PRINTFUNC(" Universe ");
|
|
|
|
|
PRINTFUNC(currentsize + 1);
|
|
|
|
|
PRINTFUNC(currentsize + 1 + START_UNIVERSE);
|
|
|
|
|
PRINTFUNC(", Light count ");
|
|
|
|
|
PRINTFUNC(tmp);
|
|
|
|
|
PRINTFUNC(", Size ");
|
|
|
|
@ -206,7 +199,7 @@ void setup() {
|
|
|
|
|
offsetcount += tmp;
|
|
|
|
|
currentsize += 1;
|
|
|
|
|
}
|
|
|
|
|
PRINTLNFUNC("========= PicoLighter v1.0 Initialized =========");
|
|
|
|
|
println("========= PicoLighter v1.0 Initialized =========");
|
|
|
|
|
initinfo += clientbuffer;
|
|
|
|
|
//e131.beginMulticast(ssid, passphrase, UNIVERSE);
|
|
|
|
|
ready = 0;
|
|
|
|
@ -251,42 +244,47 @@ void setup1() {
|
|
|
|
|
#endif
|
|
|
|
|
// Test all lights
|
|
|
|
|
for (int i = 0; i < MAX_LEDS; i++) {
|
|
|
|
|
ledstrip[i] = CRGB(50, 50, 50);
|
|
|
|
|
ledstrip[i] = CRGB(0, 0, 50);
|
|
|
|
|
FastLED.show();
|
|
|
|
|
delay(30);
|
|
|
|
|
delay(1);
|
|
|
|
|
ledstrip[i] = CRGB(0, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
FastLED.show();
|
|
|
|
|
delay(3000);
|
|
|
|
|
// WiFi.noLowPowerMode();
|
|
|
|
|
//delay(3000);
|
|
|
|
|
#ifdef INT_WIFI
|
|
|
|
|
WiFi.noLowPowerMode();
|
|
|
|
|
#endif
|
|
|
|
|
ready = 1;
|
|
|
|
|
while (ready == 1) {
|
|
|
|
|
delay(100);
|
|
|
|
|
}
|
|
|
|
|
PRINTLNFUNC("Starting mDNS client.");
|
|
|
|
|
// If we get here, then network is good to go
|
|
|
|
|
println("Starting mDNS client.");
|
|
|
|
|
MDNS.begin(HOSTNAME);
|
|
|
|
|
httpUpdater.setup(&httpServer, update_path, update_username, update_password);
|
|
|
|
|
|
|
|
|
|
httpServer.begin();
|
|
|
|
|
MDNS.addService("http", "tcp", 80);
|
|
|
|
|
PRINTFUNC("OTA Updates enabled. Open http://");
|
|
|
|
|
PRINTFUNC(HOSTNAME);
|
|
|
|
|
PRINTFUNC(update_path);
|
|
|
|
|
PRINTFUNC(" in your browser and login with username ");
|
|
|
|
|
PRINTFUNC(update_username);
|
|
|
|
|
PRINTFUNC(" and password ");
|
|
|
|
|
PRINTLNFUNC(update_password);
|
|
|
|
|
print("OTA Updates enabled. Open http://");
|
|
|
|
|
print(HOSTNAME);
|
|
|
|
|
print(update_path);
|
|
|
|
|
print(" in your browser and login with username ");
|
|
|
|
|
print(update_username);
|
|
|
|
|
print(" and password ");
|
|
|
|
|
println(update_password);
|
|
|
|
|
server.begin();
|
|
|
|
|
|
|
|
|
|
// If we get here, then WiFi is good to go
|
|
|
|
|
PRINTFUNC("Starting NTP client.");
|
|
|
|
|
NTP.begin(ntpserver);
|
|
|
|
|
NTP.waitSet([]() { PRINTFUNC("."); }, 15000);
|
|
|
|
|
time_t now = time(nullptr);
|
|
|
|
|
PRINTLNFUNC("");
|
|
|
|
|
gmtime_r(&now, &timeinfo);
|
|
|
|
|
PRINTFUNC("Current time: ");
|
|
|
|
|
PRINTFUNC(asctime(&timeinfo));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(ENABLE_NTP) {
|
|
|
|
|
println("Starting NTP client.");
|
|
|
|
|
NTP.begin(ntpserver);
|
|
|
|
|
NTP.waitSet([]() { print("."); }, 15000);
|
|
|
|
|
time_t now = time(nullptr);
|
|
|
|
|
println("");
|
|
|
|
|
gmtime_r(&now, &timeinfo);
|
|
|
|
|
print("Current time: ");
|
|
|
|
|
println(asctime(&timeinfo));
|
|
|
|
|
}
|
|
|
|
|
//rp2040.wdt_begin(8000);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -295,7 +293,9 @@ void setup1() {
|
|
|
|
|
void loop() {
|
|
|
|
|
/* Parse a packet and update pixels */
|
|
|
|
|
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) {
|
|
|
|
|
status = 0;
|
|
|
|
@ -322,7 +322,7 @@ void loop1() {
|
|
|
|
|
//delay(50);
|
|
|
|
|
float temp = analogReadTemp();
|
|
|
|
|
if (temp > 50.0) {
|
|
|
|
|
PRINTLNFUNC("ERROR: Overtemperature triggered!");
|
|
|
|
|
println("ERROR: Overtemperature triggered!");
|
|
|
|
|
rp2040.reboot();
|
|
|
|
|
}
|
|
|
|
|
WiFiClient client = server.available();
|
|
|
|
@ -349,7 +349,7 @@ void loop1() {
|
|
|
|
|
//delay(50);
|
|
|
|
|
float temp = analogReadTemp(); // read temp in celsius
|
|
|
|
|
if (temp > 50.0) {
|
|
|
|
|
PRINTLNFUNC("ERROR: Overtemperature triggered!");
|
|
|
|
|
println("ERROR: Overtemperature triggered!");
|
|
|
|
|
rp2040.reboot();
|
|
|
|
|
}
|
|
|
|
|
if(clientbuffer != (String) "") {
|
|
|
|
|