ESP32 S2 fix for RMT channels.

Ethernet pins stored in cfg.json for usermod checks.
This commit is contained in:
Blaž Kristan 2021-07-07 08:12:03 +02:00
parent 8c9fb956ff
commit d28158bc74
4 changed files with 46 additions and 9 deletions

View File

@ -665,10 +665,11 @@ class PolyBus {
uint8_t offset = 0; //0 = RMT (num 0-7) 8 = I2S0 9 = I2S1 uint8_t offset = 0; //0 = RMT (num 0-7) 8 = I2S0 9 = I2S1
#ifndef CONFIG_IDF_TARGET_ESP32S2 #ifndef CONFIG_IDF_TARGET_ESP32S2
if (num > 9) return I_NONE; if (num > 9) return I_NONE;
#else
if (num > 8) return I_NONE;
#endif
if (num > 7) offset = num -7; if (num > 7) offset = num -7;
#else
if (num > 5) return I_NONE;
if (num > 4) offset = num -4;
#endif
switch (busType) { switch (busType) {
case TYPE_WS2812_RGB: case TYPE_WS2812_RGB:
case TYPE_WS2812_WWA: case TYPE_WS2812_WWA:

View File

@ -1,4 +1,5 @@
#include "wled.h" #include "wled.h"
#include "wled_ethernet.h"
/* /*
* Serializes and parses the cfg.json and wsec.json settings files, stored in internal FS. * Serializes and parses the cfg.json and wsec.json settings files, stored in internal FS.
@ -56,6 +57,24 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
#ifdef WLED_USE_ETHERNET #ifdef WLED_USE_ETHERNET
JsonObject ethernet = doc[F("eth")]; JsonObject ethernet = doc[F("eth")];
CJSON(ethernetType, ethernet["type"]); CJSON(ethernetType, ethernet["type"]);
// allocate ethernet pins
if (ethernetType != WLED_ETH_NONE && ethernetType < WLED_NUM_ETH_TYPES) {
if (ethernetBoards[ethernetType].eth_power>=0) pinManager.allocatePin(ethernetBoards[ethernetType].eth_power);
if (ethernetBoards[ethernetType].eth_mdc>=0) pinManager.allocatePin(ethernetBoards[ethernetType].eth_mdc);
if (ethernetBoards[ethernetType].eth_mdio>=0) pinManager.allocatePin(ethernetBoards[ethernetType].eth_mdio);
switch (ethernetBoards[ethernetType].eth_clk_mode) {
case ETH_CLOCK_GPIO0_IN:
case ETH_CLOCK_GPIO0_OUT:
pinManager.allocatePin(0);
break;
case ETH_CLOCK_GPIO16_OUT:
pinManager.allocatePin(16);
break;
case ETH_CLOCK_GPIO17_OUT:
pinManager.allocatePin(17);
break;
}
}
#endif #endif
/* /*
@ -484,6 +503,24 @@ void serializeConfig() {
#ifdef WLED_USE_ETHERNET #ifdef WLED_USE_ETHERNET
JsonObject ethernet = doc.createNestedObject("eth"); JsonObject ethernet = doc.createNestedObject("eth");
ethernet["type"] = ethernetType; ethernet["type"] = ethernetType;
if (ethernetType != WLED_ETH_NONE && ethernetType < WLED_NUM_ETH_TYPES) {
JsonArray pins = ethernet.createNestedArray("pin");
if (ethernetBoards[ethernetType].eth_power>=0) pins.add(ethernetBoards[ethernetType].eth_power);
if (ethernetBoards[ethernetType].eth_mdc>=0) pins.add(ethernetBoards[ethernetType].eth_mdc);
if (ethernetBoards[ethernetType].eth_mdio>=0) pins.add(ethernetBoards[ethernetType].eth_mdio);
switch (ethernetBoards[ethernetType].eth_clk_mode) {
case ETH_CLOCK_GPIO0_IN:
case ETH_CLOCK_GPIO0_OUT:
pins.add(0);
break;
case ETH_CLOCK_GPIO16_OUT:
pins.add(16);
break;
case ETH_CLOCK_GPIO17_OUT:
pins.add(17);
break;
}
}
#endif #endif
JsonObject hw = doc.createNestedObject("hw"); JsonObject hw = doc.createNestedObject("hw");

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2107061 #define VERSION 2107071
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG

View File

@ -324,11 +324,10 @@ void getSettingsJS(byte subPage, char* dest)
#endif #endif
#ifdef WLED_USE_ETHERNET #ifdef WLED_USE_ETHERNET
if (ethernetType != WLED_ETH_NONE && ethernetType < WLED_NUM_ETH_TYPES) { if (ethernetType != WLED_ETH_NONE && ethernetType < WLED_NUM_ETH_TYPES) {
ethernet_settings es = ethernetBoards[ethernetType]; if (ethernetBoards[ethernetType].eth_power>=0) { oappend(","); oappend(itoa(ethernetBoards[ethernetType].eth_power,nS,10)); }
if (es.eth_power>0) { oappend(","); oappend(itoa(es.eth_power,nS,10)); } if (ethernetBoards[ethernetType].eth_mdc>=0) { oappend(","); oappend(itoa(ethernetBoards[ethernetType].eth_mdc,nS,10)); }
if (es.eth_mdc>0) { oappend(","); oappend(itoa(es.eth_mdc,nS,10)); } if (ethernetBoards[ethernetType].eth_mdio>=0) { oappend(","); oappend(itoa(ethernetBoards[ethernetType].eth_mdio,nS,10)); }
if (es.eth_mdio>0) { oappend(","); oappend(itoa(es.eth_mdio,nS,10)); } switch (ethernetBoards[ethernetType].eth_clk_mode) {
switch (es.eth_clk_mode) {
case ETH_CLOCK_GPIO0_IN: case ETH_CLOCK_GPIO0_IN:
case ETH_CLOCK_GPIO0_OUT: case ETH_CLOCK_GPIO0_OUT:
oappend(SET_F(",0")); oappend(SET_F(",0"));