Merge branch 'master' into dev

Added pin reservation for Ethernet.
Added SSD1305 I2C display type.
This commit is contained in:
Blaz Kristan 2021-06-20 15:13:38 +02:00
commit cd8d2c141e
12 changed files with 214 additions and 60 deletions

View File

@ -2,6 +2,14 @@
### Builds after release 0.12.0 ### Builds after release 0.12.0
#### Build 2106180
- Fixed DOS on Chrome tab restore causing reboot
#### Build 2106170
- Optimized JSON buffer usage (pre-serialized color arrays)
#### Build 2106140 #### Build 2106140
- Updated main logo - Updated main logo

12
package-lock.json generated
View File

@ -761,9 +761,9 @@
} }
}, },
"glob-parent": { "glob-parent": {
"version": "5.1.1", "version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"requires": { "requires": {
"is-glob": "^4.0.1" "is-glob": "^4.0.1"
} }
@ -1572,9 +1572,9 @@
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA=="
}, },
"normalize-url": { "normalize-url": {
"version": "4.5.0", "version": "4.5.1",
"resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz", "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.1.tgz",
"integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==" "integrity": "sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA=="
}, },
"nth-check": { "nth-check": {
"version": "1.0.2", "version": "1.0.2",

View File

@ -1,6 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags # Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000, nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000, otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x17B000, app0, app, ota_0, 0x10000, 0x180000,
app1, app, ota_1, 0x18B000,0x17B000, app1, app, ota_1, 0x190000,0x180000,
spiffs, data, spiffs, 0x306000,0x0FA000, spiffs, data, spiffs, 0x310000,0xF0000,
1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x17B000 0x180000
5 app1 app ota_1 0x18B000 0x190000 0x17B000 0x180000
6 spiffs data spiffs 0x306000 0x310000 0x0FA000 0xF0000

View File

@ -2,7 +2,7 @@
#include "wled.h" #include "wled.h"
//Pin defaults for QuinLed Dig-Uno //Pin defaults for QuinLed Dig-Uno (A0)
#define PHOTORESISTOR_PIN A0 #define PHOTORESISTOR_PIN A0
// the frequency to check photoresistor, 10 seconds // the frequency to check photoresistor, 10 seconds
@ -38,6 +38,12 @@
class Usermod_SN_Photoresistor : public Usermod class Usermod_SN_Photoresistor : public Usermod
{ {
private: private:
float referenceVoltage = USERMOD_SN_PHOTORESISTOR_REFERENCE_VOLTAGE;
float resistorValue = USERMOD_SN_PHOTORESISTOR_RESISTOR_VALUE;
float adcPrecision = USERMOD_SN_PHOTORESISTOR_ADC_PRECISION;
int8_t offset = USERMOD_SN_PHOTORESISTOR_OFFSET_VALUE;
unsigned long readingInterval = USERMOD_SN_PHOTORESISTOR_MEASUREMENT_INTERVAL;
// set last reading as "40 sec before boot", so first reading is taken after 20 sec // set last reading as "40 sec before boot", so first reading is taken after 20 sec
unsigned long lastMeasurement = UINT32_MAX - (USERMOD_SN_PHOTORESISTOR_MEASUREMENT_INTERVAL - USERMOD_SN_PHOTORESISTOR_FIRST_MEASUREMENT_AT); unsigned long lastMeasurement = UINT32_MAX - (USERMOD_SN_PHOTORESISTOR_MEASUREMENT_INTERVAL - USERMOD_SN_PHOTORESISTOR_FIRST_MEASUREMENT_AT);
// flag to indicate we have finished the first getTemperature call // flag to indicate we have finished the first getTemperature call
@ -46,6 +52,18 @@ private:
bool getLuminanceComplete = false; bool getLuminanceComplete = false;
uint16_t lastLDRValue = -1000; uint16_t lastLDRValue = -1000;
// flag set at startup
bool disabled = false;
// strings to reduce flash memory usage (used more than twice)
static const char _name[];
static const char _enabled[];
static const char _readInterval[];
static const char _referenceVoltage[];
static const char _resistorValue[];
static const char _adcPrecision[];
static const char _offset[];
bool checkBoundSensor(float newValue, float prevValue, float maxDiff) bool checkBoundSensor(float newValue, float prevValue, float maxDiff)
{ {
return isnan(prevValue) || newValue <= prevValue - maxDiff || newValue >= prevValue + maxDiff; return isnan(prevValue) || newValue <= prevValue - maxDiff || newValue >= prevValue + maxDiff;
@ -55,8 +73,8 @@ private:
{ {
// http://forum.arduino.cc/index.php?topic=37555.0 // http://forum.arduino.cc/index.php?topic=37555.0
// https://forum.arduino.cc/index.php?topic=185158.0 // https://forum.arduino.cc/index.php?topic=185158.0
float volts = analogRead(PHOTORESISTOR_PIN) * (USERMOD_SN_PHOTORESISTOR_REFERENCE_VOLTAGE / USERMOD_SN_PHOTORESISTOR_ADC_PRECISION); float volts = analogRead(PHOTORESISTOR_PIN) * (referenceVoltage / adcPrecision);
float amps = volts / USERMOD_SN_PHOTORESISTOR_RESISTOR_VALUE; float amps = volts / resistorValue;
float lux = amps * 1000000 * 2.0; float lux = amps * 1000000 * 2.0;
lastMeasurement = millis(); lastMeasurement = millis();
@ -67,23 +85,27 @@ private:
public: public:
void setup() void setup()
{ {
// set pinmode
pinMode(PHOTORESISTOR_PIN, INPUT); pinMode(PHOTORESISTOR_PIN, INPUT);
} }
void loop() void loop()
{ {
if (disabled || strip.isUpdating())
return;
unsigned long now = millis(); unsigned long now = millis();
// check to see if we are due for taking a measurement // check to see if we are due for taking a measurement
// lastMeasurement will not be updated until the conversion // lastMeasurement will not be updated until the conversion
// is complete the the reading is finished // is complete the the reading is finished
if (now - lastMeasurement < USERMOD_SN_PHOTORESISTOR_MEASUREMENT_INTERVAL) if (now - lastMeasurement < readingInterval)
{ {
return; return;
} }
uint16_t currentLDRValue = getLuminance(); uint16_t currentLDRValue = getLuminance();
if (checkBoundSensor(currentLDRValue, lastLDRValue, USERMOD_SN_PHOTORESISTOR_OFFSET_VALUE)) if (checkBoundSensor(currentLDRValue, lastLDRValue, offset))
{ {
lastLDRValue = currentLDRValue; lastLDRValue = currentLDRValue;
@ -104,7 +126,8 @@ public:
void addToJsonInfo(JsonObject &root) void addToJsonInfo(JsonObject &root)
{ {
JsonObject user = root[F("u")]; JsonObject user = root[F("u")];
if (user.isNull()) user = root.createNestedObject(F("u")); if (user.isNull())
user = root.createNestedObject(F("u"));
JsonArray lux = user.createNestedArray(F("Luminance")); JsonArray lux = user.createNestedArray(F("Luminance"));
@ -125,4 +148,63 @@ public:
{ {
return USERMOD_ID_SN_PHOTORESISTOR; return USERMOD_ID_SN_PHOTORESISTOR;
} }
/**
* addToConfig() (called from set.cpp) stores persistent properties to cfg.json
*/
void addToConfig(JsonObject &root)
{
// we add JSON object.
JsonObject top = root.createNestedObject(FPSTR(_name)); // usermodname
top[FPSTR(_enabled)] = !disabled;
top[FPSTR(_readInterval)] = readingInterval / 1000;
top[FPSTR(_referenceVoltage)] = referenceVoltage;
top[FPSTR(_resistorValue)] = resistorValue;
top[FPSTR(_adcPrecision)] = adcPrecision;
top[FPSTR(_offset)] = offset;
DEBUG_PRINTLN(F("Photoresistor config saved."));
}
/**
* readFromConfig() is called before setup() to populate properties from values stored in cfg.json
*/
void readFromConfig(JsonObject &root)
{
// we look for JSON object.
JsonObject top = root[FPSTR(_name)];
if (!top.isNull())
{
if (top[FPSTR(_enabled)].is<bool>())
{
disabled = !top[FPSTR(_enabled)].as<bool>();
}
else
{
String str = top[FPSTR(_enabled)]; // checkbox -> off or on
disabled = (bool)(str == "off"); // off is guaranteed to be present
};
readingInterval = min(120, max(10, top[FPSTR(_readInterval)].as<int>())) * 1000; // convert to ms
referenceVoltage = top[FPSTR(_referenceVoltage)].as<float>();
resistorValue = top[FPSTR(_resistorValue)].as<float>();
adcPrecision = top[FPSTR(_adcPrecision)].as<float>();
offset = top[FPSTR(_offset)].as<int>();
DEBUG_PRINTLN(F("Photoresistor config (re)loaded."));
}
else
{
DEBUG_PRINTLN(F("No config found. (Using defaults.)"));
}
}
}; };
// strings to reduce flash memory usage (used more than twice)
const char Usermod_SN_Photoresistor::_name[] PROGMEM = "Photoresistor";
const char Usermod_SN_Photoresistor::_enabled[] PROGMEM = "enabled";
const char Usermod_SN_Photoresistor::_readInterval[] PROGMEM = "read-interval-s";
const char Usermod_SN_Photoresistor::_referenceVoltage[] PROGMEM = "supplied-voltage";
const char Usermod_SN_Photoresistor::_resistorValue[] PROGMEM = "resistor-value";
const char Usermod_SN_Photoresistor::_adcPrecision[] PROGMEM = "adc-precision";
const char Usermod_SN_Photoresistor::_offset[] PROGMEM = "offset";

View File

@ -66,7 +66,9 @@ typedef enum {
NONE = 0, NONE = 0,
SSD1306, // U8X8_SSD1306_128X32_UNIVISION_HW_I2C SSD1306, // U8X8_SSD1306_128X32_UNIVISION_HW_I2C
SH1106, // U8X8_SH1106_128X64_WINSTAR_HW_I2C SH1106, // U8X8_SH1106_128X64_WINSTAR_HW_I2C
SSD1306_64 // U8X8_SSD1306_128X64_NONAME_HW_I2C SSD1306_64, // U8X8_SSD1306_128X64_NONAME_HW_I2C
SSD1305, // U8X8_SSD1305_128X32_ADAFRUIT_HW_I2C
SSD1305_64 // U8X8_SSD1305_128X64_ADAFRUIT_HW_I2C
} DisplayType; } DisplayType;
class FourLineDisplayUsermod : public Usermod { class FourLineDisplayUsermod : public Usermod {
@ -156,6 +158,22 @@ class FourLineDisplayUsermod : public Usermod {
#endif #endif
u8x8 = (U8X8 *) new U8X8_SSD1306_128X64_NONAME_HW_I2C(U8X8_PIN_NONE, sclPin, sdaPin); // Pins are Reset, SCL, SDA u8x8 = (U8X8 *) new U8X8_SSD1306_128X64_NONAME_HW_I2C(U8X8_PIN_NONE, sclPin, sdaPin); // Pins are Reset, SCL, SDA
break; break;
case SSD1305:
#ifdef ESP8266
if (!(sclPin==5 && sdaPin==4))
u8x8 = (U8X8 *) new U8X8_SSD1305_128X32_NONAME_SW_I2C(sclPin, sdaPin); // SCL, SDA, reset
else
#endif
u8x8 = (U8X8 *) new U8X8_SSD1305_128X32_ADAFRUIT_HW_I2C(U8X8_PIN_NONE, sclPin, sdaPin); // Pins are Reset, SCL, SDA
break;
case SSD1305_64:
#ifdef ESP8266
if (!(sclPin==5 && sdaPin==4))
u8x8 = (U8X8 *) new U8X8_SSD1305_128X64_ADAFRUIT_SW_I2C(sclPin, sdaPin); // SCL, SDA, reset
else
#endif
u8x8 = (U8X8 *) new U8X8_SSD1305_128X64_ADAFRUIT_HW_I2C(U8X8_PIN_NONE, sclPin, sdaPin); // Pins are Reset, SCL, SDA
break;
default: default:
u8x8 = nullptr; u8x8 = nullptr;
type = NONE; type = NONE;

View File

@ -167,13 +167,15 @@
#define BTN_TYPE_ANALOG_INVERTED 8 #define BTN_TYPE_ANALOG_INVERTED 8
//Ethernet board types //Ethernet board types
#define WLED_NUM_ETH_TYPES 5 #define WLED_NUM_ETH_TYPES 7
#define WLED_ETH_NONE 0 #define WLED_ETH_NONE 0
#define WLED_ETH_WT32_ETH01 1 #define WLED_ETH_WT32_ETH01 1
#define WLED_ETH_ESP32_POE 2 #define WLED_ETH_ESP32_POE 2
#define WLED_ETH_WESP32 3 #define WLED_ETH_WESP32 3
#define WLED_ETH_QUINLED 4 #define WLED_ETH_QUINLED 4
#define WLED_ETH_TWILIGHTLORD 5
#define WLED_ETH_ESP32DEUX 6
//Hue error codes //Hue error codes
#define HUE_ERROR_INACTIVE 0 #define HUE_ERROR_INACTIVE 0

View File

@ -70,11 +70,13 @@
<select name="ETH"> <select name="ETH">
<option value="0">None</option> <option value="0">None</option>
<option value="2">ESP32-POE</option> <option value="2">ESP32-POE</option>
<option value="6">ESP32Deux</option>
<option value="4">QuinLED-ESP32</option> <option value="4">QuinLED-ESP32</option>
<option value="4">TwilightLord-ESP32</option> <option value="5">TwilightLord-ESP32</option>
<option value="3">WESP32</option> <option value="3">WESP32</option>
<option value="1">WT32-ETH01</option> <option value="1">WT32-ETH01</option>
</select><br><br></div> </select><br><br>
</div>
<hr> <hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save & Connect</button> <button type="button" onclick="B()">Back</button><button type="submit">Save & Connect</button>
</form> </form>

View File

@ -64,11 +64,12 @@ Never (not recommended)</option></select><br>AP IP: <span class="sip">Not active
name="WS"><br><i>Can help with connectivity issues.<br> name="WS"><br><i>Can help with connectivity issues.<br>
Do not enable if WiFi is working correctly, increases power consumption.</i><div Do not enable if WiFi is working correctly, increases power consumption.</i><div
id="ethd"><h3>Ethernet Type</h3><select name="ETH"><option value="0">None id="ethd"><h3>Ethernet Type</h3><select name="ETH"><option value="0">None
</option><option value="2">ESP32-POE</option><option value="4">QuinLED-ESP32 </option><option value="2">ESP32-POE</option><option value="6">ESP32Deux
</option><option value="4">TwilightLord-ESP32</option><option value="3">WESP32 </option><option value="4">QuinLED-ESP32</option><option value="5">
</option><option value="1">WT32-ETH01</option></select><br><br></div><hr><button TwilightLord-ESP32</option><option value="3">WESP32</option><option value="1">
type="button" onclick="B()">Back</button><button type="submit">Save & Connect WT32-ETH01</option></select><br><br></div><hr><button type="button"
</button></form></body></html>)====="; onclick="B()">Back</button><button type="submit">Save & Connect</button></form>
</body></html>)=====";
// Autogenerated from wled00/data/settings_leds.htm, do not edit!! // Autogenerated from wled00/data/settings_leds.htm, do not edit!!

View File

@ -1,5 +1,6 @@
#define WLED_DEFINE_GLOBAL_VARS //only in one source file, wled.cpp! #define WLED_DEFINE_GLOBAL_VARS //only in one source file, wled.cpp!
#include "wled.h" #include "wled.h"
#include "wled_ethernet.h"
#include <Arduino.h> #include <Arduino.h>
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET) #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET)
@ -16,16 +17,6 @@ WLED::WLED()
} }
#ifdef WLED_USE_ETHERNET #ifdef WLED_USE_ETHERNET
// settings for various ethernet boards
typedef struct EthernetSettings {
uint8_t eth_address;
int eth_power;
int eth_mdc;
int eth_mdio;
eth_phy_type_t eth_type;
eth_clock_mode_t eth_clk_mode;
} ethernet_settings;
ethernet_settings ethernetBoards[] = { ethernet_settings ethernetBoards[] = {
// None // None
{ {
@ -73,6 +64,26 @@ ethernet_settings ethernetBoards[] = {
18, // eth_mdio, 18, // eth_mdio,
ETH_PHY_LAN8720, // eth_type, ETH_PHY_LAN8720, // eth_type,
ETH_CLOCK_GPIO17_OUT // eth_clk_mode ETH_CLOCK_GPIO17_OUT // eth_clk_mode
},
// TwilightLord-ESP32 Ethernet Shield
{
0, // eth_address,
5, // eth_power,
23, // eth_mdc,
18, // eth_mdio,
ETH_PHY_LAN8720, // eth_type,
ETH_CLOCK_GPIO17_OUT // eth_clk_mode
},
// ESP3DEUXQuattro
{
1, // eth_address,
-1, // eth_power,
23, // eth_mdc,
18, // eth_mdio,
ETH_PHY_LAN8720, // eth_type,
ETH_CLOCK_GPIO17_OUT // eth_clk_mode
} }
}; };
#endif #endif

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2106192 #define VERSION 2106201
//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

18
wled00/wled_ethernet.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef WLED_ETHERNET_H
#define WLED_ETHERNET_H
#ifdef WLED_USE_ETHERNET
// settings for various ethernet boards
typedef struct EthernetSettings {
uint8_t eth_address;
int eth_power;
int eth_mdc;
int eth_mdio;
eth_phy_type_t eth_type;
eth_clock_mode_t eth_clk_mode;
} ethernet_settings;
extern ethernet_settings ethernetBoards[];
#endif
#endif

View File

@ -1,4 +1,5 @@
#include "wled.h" #include "wled.h"
#include "wled_ethernet.h"
/* /*
* Sending XML status files to client * Sending XML status files to client
@ -273,16 +274,20 @@ void getSettingsJS(byte subPage, char* dest)
if (obj["pin"].is<JsonArray>()) { if (obj["pin"].is<JsonArray>()) {
JsonArray pins = obj["pin"].as<JsonArray>(); JsonArray pins = obj["pin"].as<JsonArray>();
for (JsonVariant pv : pins) { for (JsonVariant pv : pins) {
if (pv.as<int>() > -1) {
if (i++) oappend(SET_F(",")); if (i++) oappend(SET_F(","));
oappendi(pv.as<int>()); oappendi(pv.as<int>());
} }
}
} else { } else {
if (obj["pin"].as<int>() > -1) {
if (i++) oappend(SET_F(",")); if (i++) oappend(SET_F(","));
oappendi(obj["pin"].as<int>()); oappendi(obj["pin"].as<int>());
} }
} }
} }
} }
}
if (i) oappend(SET_F(",")); if (i) oappend(SET_F(","));
oappend(SET_F("6,7,8,9,10,11")); // flash memory pins oappend(SET_F("6,7,8,9,10,11")); // flash memory pins
#ifdef WLED_ENABLE_DMX #ifdef WLED_ENABLE_DMX
@ -314,18 +319,25 @@ void getSettingsJS(byte subPage, char* dest)
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM) #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
if (psramFound()) oappend(SET_F(",16,17")); // GPIO16 & GPIO17 reserved for SPI RAM if (psramFound()) oappend(SET_F(",16,17")); // GPIO16 & GPIO17 reserved for SPI RAM
#endif #endif
//TODO: add reservations for Ethernet shield pins
#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]; ethernet_settings es = ethernetBoards[ethernetType];
if (es.eth_power>0) pinManager.allocatePin(es.eth_power); if (es.eth_power>0) { oappend(","); oappend(itoa(es.eth_power,nS,10)); }
if (es.eth_mdc>0) pinManager.allocatePin(es.eth_mdc); if (es.eth_mdc>0) { oappend(","); oappend(itoa(es.eth_mdc,nS,10)); }
if (es.eth_mdio>0) pinManager.allocatePin(es.eth_mdio); if (es.eth_mdio>0) { oappend(","); oappend(itoa(es.eth_mdio,nS,10)); }
//if (es.eth_type>0) pinManager.allocatePin(es.eth_type); switch (es.eth_clk_mode) {
//if (es.eth_clk_mode>0) pinManager.allocatePin(es.eth_clk_mode); case ETH_CLOCK_GPIO0_IN:
case ETH_CLOCK_GPIO0_OUT:
oappend(SET_F(",0"));
break;
case ETH_CLOCK_GPIO16_OUT:
oappend(SET_F(",16"));
break;
case ETH_CLOCK_GPIO17_OUT:
oappend(SET_F(",17"));
break;
}
} }
*/
#endif #endif
} }
oappend(SET_F("];")); oappend(SET_F("];"));