Compare commits
5 Commits
simple-cra
...
neopixel-s
Author | SHA1 | Date | |
---|---|---|---|
d400850658 | |||
cb753616cc | |||
e0249dcadf | |||
181dcc98ca | |||
17ef48ff82 |
@ -13,7 +13,7 @@ platform = https://github.com/maxgerhardt/platform-raspberrypi.git
|
|||||||
board = pico
|
board = pico
|
||||||
framework = arduino
|
framework = arduino
|
||||||
platform_packages =
|
platform_packages =
|
||||||
framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#c64a4a58d793ee6d24c7df7ff3ec35adac3bbb45
|
framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#master
|
||||||
board_build.core = earlephilhower
|
board_build.core = earlephilhower
|
||||||
upload_port = /run/media/amelia/RPI-RP2/
|
upload_port = /run/media/amelia/RPI-RP2/
|
||||||
debug_tool = cmsis-dap
|
debug_tool = cmsis-dap
|
||||||
@ -21,7 +21,6 @@ upload_protocol = cmsis-dap
|
|||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
board_build.filesystem_size = 1m
|
board_build.filesystem_size = 1m
|
||||||
board_build.f_cpu = 133000000L
|
board_build.f_cpu = 133000000L
|
||||||
build_flags = -O3
|
|
||||||
; board_flags = -DWIFICC=CYW43_COUNTRY_USA
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/FastLED/FastLED#master
|
adafruit/Adafruit NeoPixel@^1.12.0
|
||||||
|
adafruit/Adafruit NeoPXL8@^1.2.6
|
||||||
|
52
src/FastLED_RGBW.h
Normal file
52
src/FastLED_RGBW.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/* FastLED_RGBW
|
||||||
|
*
|
||||||
|
* Hack to enable SK6812 RGBW strips to work with FastLED.
|
||||||
|
*
|
||||||
|
* Original code by Jim Bumgardner (http://krazydad.com).
|
||||||
|
* Modified by David Madison (http://partsnotincluded.com).
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef FastLED_RGBW_h
|
||||||
|
#define FastLED_RGBW_h
|
||||||
|
struct CRGBW {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
union {
|
||||||
|
uint8_t g;
|
||||||
|
uint8_t green;
|
||||||
|
};
|
||||||
|
union {
|
||||||
|
uint8_t r;
|
||||||
|
uint8_t red;
|
||||||
|
};
|
||||||
|
union {
|
||||||
|
uint8_t b;
|
||||||
|
uint8_t blue;
|
||||||
|
};
|
||||||
|
union {
|
||||||
|
uint8_t w;
|
||||||
|
uint8_t white;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
uint8_t raw[4];
|
||||||
|
};
|
||||||
|
CRGBW(){}
|
||||||
|
CRGBW(uint8_t rd, uint8_t grn, uint8_t blu, uint8_t wht){
|
||||||
|
r = rd;
|
||||||
|
g = grn;
|
||||||
|
b = blu;
|
||||||
|
w = wht;
|
||||||
|
}
|
||||||
|
inline void operator = (const CRGB c) __attribute__((always_inline)){
|
||||||
|
this->r = c.r;
|
||||||
|
this->g = c.g;
|
||||||
|
this->b = c.b;
|
||||||
|
this->white = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
inline uint16_t getRGBWsize(uint16_t nleds){
|
||||||
|
uint16_t nbytes = nleds * 4;
|
||||||
|
if(nbytes % 3 > 0) return nbytes / 3 + 1;
|
||||||
|
else return nbytes / 3;
|
||||||
|
}
|
||||||
|
#endif
|
31
src/config.h
31
src/config.h
@ -3,13 +3,20 @@
|
|||||||
|
|
||||||
#define DEBUG
|
#define DEBUG
|
||||||
|
|
||||||
// Amount of color channels per pixel - i.e. RGB = 3, RGBW = 4
|
#define LIGHTTEST
|
||||||
#define PIXEL_SIZE 3
|
|
||||||
|
|
||||||
// Total LED count
|
// Total LED count
|
||||||
// set to 128*8 for 4 channel, 170*8 for 3 channel
|
// set to 128*8 for 4 channel, 170*8 for 3 channel
|
||||||
#define MAX_LEDS 170*8
|
#define MAX_LEDS 170*8
|
||||||
|
|
||||||
|
//#define RGBW_MODE
|
||||||
|
// Amount of color channels per pixel - i.e. RGB = 3, RGBW = 4
|
||||||
|
#ifdef RGBW_MODE
|
||||||
|
#define PIXEL_SIZE 4
|
||||||
|
#else
|
||||||
|
#define PIXEL_SIZE 3
|
||||||
|
#endif
|
||||||
|
|
||||||
// LED driver chip model - depends on strip
|
// LED driver chip model - depends on strip
|
||||||
#define LED_TYPE WS2812
|
#define LED_TYPE WS2812
|
||||||
|
|
||||||
@ -24,13 +31,13 @@
|
|||||||
// Define the data pin connection to each strip
|
// Define the data pin connection to each strip
|
||||||
// 0-7 for ARGB Controller PCB
|
// 0-7 for ARGB Controller PCB
|
||||||
#define STRIP1 0
|
#define STRIP1 0
|
||||||
#define STRIP2 1
|
// #define STRIP2 1
|
||||||
#define STRIP3 2
|
// #define STRIP3 2
|
||||||
#define STRIP4 3
|
// #define STRIP4 3
|
||||||
#define STRIP5 4
|
// #define STRIP5 4
|
||||||
#define STRIP6 5
|
// #define STRIP6 5
|
||||||
#define STRIP7 6
|
// #define STRIP7 6
|
||||||
#define STRIP8 7
|
// #define STRIP8 7
|
||||||
|
|
||||||
// enable pin, if any
|
// enable pin, if any
|
||||||
// 8 on ARGB controller
|
// 8 on ARGB controller
|
||||||
@ -42,10 +49,16 @@
|
|||||||
#define ENABLE_NTP false
|
#define ENABLE_NTP false
|
||||||
#define ntpserver "pool.ntp.org" // Address of NTP server. Example: pool.ntp.org
|
#define ntpserver "pool.ntp.org" // Address of NTP server. Example: pool.ntp.org
|
||||||
|
|
||||||
|
#define TEMP_SAMPLES 32
|
||||||
|
#define AIRTEMP_PIN 28
|
||||||
|
|
||||||
// ethernet (w5500) or wifi (pico W cyw43)
|
// ethernet (w5500) or wifi (pico W cyw43)
|
||||||
#define INT_ETHERNET
|
#define INT_ETHERNET
|
||||||
//#define INT_WIFI
|
//#define INT_WIFI
|
||||||
|
|
||||||
|
#define NO_DOUBLE_BUFFER 1
|
||||||
|
#define E131_DEFAULT_PORT 5568
|
||||||
|
|
||||||
#define ETH_SPI_SPD 64000000
|
#define ETH_SPI_SPD 64000000
|
||||||
|
|
||||||
// network and universe settings
|
// network and universe settings
|
||||||
|
12
src/e131.cpp
12
src/e131.cpp
@ -57,7 +57,7 @@ void E131::initUnicast() {
|
|||||||
delay(100);
|
delay(100);
|
||||||
udp.begin(E131_DEFAULT_PORT);
|
udp.begin(E131_DEFAULT_PORT);
|
||||||
if (Serial) {
|
if (Serial) {
|
||||||
Serial.print(F("- Unicast port: "));
|
Serial.print(String(millis()/1000.0) + ": " + "- Unicast port: ");
|
||||||
Serial.println(E131_DEFAULT_PORT);
|
Serial.println(E131_DEFAULT_PORT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -268,24 +268,24 @@ void E131::beginMulticast(uint8_t *mac, uint16_t universe,
|
|||||||
void E131::dumpError(e131_error_t error) {
|
void E131::dumpError(e131_error_t error) {
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case ERROR_ACN_ID:
|
case ERROR_ACN_ID:
|
||||||
Serial.print(F("INVALID PACKET ID: "));
|
Serial.print(String(millis()/1000.0) + ": " + "INVALID PACKET ID: ");
|
||||||
for (int i = 0; i < sizeof(ACN_ID); i++)
|
for (int i = 0; i < sizeof(ACN_ID); i++)
|
||||||
Serial.print(pwbuff->acn_id[i], HEX);
|
Serial.print(pwbuff->acn_id[i], HEX);
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
break;
|
break;
|
||||||
case ERROR_PACKET_SIZE:
|
case ERROR_PACKET_SIZE:
|
||||||
Serial.println(F("INVALID PACKET SIZE: "));
|
Serial.println(String(millis()/1000.0) + ": " + "INVALID PACKET SIZE: ");
|
||||||
break;
|
break;
|
||||||
case ERROR_VECTOR_ROOT:
|
case ERROR_VECTOR_ROOT:
|
||||||
Serial.print(F("INVALID ROOT VECTOR: 0x"));
|
Serial.print(String(millis()/1000.0) + ": " + "INVALID ROOT VECTOR: 0x");
|
||||||
Serial.println(htonl(pwbuff->root_vector), HEX);
|
Serial.println(htonl(pwbuff->root_vector), HEX);
|
||||||
break;
|
break;
|
||||||
case ERROR_VECTOR_FRAME:
|
case ERROR_VECTOR_FRAME:
|
||||||
Serial.print(F("INVALID FRAME VECTOR: 0x"));
|
Serial.print(String(millis()/1000.0) + ": " + "INVALID FRAME VECTOR: 0x");
|
||||||
Serial.println(htonl(pwbuff->frame_vector), HEX);
|
Serial.println(htonl(pwbuff->frame_vector), HEX);
|
||||||
break;
|
break;
|
||||||
case ERROR_VECTOR_DMP:
|
case ERROR_VECTOR_DMP:
|
||||||
Serial.print(F("INVALID DMP VECTOR: 0x"));
|
Serial.print(String(millis()/1000.0) + ": " + "INVALID DMP VECTOR: 0x");
|
||||||
Serial.println(pwbuff->dmp_vector, HEX);
|
Serial.println(pwbuff->dmp_vector, HEX);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -41,10 +41,6 @@
|
|||||||
# define _UDP WiFiUDP
|
# define _UDP WiFiUDP
|
||||||
//# define INT_ETHERNET
|
//# define INT_ETHERNET
|
||||||
|
|
||||||
|
|
||||||
#define NO_DOUBLE_BUFFER 1
|
|
||||||
/* Defaults */
|
|
||||||
#define E131_DEFAULT_PORT 5568
|
|
||||||
#define WIFI_CONNECT_TIMEOUT 15000 /* 15 seconds */
|
#define WIFI_CONNECT_TIMEOUT 15000 /* 15 seconds */
|
||||||
|
|
||||||
/* E1.31 Packet Offsets */
|
/* E1.31 Packet Offsets */
|
||||||
|
367
src/main.cpp
367
src/main.cpp
@ -6,13 +6,15 @@
|
|||||||
#include <HTTPUpdateServer.h>
|
#include <HTTPUpdateServer.h>
|
||||||
#include <WebServer.h>
|
#include <WebServer.h>
|
||||||
#include "e131.h"
|
#include "e131.h"
|
||||||
#include <FastLED.h>
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
//#include <FastLED.h>
|
||||||
|
//#include "FastLED_RGBW.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include <pico/stdlib.h>
|
#include <pico/stdlib.h>
|
||||||
#include <hardware/vreg.h>
|
#include <hardware/vreg.h>
|
||||||
|
|
||||||
int strips[LED_STRIPS] = {170, 170, 170, 170, 170, 170, 170, 170};
|
|
||||||
// Begin code
|
// Begin code
|
||||||
bool core1_separate_stack = true;
|
bool core1_separate_stack = true;
|
||||||
|
|
||||||
@ -26,7 +28,28 @@ bool core1_separate_stack = true;
|
|||||||
|
|
||||||
int calculate[LED_STRIPS * 4];
|
int calculate[LED_STRIPS * 4];
|
||||||
int universes[LED_STRIPS * 4];
|
int universes[LED_STRIPS * 4];
|
||||||
CRGB ledstrip[MAX_LEDS];
|
|
||||||
|
|
||||||
|
Adafruit_NeoPixel *pixel1;
|
||||||
|
Adafruit_NeoPixel *pixel2;
|
||||||
|
Adafruit_NeoPixel *pixel3;
|
||||||
|
Adafruit_NeoPixel *pixel4;
|
||||||
|
Adafruit_NeoPixel *pixel5;
|
||||||
|
Adafruit_NeoPixel *pixel6;
|
||||||
|
Adafruit_NeoPixel *pixel7;
|
||||||
|
Adafruit_NeoPixel *pixel8;
|
||||||
|
const int strips[LED_STRIPS] = {170, 170, 170, 170, 170, 170, 170, 170};
|
||||||
|
int offsets[(LED_STRIPS+1)];
|
||||||
|
|
||||||
|
// #ifdef RGBW_MODE
|
||||||
|
// // EVIL! hack to support RGBW ICs
|
||||||
|
// CRGBW leds[MAX_LEDS];
|
||||||
|
// CRGB *ledstrip = (CRGB *) &leds[0]; // yes, we just casted a 4-byte value array to a pseudo 3-byte value array
|
||||||
|
// int strips[LED_STRIPS] = {getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128), getRGBWsize(128)};
|
||||||
|
// #else
|
||||||
|
// int strips[LED_STRIPS] = {170, 170, 170, 170, 170, 170, 170, 170};
|
||||||
|
// CRGB ledstrip[MAX_LEDS];
|
||||||
|
// #endif
|
||||||
int pins[8];
|
int pins[8];
|
||||||
|
|
||||||
uint8_t * livedata;
|
uint8_t * livedata;
|
||||||
@ -63,15 +86,76 @@ const uint8_t WHITE[PIXEL_SIZE]= {0x20, 0x20, 0x20};
|
|||||||
Wiznet5500lwIP eth(17, SPI, 21); //, 21); // 17 : cs, 21 : INTn
|
Wiznet5500lwIP eth(17, SPI, 21); //, 21); // 17 : cs, 21 : INTn
|
||||||
E131 e131;
|
E131 e131;
|
||||||
|
|
||||||
|
float cputemparray[TEMP_SAMPLES];
|
||||||
|
float airtemparray[TEMP_SAMPLES];
|
||||||
|
float cputemp;
|
||||||
|
float airtemp;
|
||||||
|
int datapos = 0;
|
||||||
|
|
||||||
|
inline void setpixelrgb(int idx, byte r, byte g, byte b, byte w = 0) {
|
||||||
|
if (idx < offsets[1]) {
|
||||||
|
pixel1->setPixelColor(idx - offsets[0], pixel1->Color(r,g,b,w));
|
||||||
|
}
|
||||||
|
else if (idx < offsets[2]) {
|
||||||
|
pixel2->setPixelColor(idx - offsets[1], pixel2->Color(r,g,b,w));
|
||||||
|
}
|
||||||
|
else if (idx < offsets[3]) {
|
||||||
|
pixel3->setPixelColor(idx - offsets[2], pixel3->Color(r,g,b,w));
|
||||||
|
}
|
||||||
|
else if (idx < offsets[4]) {
|
||||||
|
pixel4->setPixelColor(idx - offsets[3], pixel4->Color(r,g,b,w));
|
||||||
|
}
|
||||||
|
else if (idx < offsets[5]) {
|
||||||
|
pixel5->setPixelColor(idx - offsets[4], pixel5->Color(r,g,b,w));
|
||||||
|
}
|
||||||
|
else if (idx < offsets[6]) {
|
||||||
|
pixel6->setPixelColor(idx - offsets[5], pixel6->Color(r,g,b,w));
|
||||||
|
}
|
||||||
|
else if (idx < offsets[7]) {
|
||||||
|
pixel7->setPixelColor(idx - offsets[6], pixel7->Color(r,g,b,w));
|
||||||
|
}
|
||||||
|
else if (idx < offsets[8]) {
|
||||||
|
pixel8->setPixelColor(idx - offsets[7], pixel8->Color(r,g,b,w));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void showpixels() {
|
||||||
|
#ifdef STRIP1
|
||||||
|
pixel1->show();
|
||||||
|
#endif
|
||||||
|
#ifdef STRIP2
|
||||||
|
pixel2->show();
|
||||||
|
#endif
|
||||||
|
#ifdef STRIP3
|
||||||
|
pixel3->show();
|
||||||
|
#endif
|
||||||
|
#ifdef STRIP4
|
||||||
|
pixel4->show();
|
||||||
|
#endif
|
||||||
|
#ifdef STRIP5
|
||||||
|
pixel5->show();
|
||||||
|
#endif
|
||||||
|
#ifdef STRIP6
|
||||||
|
pixel6->show();
|
||||||
|
#endif
|
||||||
|
#ifdef STRIP7
|
||||||
|
pixel7->show();
|
||||||
|
#endif
|
||||||
|
#ifdef STRIP8
|
||||||
|
pixel8->show();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
template <class T> T print(T in) {
|
template <class T> T print(T in) {
|
||||||
Serial.print(String(in));
|
if(Serial)
|
||||||
|
Serial.print(String(millis()/1000.0) + ": " + String(in));
|
||||||
if(printer) clientbuffer += String(in);
|
if(printer) clientbuffer += String(in);
|
||||||
return (T)true;
|
return (T)true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> T println(T in) {
|
template <class T> T println(T in) {
|
||||||
Serial.println(String(in));
|
if(Serial)
|
||||||
|
Serial.println(String(millis()/1000.0) + ": " + String(in));
|
||||||
if(printer) {
|
if(printer) {
|
||||||
clientbuffer += String(in);
|
clientbuffer += String(in);
|
||||||
clientbuffer += "\n";
|
clientbuffer += "\n";
|
||||||
@ -118,7 +202,7 @@ void handleForm() {
|
|||||||
bool ipset = false;
|
bool ipset = false;
|
||||||
bool reboot = false;
|
bool reboot = false;
|
||||||
for (uint8_t i = 0; i < httpServer.args(); i++) {
|
for (uint8_t i = 0; i < httpServer.args(); i++) {
|
||||||
Serial.println(httpServer.argName(i));
|
println(httpServer.argName(i));
|
||||||
if (httpServer.argName(i) == "ipa") {
|
if (httpServer.argName(i) == "ipa") {
|
||||||
ipset = true;
|
ipset = true;
|
||||||
}
|
}
|
||||||
@ -177,9 +261,9 @@ void handleForm() {
|
|||||||
if(reboot) {
|
if(reboot) {
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
for (int i = 0; i < MAX_LEDS; i++) {
|
for (int i = 0; i < MAX_LEDS; i++) {
|
||||||
ledstrip[i] = CRGB(0, 0, 0);
|
setpixelrgb(i, 0, 0, 0);
|
||||||
}
|
}
|
||||||
FastLED.show();
|
showpixels();
|
||||||
ready = 3; // trigger core 1 to stop
|
ready = 3; // trigger core 1 to stop
|
||||||
delay(250);
|
delay(250);
|
||||||
rp2040.reboot();
|
rp2040.reboot();
|
||||||
@ -209,46 +293,53 @@ void handleNotFound() {
|
|||||||
|
|
||||||
void write_universe(long universe, uint8_t data[], long size) {
|
void write_universe(long universe, uint8_t data[], long size) {
|
||||||
// universe starts at 0
|
// universe starts at 0
|
||||||
/*PRINTFUNC("Universe: ");
|
//print("Universe: ");
|
||||||
PRINTLNFUNC(universe);
|
//Serial.println(universe);
|
||||||
PRINTFUNC("Calculate size: ");
|
//print("Calculate size: ");
|
||||||
PRINTLNFUNC(sizeof(calculate));*/
|
//Serial.println(sizeof(calculate));
|
||||||
int offset = calculate[universe];
|
int offset = calculate[universe];
|
||||||
/*PRINTFUNC("Offset: ");
|
//print("Offset: ");
|
||||||
PRINTLNFUNC(offset);
|
//Serial.println(offset);
|
||||||
PRINTFUNC("Universes size: ");
|
//print("Universes size: ");
|
||||||
PRINTLNFUNC(sizeof(universes));*/
|
//Serial.println(sizeof(universes));
|
||||||
int write_size = universes[universe];
|
int write_size = universes[universe];
|
||||||
/*PRINTFUNC("Length: ");
|
/*print("Length: ");
|
||||||
PRINTLNFUNC(write_size * PIXEL_SIZE + (CHANNEL_START - 1) + 2);
|
Serial.println(write_size * PIXEL_SIZE + (CHANNEL_START - 1) + 2);
|
||||||
PRINTFUNC("Data: ");
|
print("Data: ");
|
||||||
PRINTLNFUNC(size);*/
|
Serial.println(size);*/
|
||||||
if (write_size * PIXEL_SIZE + (CHANNEL_START - 1) + 2 > size) {
|
if (write_size * PIXEL_SIZE + (CHANNEL_START - 1) > size) {
|
||||||
println("Write size too big!!");
|
println("Write size too big!!");
|
||||||
|
println(String(write_size * PIXEL_SIZE + (CHANNEL_START - 1)) + " with data size " + String(size));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(offset + write_size > sizeof(ledstrip)) {
|
/*if(offset + write_size > sizeof(ledstrip)) {
|
||||||
println("Write size too big!!");
|
println("Write size too big!!");
|
||||||
|
println(String(offset + write_size) + " with strip size " + sizeof(ledstrip));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
//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]);
|
Serial.print(data[j]);
|
||||||
PRINTFUNC(" ");
|
Serial.print(" ");
|
||||||
PRINTFUNC(data[j+1]);
|
Serial.print(data[j+1]);
|
||||||
PRINTFUNC(" ");
|
Serial.print(" ");
|
||||||
PRINTFUNC(data[j+2]);
|
Serial.print(data[j+2]);
|
||||||
PRINTFUNC(" ");
|
Serial.print(" ");
|
||||||
}*/
|
}*/
|
||||||
ledstrip[offset + i] = CRGB(data[j], data[j+1], data[j+2]);
|
#ifdef RGBW_MODE
|
||||||
|
setpixelrgb(offset + i, data[j], data[j+1], data[j+2]);
|
||||||
|
#else
|
||||||
|
setpixelrgb(offset + i, data[j], data[j+1], data[j+2]);
|
||||||
|
#endif
|
||||||
//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]);
|
||||||
}
|
}
|
||||||
//FastLED.show();
|
//FastLED.show();
|
||||||
//status = 1;
|
//status = 1;
|
||||||
|
|
||||||
//PRINTLNFUNC("Done writing.");
|
//println("Done writing.");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -257,14 +348,18 @@ void setup() {
|
|||||||
vreg_voltage v = VREG_VOLTAGE_1_20;
|
vreg_voltage v = VREG_VOLTAGE_1_20;
|
||||||
vreg_set_voltage(v);
|
vreg_set_voltage(v);
|
||||||
set_sys_clock_khz(252000, false);
|
set_sys_clock_khz(252000, false);
|
||||||
|
pinMode(23, OUTPUT);
|
||||||
|
pinMode(23, HIGH);
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
rp2040.wdt_begin(8000);
|
//rp2040.wdt_begin(8000);
|
||||||
pinMode(24, INPUT); // VBUS detect - check for USB connection
|
//pinMode(24, INPUT); // VBUS detect - check for USB connection
|
||||||
if (digitalRead(24)) {
|
//if (digitalRead(24)) {
|
||||||
delay(3000); // Wait for serial
|
// delay(3000); // Wait for serial
|
||||||
}
|
//}
|
||||||
pinMode(21, INPUT);
|
|
||||||
println("\r\nStarting RGB Controller...");
|
pinMode(21, INPUT); // interrupt for W500
|
||||||
|
Serial.println("");
|
||||||
|
println("Starting RGB Controller...");
|
||||||
pinMode(20, OUTPUT);
|
pinMode(20, OUTPUT);
|
||||||
println("Resetting W5500 Ethernet Driver...");
|
println("Resetting W5500 Ethernet Driver...");
|
||||||
digitalWrite(20, LOW); // reset W5500 ethernet
|
digitalWrite(20, LOW); // reset W5500 ethernet
|
||||||
@ -316,6 +411,7 @@ void setup() {
|
|||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
}
|
}
|
||||||
IP_ADDR = IPAddress(EEPROM.read(0),EEPROM.read(1),EEPROM.read(2),EEPROM.read(3));
|
IP_ADDR = IPAddress(EEPROM.read(0),EEPROM.read(1),EEPROM.read(2),EEPROM.read(3));
|
||||||
|
//IP_ADDR = IPAddress(192,168,5,5);
|
||||||
if (!IP_ADDR.isSet())
|
if (!IP_ADDR.isSet())
|
||||||
ETH_MODE = "dhcp";
|
ETH_MODE = "dhcp";
|
||||||
else
|
else
|
||||||
@ -325,11 +421,11 @@ void setup() {
|
|||||||
println("Configuration loaded.");
|
println("Configuration loaded.");
|
||||||
|
|
||||||
if(ETH_MODE == "staticip") {
|
if(ETH_MODE == "staticip") {
|
||||||
Serial.println("Setting static IP");
|
println("Setting static IP...");
|
||||||
eth.config(IP_ADDR, INADDR_NONE);
|
eth.config(IP_ADDR, INADDR_NONE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Serial.println(F("Requesting Address via DHCP"));
|
println(F("Requesting Address via DHCP..."));
|
||||||
}
|
}
|
||||||
SPI.setRX(16);
|
SPI.setRX(16);
|
||||||
SPI.setCS(17);
|
SPI.setCS(17);
|
||||||
@ -343,7 +439,7 @@ void setup() {
|
|||||||
eth.setHostname(HOSTNAME);
|
eth.setHostname(HOSTNAME);
|
||||||
|
|
||||||
if (!eth.begin()) {
|
if (!eth.begin()) {
|
||||||
Serial.println("No wired Ethernet hardware detected. Check pinouts, wiring.");
|
println("No wired Ethernet hardware detected. Check pinouts, wiring.");
|
||||||
println("Connection failed. Retrying.");
|
println("Connection failed. Retrying.");
|
||||||
rp2040.reboot();
|
rp2040.reboot();
|
||||||
}
|
}
|
||||||
@ -351,14 +447,14 @@ void setup() {
|
|||||||
while (!eth.connected() && count < 32) {
|
while (!eth.connected() && count < 32) {
|
||||||
rp2040.wdt_reset();
|
rp2040.wdt_reset();
|
||||||
count++;
|
count++;
|
||||||
Serial.print(".");
|
print(".");
|
||||||
delay(250);
|
delay(250);
|
||||||
}
|
}
|
||||||
if (!eth.connected()) {
|
if (!eth.connected()) {
|
||||||
println("Connection failed. Retrying.");
|
println("Connection failed. Retrying.");
|
||||||
rp2040.reboot();
|
rp2040.reboot();
|
||||||
}
|
}
|
||||||
Serial.print(F("\r\n- IP Address: "));
|
print("- IP Address: ");
|
||||||
Serial.println(eth.localIP());
|
Serial.println(eth.localIP());
|
||||||
|
|
||||||
|
|
||||||
@ -422,28 +518,36 @@ void setup() {
|
|||||||
httpServer.begin();
|
httpServer.begin();
|
||||||
MDNS.addService("http", "tcp", 80);
|
MDNS.addService("http", "tcp", 80);
|
||||||
print("OTA Updates enabled. Open http://");
|
print("OTA Updates enabled. Open http://");
|
||||||
print(HOSTNAME);
|
Serial.print(HOSTNAME);
|
||||||
print(update_path);
|
Serial.print(update_path);
|
||||||
print(" in your browser and login with username ");
|
Serial.print(" in your browser and login with username ");
|
||||||
print(update_username);
|
Serial.print(update_username);
|
||||||
print(" and password ");
|
Serial.print(" and password ");
|
||||||
println(update_password);
|
Serial.println(update_password);
|
||||||
|
|
||||||
|
|
||||||
if(ENABLE_NTP) {
|
if(ENABLE_NTP) {
|
||||||
println("Starting NTP client.");
|
println("Starting NTP client.");
|
||||||
NTP.begin(ntpserver);
|
NTP.begin(ntpserver);
|
||||||
NTP.waitSet([]() { print("."); }, 15000);
|
NTP.waitSet([]() { Serial.print("."); }, 15000);
|
||||||
time_t now = time(nullptr);
|
time_t now = time(nullptr);
|
||||||
println("");
|
Serial.println("");
|
||||||
gmtime_r(&now, &timeinfo);
|
gmtime_r(&now, &timeinfo);
|
||||||
print("Current time: ");
|
print("Current time: ");
|
||||||
println(asctime(&timeinfo));
|
Serial.println(asctime(&timeinfo));
|
||||||
}
|
}
|
||||||
ready += 1;
|
ready += 1;
|
||||||
while (ready == 1) {
|
while (ready == 1) {
|
||||||
delay(50);
|
delay(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println("Starting temperature monitoring...");
|
||||||
|
pinMode(AIRTEMP_PIN, INPUT);
|
||||||
|
for(int i = 0; i < TEMP_SAMPLES; i++) {
|
||||||
|
cputemparray[i] = analogReadTemp();
|
||||||
|
airtemparray[i] = analogRead(AIRTEMP_PIN);
|
||||||
|
}
|
||||||
|
|
||||||
println("Startup Complete. Listening for HTTP and e1.31 (sACN) connections...");
|
println("Startup Complete. Listening for HTTP and e1.31 (sACN) connections...");
|
||||||
initinfo += clientbuffer;
|
initinfo += clientbuffer;
|
||||||
//e131.beginMulticast(ssid, passphrase, UNIVERSE);
|
//e131.beginMulticast(ssid, passphrase, UNIVERSE);
|
||||||
@ -457,6 +561,10 @@ void setup1() {
|
|||||||
pinMode(32+1, OUTPUT);
|
pinMode(32+1, OUTPUT);
|
||||||
digitalWrite(LED_BUILTIN, HIGH);
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
println("Initializing LED outputs and universe mappings...");
|
println("Initializing LED outputs and universe mappings...");
|
||||||
|
offsets[0] = 0;
|
||||||
|
for (int i = 1; i <= LED_STRIPS; i++) {
|
||||||
|
offsets[i] = offsets[i-1] + strips[i-1];
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef STRIP1
|
#ifdef STRIP1
|
||||||
pins[0] = STRIP1;
|
pins[0] = STRIP1;
|
||||||
@ -486,79 +594,99 @@ void setup1() {
|
|||||||
int offsetcount = 0;
|
int offsetcount = 0;
|
||||||
int currentsize = 0;
|
int currentsize = 0;
|
||||||
for (int i = 0; i < LED_STRIPS; i++) {
|
for (int i = 0; i < LED_STRIPS; i++) {
|
||||||
|
#ifdef RGBW_MODE
|
||||||
|
int tmp = strips[i] * 3 / 4;
|
||||||
|
#else
|
||||||
int tmp = strips[i];
|
int tmp = strips[i];
|
||||||
|
#endif
|
||||||
|
|
||||||
PRINTFUNC("Strip ");
|
print("Strip ");
|
||||||
PRINTFUNC(i);
|
Serial.print(i);
|
||||||
PRINTFUNC(", Pin ");
|
Serial.print(", Pin ");
|
||||||
PRINTFUNC(pins[i]);
|
Serial.print(pins[i]);
|
||||||
PRINTFUNC(", Light count ");
|
Serial.print(", Light count ");
|
||||||
PRINTLNFUNC(tmp);
|
Serial.println(tmp);
|
||||||
|
|
||||||
while(tmp > MAX_PIXELS_PER_UNIVERSE) {
|
while(tmp > MAX_PIXELS_PER_UNIVERSE) {
|
||||||
universes[currentsize] = MAX_PIXELS_PER_UNIVERSE;
|
universes[currentsize] = MAX_PIXELS_PER_UNIVERSE;
|
||||||
calculate[currentsize] = offsetcount;
|
calculate[currentsize] = offsetcount;
|
||||||
|
|
||||||
PRINTFUNC(" Universe ");
|
print(" Universe ");
|
||||||
PRINTFUNC(currentsize + START_UNIVERSE);
|
Serial.print(currentsize + START_UNIVERSE);
|
||||||
PRINTFUNC(", Light count ");
|
Serial.print(", Light count ");
|
||||||
PRINTFUNC(MAX_PIXELS_PER_UNIVERSE);
|
Serial.print(MAX_PIXELS_PER_UNIVERSE);
|
||||||
PRINTFUNC(", Size ");
|
Serial.print(", Size ");
|
||||||
PRINTLNFUNC(MAX_PIXELS_PER_UNIVERSE * PIXEL_SIZE);
|
Serial.print(MAX_PIXELS_PER_UNIVERSE * PIXEL_SIZE);
|
||||||
|
Serial.print(", Offset ");
|
||||||
|
Serial.println(calculate[currentsize]);
|
||||||
offsetcount += MAX_PIXELS_PER_UNIVERSE;
|
offsetcount += MAX_PIXELS_PER_UNIVERSE;
|
||||||
currentsize += 1;
|
currentsize += 1;
|
||||||
tmp -= MAX_PIXELS_PER_UNIVERSE;
|
tmp -= MAX_PIXELS_PER_UNIVERSE;
|
||||||
}
|
}
|
||||||
universes[currentsize] = tmp;
|
universes[currentsize] = tmp;
|
||||||
calculate[currentsize] = offsetcount;
|
calculate[currentsize] = offsetcount;
|
||||||
PRINTFUNC(" Universe ");
|
print(" Universe ");
|
||||||
PRINTFUNC(currentsize + START_UNIVERSE);
|
Serial.print(currentsize + START_UNIVERSE);
|
||||||
PRINTFUNC(", Light count ");
|
Serial.print(", Light count ");
|
||||||
PRINTFUNC(tmp);
|
Serial.print(tmp);
|
||||||
PRINTFUNC(", Size ");
|
Serial.print(", Size ");
|
||||||
PRINTLNFUNC(tmp * PIXEL_SIZE);
|
Serial.print(tmp * PIXEL_SIZE);
|
||||||
|
Serial.print(", Offset ");
|
||||||
|
Serial.println(calculate[currentsize]);
|
||||||
offsetcount += tmp;
|
offsetcount += tmp;
|
||||||
currentsize += 1;
|
currentsize += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STRIP1
|
#ifdef STRIP1
|
||||||
FastLED.addLeds<LED_TYPE, STRIP1, RGB_ORDER>(ledstrip, calculate[0], strips[0]);
|
pixel1 = new Adafruit_NeoPixel(strips[0], pins[0], NEO_GRB + NEO_KHZ800);
|
||||||
|
pixel1->begin();
|
||||||
#endif
|
#endif
|
||||||
#ifdef STRIP2
|
#ifdef STRIP2
|
||||||
FastLED.addLeds<LED_TYPE, STRIP2, RGB_ORDER>(ledstrip, calculate[1], strips[1]);
|
pixel2 = new Adafruit_NeoPixel(strips[1], pins[1], NEO_GRB + NEO_KHZ800);
|
||||||
|
pixel2->begin();
|
||||||
#endif
|
#endif
|
||||||
#ifdef STRIP3
|
#ifdef STRIP3
|
||||||
FastLED.addLeds<LED_TYPE, STRIP3, RGB_ORDER>(ledstrip, calculate[2], strips[2]);
|
pixel3 = new Adafruit_NeoPixel(strips[2], pins[2], NEO_GRB + NEO_KHZ800);
|
||||||
|
pixel3->begin();
|
||||||
#endif
|
#endif
|
||||||
#ifdef STRIP4
|
#ifdef STRIP4
|
||||||
FastLED.addLeds<LED_TYPE, STRIP4, RGB_ORDER>(ledstrip, calculate[3], strips[3]);
|
pixel4 = new Adafruit_NeoPixel(strips[3], pins[3], NEO_GRB + NEO_KHZ800);
|
||||||
|
pixel4->begin();
|
||||||
#endif
|
#endif
|
||||||
#ifdef STRIP5
|
#ifdef STRIP5
|
||||||
FastLED.addLeds<LED_TYPE, STRIP5, RGB_ORDER>(ledstrip, calculate[4], strips[4]);
|
pixel5 = new Adafruit_NeoPixel(strips[4], pins[4], NEO_GRB + NEO_KHZ800);
|
||||||
|
pixel5->begin();
|
||||||
#endif
|
#endif
|
||||||
#ifdef STRIP6
|
#ifdef STRIP6
|
||||||
FastLED.addLeds<LED_TYPE, STRIP6, RGB_ORDER>(ledstrip, calculate[5], strips[5]);
|
pixel6 = new Adafruit_NeoPixel(strips[5], pins[5], NEO_GRB + NEO_KHZ800);
|
||||||
|
pixel6->begin();
|
||||||
#endif
|
#endif
|
||||||
#ifdef STRIP7
|
#ifdef STRIP7
|
||||||
FastLED.addLeds<LED_TYPE, STRIP7, RGB_ORDER>(ledstrip, calculate[6], strips[6]);
|
pixel7 = new Adafruit_NeoPixel(strips[6], pins[6], NEO_GRB + NEO_KHZ800);
|
||||||
|
pixel7->begin();
|
||||||
#endif
|
#endif
|
||||||
#ifdef STRIP8
|
#ifdef STRIP8
|
||||||
FastLED.addLeds<LED_TYPE, STRIP8, RGB_ORDER>(ledstrip, calculate[7], strips[7]);
|
pixel8 = new Adafruit_NeoPixel(strips[7], pins[7], NEO_GRB + NEO_KHZ800);
|
||||||
|
pixel8->begin();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_LEDS; i++) {
|
for (int i = 0; i < MAX_LEDS; i++) {
|
||||||
ledstrip[i] = CRGB(0, 0, 0);
|
setpixelrgb(i, 0, 0, 0);
|
||||||
}
|
}
|
||||||
FastLED.show();
|
showpixels();
|
||||||
// Test all lights
|
// Test all lights
|
||||||
/*for (int i = 0; i < MAX_LEDS; i++) {
|
#ifdef LIGHTTEST
|
||||||
ledstrip[i] = CRGB(0, 0, 50);
|
for (int i = 0; i < MAX_LEDS; i++) {
|
||||||
FastLED.show();
|
setpixelrgb(i, 0, 0, 50);
|
||||||
//delay(1);
|
showpixels();
|
||||||
ledstrip[i] = CRGB(0, 0, 0);
|
delay(1);
|
||||||
|
setpixelrgb(i, 0, 0, 0);
|
||||||
}
|
}
|
||||||
FastLED.show();*/
|
showpixels();
|
||||||
|
#endif
|
||||||
//delay(3000);
|
//delay(3000);
|
||||||
|
|
||||||
ready += 1;
|
ready += 1;
|
||||||
@ -571,9 +699,13 @@ void setup1() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
/* Parse a packet */
|
/* Parse a packet */
|
||||||
//println("Start loop");
|
//println("Start loop");
|
||||||
|
if (millis() % 100 > 50) { // reset LED
|
||||||
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
|
}
|
||||||
|
|
||||||
if(channels = e131.parsePacket()) {
|
if(channels = e131.parsePacket()) {
|
||||||
// Offset by start universe
|
// Offset by start universe
|
||||||
@ -581,8 +713,8 @@ void loop() {
|
|||||||
//delay(0);
|
//delay(0);
|
||||||
livedata = e131.data;
|
livedata = e131.data;
|
||||||
status = 1;
|
status = 1;
|
||||||
delayMicroseconds(5000);
|
delayMicroseconds(3000);
|
||||||
//Serial.print(eth.isLinked());
|
//print(eth.isLinked());
|
||||||
nopackets = 0;
|
nopackets = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -590,11 +722,8 @@ void loop() {
|
|||||||
}
|
}
|
||||||
if(nopackets > 50000) {
|
if(nopackets > 50000) {
|
||||||
nopackets = 0;
|
nopackets = 0;
|
||||||
println("Resetting network");
|
println("No packets processed recently.");
|
||||||
eth.end();
|
|
||||||
delay(5);
|
delay(5);
|
||||||
eth.begin();
|
|
||||||
println("Reset network");
|
|
||||||
}
|
}
|
||||||
//println("mid loop");
|
//println("mid loop");
|
||||||
httpServer.handleClient();
|
httpServer.handleClient();
|
||||||
@ -613,7 +742,11 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop1() {
|
void loop1() {
|
||||||
rp2040.wdt_reset();
|
//rp2040.wdt_reset();
|
||||||
|
if (millis() % 100 < 50) {
|
||||||
|
//status = 0;
|
||||||
|
digitalWrite(LED_BUILTIN, LOW);
|
||||||
|
}
|
||||||
if(BOOTSEL) {
|
if(BOOTSEL) {
|
||||||
bootsel_count++;
|
bootsel_count++;
|
||||||
delay(50);
|
delay(50);
|
||||||
@ -622,7 +755,7 @@ void loop1() {
|
|||||||
bootsel_count = 0;
|
bootsel_count = 0;
|
||||||
}
|
}
|
||||||
if(bootsel_count > 60) { // 3 seconds
|
if(bootsel_count > 60) { // 3 seconds
|
||||||
Serial.print("Wiping configuration...");
|
print("Wiping configuration...");
|
||||||
digitalWrite(LED_BUILTIN, LOW);
|
digitalWrite(LED_BUILTIN, LOW);
|
||||||
delay(50);
|
delay(50);
|
||||||
for(int i = 0; i < 5; i++) { // blink 5 times to indicate wipe
|
for(int i = 0; i < 5; i++) { // blink 5 times to indicate wipe
|
||||||
@ -642,35 +775,43 @@ void loop1() {
|
|||||||
}
|
}
|
||||||
status2 = 1;
|
status2 = 1;
|
||||||
if(status == 1 && e131.universe > START_UNIVERSE - 1 && channels > 0) {
|
if(status == 1 && e131.universe > START_UNIVERSE - 1 && channels > 0) {
|
||||||
write_universe(e131.universe - START_UNIVERSE, livedata, channels);
|
write_universe(e131.universe - START_UNIVERSE - 1, livedata, channels);
|
||||||
FastLED.show();
|
showpixels();
|
||||||
//println("Done Writing");
|
//println("Done Writing");
|
||||||
status = 0;
|
status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
status2 = 0;
|
status2 = 0;
|
||||||
|
|
||||||
if (millis() % 100 > 50) { // reset LED
|
|
||||||
digitalWrite(LED_BUILTIN, HIGH);
|
|
||||||
}
|
|
||||||
else if (millis() % 100 < 50 && status == 1) {
|
|
||||||
//status = 0;
|
|
||||||
digitalWrite(LED_BUILTIN, LOW);
|
|
||||||
}
|
|
||||||
//status = 0;
|
//status = 0;
|
||||||
//delay(50);
|
//delay(50);
|
||||||
float cputemp = analogReadTemp();
|
float cputemp2 = analogReadTemp();
|
||||||
if (cputemp > 50.0) {
|
float airtemp2 = analogRead(AIRTEMP_PIN);
|
||||||
println("ERROR: Overtemperature triggered!");
|
airtemp2 = airtemp2 / 1024.0 * 3300; // voltage in mV
|
||||||
rp2040.reboot();
|
airtemp2 /= 10.0; // 10.0 mv/C
|
||||||
|
airtemp2 -= 50; // offset 500mV = 0C
|
||||||
|
|
||||||
|
cputemparray[datapos] = cputemp2;
|
||||||
|
airtemparray[datapos] = airtemp2;
|
||||||
|
if(datapos >= TEMP_SAMPLES - 1) {
|
||||||
|
datapos = 0;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
float envtemp = analogRead(28);
|
datapos++;
|
||||||
envtemp = envtemp / 1024.0 * 3300; // voltage in mV
|
}
|
||||||
envtemp /= 10.0; // 10.0 mv/C
|
cputemp2 = 0;
|
||||||
envtemp -= 50; // offset 500mV = 0C
|
airtemp2 = 0;
|
||||||
|
for (int i = 0; i < TEMP_SAMPLES; i++) {
|
||||||
|
if(i != datapos) {
|
||||||
|
cputemp2 += cputemparray[i];
|
||||||
|
airtemp2 += airtemparray[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cputemp = cputemp2 / (TEMP_SAMPLES - 1);
|
||||||
|
airtemp = airtemp2 / (TEMP_SAMPLES - 1);
|
||||||
// TODO: report temps somehow to dashboard
|
// TODO: report temps somehow to dashboard
|
||||||
|
//println("CPUTEMP " + String(cputemp) + " AIRTEMP " + String(airtemp));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user