working ethernet version

simple-crash-test
Cole Deck 4 months ago
parent eb17418214
commit c6f8fdd9a2

@ -9,5 +9,6 @@
"string_view": "cpp", "string_view": "cpp",
"initializer_list": "cpp", "initializer_list": "cpp",
"ranges": "cpp" "ranges": "cpp"
} },
"C_Cpp.errorSquiggles": "disabled"
} }

@ -9,14 +9,14 @@
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
[env:pico] [env:pico]
board = rpipicow
framework = arduino
platform = https://github.com/maxgerhardt/platform-raspberrypi.git platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
framework = arduino
board_build.core = earlephilhower board_build.core = earlephilhower
upload_port = /run/media/amelia/RPI-RP2/ upload_port = /run/media/amelia/RPI-RP2/
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
board_flags = -DWIFICC=CYW43_COUNTRY_USA ; board_flags = -DWIFICC=CYW43_COUNTRY_USA
lib_deps = lib_deps =
fastled/FastLED@^3.6.0 fastled/FastLED@^3.6.0

@ -30,6 +30,10 @@ const PROGMEM byte E131::ACN_ID[12] = { 0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e
const byte E131::ACN_ID[12] = { 0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00 }; const byte E131::ACN_ID[12] = { 0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00 };
#endif #endif
Wiznet5500lwIP eth(17, SPI, 21); // 17 : cs, 21 : INTn
/* Constructor */ /* Constructor */
E131::E131() { E131::E131() {
#ifdef NO_DOUBLE_BUFFER #ifdef NO_DOUBLE_BUFFER
@ -191,24 +195,34 @@ int E131::beginMulticast(const char *ssid, const char *passphrase,
#if defined (INT_ETHERNET) #if defined (INT_ETHERNET)
/* Unicast Ethernet Initializers */ /* Unicast Ethernet Initializers */
int E131::begin(uint8_t *mac) { int E131::begin() {
int retval = 0; int retval = 0;
if (Serial) { if (Serial) {
Serial.println(""); Serial.println("");
Serial.println(F("Requesting Address via DHCP")); Serial.println(F("Requesting Address via DHCP"));
Serial.print(F("- MAC: "));
for (int i = 0; i < 6; i++)
Serial.print(mac[i], HEX);
Serial.println(""); Serial.println("");
} }
retval = Ethernet.begin(mac); SPI.setRX(16);
SPI.setCS(17);
SPI.setSCK(18);
SPI.setTX(19);
//eth.setSPISpeed(30000000);
//lwipPollingPeriod(3);
if (!eth.begin()) {
Serial.println("No wired Ethernet hardware detected. Check pinouts, wiring.");
return false;
}
while (!eth.connected()) {
Serial.print(".");
delay(500);
}
retval = eth.connected();
if (Serial) { if (Serial) {
if (retval) { if (retval) {
Serial.print(F("- IP Address: ")); Serial.print(F("\n- IP Address: "));
Serial.println(Ethernet.localIP()); Serial.println(eth.localIP());
} else { } else {
Serial.println(F("** DHCP FAILED")); Serial.println(F("** DHCP FAILED"));
} }
@ -220,31 +234,18 @@ int E131::begin(uint8_t *mac) {
return retval; return retval;
} }
void E131::begin(uint8_t *mac, IPAddress ip, IPAddress netmask,
IPAddress gateway, IPAddress dns) {
Ethernet.begin(mac, ip, dns, gateway, netmask);
if (Serial) {
Serial.println("");
Serial.println(F("Static Configuration"));
Serial.println(F("- MAC: "));
for (int i = 0; i < 6; i++)
Serial.print(mac[i], HEX);
Serial.print(F("- IP Address: "));
Serial.println(Ethernet.localIP());
}
initUnicast();
}
/* Multicast Ethernet Initializers */ /* Multicast Ethernet Initializers */
int E131::beginMulticast(uint8_t *mac, uint16_t universe, uint8_t n) { int E131::beginMulticast(uint8_t *mac, uint16_t universe, uint8_t n) {
//TODO: Add ethernet multicast support //TODO: Add ethernet multicast support
return -1;
} }
void E131::beginMulticast(uint8_t *mac, uint16_t universe, void E131::beginMulticast(uint8_t *mac, uint16_t universe,
IPAddress ip, IPAddress netmask, IPAddress gateway, IPAddress ip, IPAddress netmask, IPAddress gateway,
IPAddress dns, uint8_t n) { IPAddress dns, uint8_t n) {
//TODO: Add ethernet multicast support //TODO: Add ethernet multicast support
//return -1;
} }
#endif #endif
/****** END - Ethernet ifdef block ******/ /****** END - Ethernet ifdef block ******/

@ -26,13 +26,15 @@
#include "Arduino.h" #include "Arduino.h"
/* Network interface detection. WiFi for ESP8266 and Ethernet for AVR */ /* Network interface detection. WiFi for ESP8266 and Ethernet for AVR */
# include <WiFi.h> //# include <WiFi.h>
//# include <WiFiMulti.h> //# include <WiFiMulti.h>
//# include <WiFiUdp.h> //# include <WiFiUdp.h>
# include <W5500lwIP.h>
# include <lwip/ip_addr.h> # include <lwip/ip_addr.h>
# include <lwip/igmp.h> # include <lwip/igmp.h>
# define _UDP WiFiUDP # define _UDP WiFiUDP
# define INT_WIFI # define INT_ETHERNET
#define NO_DOUBLE_BUFFER 1 #define NO_DOUBLE_BUFFER 1
/* Defaults */ /* Defaults */
@ -179,9 +181,7 @@ class E131 {
/****** START - Ethernet ifdef block ******/ /****** START - Ethernet ifdef block ******/
#if defined (INT_ETHERNET) #if defined (INT_ETHERNET)
/* Unicast Ethernet Initializers */ /* Unicast Ethernet Initializers */
int begin(uint8_t *mac); int begin();
void begin(uint8_t *mac,
IPAddress ip, IPAddress netmask, IPAddress gateway, IPAddress dns);
/* Multicast Ethernet Initializers */ /* Multicast Ethernet Initializers */
int beginMulticast(uint8_t *mac, uint16_t universe, uint8_t n = 1); int beginMulticast(uint8_t *mac, uint16_t universe, uint8_t n = 1);

@ -1,6 +1,7 @@
// Includes // Includes
#include <WiFi.h> //#include <WiFi.h>
//#include <WiFiServer.h> //#include <WiFiServer.h>
#include <W5500lwIP.h>
#include <LEAmDNS.h> #include <LEAmDNS.h>
#include <HTTPUpdateServer.h> #include <HTTPUpdateServer.h>
#include <WebServer.h> #include <WebServer.h>
@ -9,8 +10,8 @@
// User configurable // User configurable
const char* ssid = "iPhone 14"; // WiFi SSID //const char* ssid = "iPhone 14"; // WiFi SSID
const char* password = "givemewifi"; // WiFi Password //const char* password = "givemewifi"; // WiFi Password
const char* ntpserver = "pool.ntp.org"; // Address of NTP server. Example: pool.ntp.org const char* ntpserver = "pool.ntp.org"; // Address of NTP server. Example: pool.ntp.org
const char* HOSTNAME = "lighttest"; const char* HOSTNAME = "lighttest";
@ -18,9 +19,11 @@ const char* update_path = "/firmware";
const char* update_username = "admin"; const char* update_username = "admin";
const char* update_password = "pico-stripper"; const char* update_password = "pico-stripper";
//Wiznet5500lwIP eth(1);
//#define DEBUG //#define DEBUG
// Total LED count // Total LED count
#define MAX_LEDS 50 #define MAX_LEDS 150
#define LED_TYPE WS2812B #define LED_TYPE WS2812B
// Amount of color channels per pixel - i.e. RGB = 3, RGBW = 4 // Amount of color channels per pixel - i.e. RGB = 3, RGBW = 4
@ -31,7 +34,7 @@ const char* update_password = "pico-stripper";
// Define the data pin connection to each strip // Define the data pin connection to each strip
// Only uncomment the strips you use // Only uncomment the strips you use
#define STRIP1 28 #define STRIP1 0
//#define STRIP2 0 //#define STRIP2 0
//#define STRIP3 2 //#define STRIP3 2
//#define STRIP4 3 //#define STRIP4 3
@ -43,7 +46,7 @@ const char* update_password = "pico-stripper";
#define RGB_ORDER RGB #define RGB_ORDER RGB
// define how many LEDs / zones are in each strip // define how many LEDs / zones are in each strip
int strips[LED_STRIPS] = {50}; int strips[LED_STRIPS] = {150};
// Begin code // Begin code
@ -141,13 +144,25 @@ void write_universe(int universe, uint8_t data[]) {
} }
void setup() { void setup() {
pinMode(22, OUTPUT); pinMode(20, OUTPUT);
digitalWrite(22, LOW); // Enable buffer output! digitalWrite(20, LOW); // reset W5500
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(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 ========="); PRINTLNFUNC("========= PicoLighter v1.0 Initializing =========");
if (!e131.begin()) {
PRINTFUNC("Connection failed. Retrying.");
rp2040.reboot();
}
while (ready == 0) { while (ready == 0) {
delay(100); delay(100);
} }
@ -236,17 +251,17 @@ 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(130, 130, 130); ledstrip[i] = CRGB(50, 50, 50);
FastLED.show(); FastLED.show();
delay(30); delay(30);
ledstrip[i] = CRGB(0, 0, 0); ledstrip[i] = CRGB(0, 0, 0);
} }
FastLED.show(); FastLED.show();
delay(3000); delay(3000);
WiFi.noLowPowerMode(); // WiFi.noLowPowerMode();
if (e131.begin(ssid, password) != WL_CONNECTED) { ready = 1;
PRINTFUNC("Connection failed. Retrying."); while (ready == 1) {
rp2040.reboot(); delay(100);
} }
PRINTLNFUNC("Starting mDNS client."); PRINTLNFUNC("Starting mDNS client.");
MDNS.begin(HOSTNAME); MDNS.begin(HOSTNAME);
@ -261,10 +276,7 @@ void setup1() {
PRINTFUNC(" and password "); PRINTFUNC(" and password ");
PRINTLNFUNC(update_password); PRINTLNFUNC(update_password);
server.begin(); server.begin();
ready = 1;
while (ready == 1) {
delay(100);
}
// If we get here, then WiFi is good to go // If we get here, then WiFi is good to go
PRINTFUNC("Starting NTP client."); PRINTFUNC("Starting NTP client.");
NTP.begin(ntpserver); NTP.begin(ntpserver);

Loading…
Cancel
Save