Skip to content

Commit 8c0592c

Browse files
authored
Merge branch 'filesystem' into mergefs-201115
2 parents c365fd9 + 0c73ecf commit 8c0592c

32 files changed

+4387
-2635
lines changed

platformio.ini

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ build_flags = -g -w -DMQTT_MAX_PACKET_SIZE=1024 -DPIO_FRAMEWORK_ARDUINO_LWIP_HIG
125125
-D DECODE_LG=true
126126

127127
build_flags_esp8266 = ${common.build_flags} -DESP8266
128-
build_flags_esp32 = ${common.build_flags} -DARDUINO_ARCH_ESP32
128+
build_flags_esp32 = ${common.build_flags} -DARDUINO_ARCH_ESP32 -DCONFIG_LITTLEFS_FOR_IDF_3_2
129129

130130
# enables all features for travis CI
131131
build_flags_all_features =
@@ -139,6 +139,8 @@ build_flags_all_features =
139139

140140
ldscript_512k = eagle.flash.512k.ld ;for older versions change this to eagle.flash.512k0.ld
141141
ldscript_1m0m = eagle.flash.1m.ld ;for older versions change this to eagle.flash.1m0.ld
142+
ldscript_1m128k = eagle.flash.1m128.ld
143+
ldscript_2m512k = eagle.flash.2m512.ld
142144
ldscript_2m1m = eagle.flash.2m1m.ld
143145
ldscript_4m1m = eagle.flash.4m1m.ld
144146
ldscript_4m3m = eagle.flash.4m3m.ld
@@ -166,19 +168,20 @@ lib_extra_dirs =
166168
lib_compat_mode = strict
167169
lib_deps =
168170
169-
170-
https://github.com/Makuna/NeoPixelBus
171+
171172
172173
ESPAsyncUDP
173174
174-
https://github.com/Aircoookie/ESPAsyncWebServer
175175
176+
https://github.com/lorol/LITTLEFS.git
177+
https://github.com/Aircoookie/ESPAsyncWebServer.git@~2.0.0
176178
#For use of the TTGO T-Display ESP32 Module with integrated TFT display uncomment the following line
177179
#TFT_eSPI
178180
#For use SSD1306 OLED display uncomment following
179181
#U8g2@~2.27.2
180182
#For Dallas sensor uncomment following 2 lines
181183
#OneWire@~2.3.5
184+
#milesburton/DallasTemperature@^3.9.0
182185
#For BME280 sensor uncomment following
183186
#BME280@~3.0.0
184187
lib_ignore =
@@ -213,7 +216,7 @@ build_flags = ${common.build_flags_esp8266} -D WLED_DISABLE_ALEXA -D WLED_DISABL
213216
[env:esp01_1m_full]
214217
board = esp01_1m
215218
platform = ${common.platform_wled_default}
216-
board_build.ldscript = ${common.ldscript_1m0m}
219+
board_build.ldscript = ${common.ldscript_1m128k}
217220
build_flags = ${common.build_flags_esp8266} -D WLED_DISABLE_OTA
218221

219222
[env:esp07]
@@ -228,6 +231,7 @@ platform = ${common.platform_wled_default}
228231
upload_speed = 921600
229232
board_build.ldscript = ${common.ldscript_4m1m}
230233
build_flags = ${common.build_flags_esp8266}
234+
monitor_filters = esp8266_exception_decoder
231235

232236
[env:heltec_wifi_kit_8]
233237
board = d1_mini
@@ -389,7 +393,7 @@ build_flags = ${common.build_flags_esp8266} ${common.debug_flags} ${common.build
389393

390394
[env:travis_esp32]
391395
extends = env:esp32dev
392-
build_type = debug
396+
; build_type = debug
393397
build_flags = ${common.build_flags_esp32} ${common.debug_flags} ${common.build_flags_all_features}
394398

395399
# ------------------------------------------------------------------------------

usermods/EXAMPLE_v2/usermod_v2_example.h

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,43 @@ class MyExampleUsermod : public Usermod {
103103
userVar0 = root["user0"] | userVar0; //if "user0" key exists in JSON, update, else keep old value
104104
//if (root["bri"] == 255) Serial.println(F("Don't burn down your garage!"));
105105
}
106-
106+
107+
108+
/*
109+
* addToConfig() can be used to add custom persistent settings to the cfg.json file in the "um" (usermod) object.
110+
* It will be called by WLED when settings are actually saved (for example, LED settings are saved)
111+
* If you want to force saving the current state, use serializeConfig() in your loop().
112+
*
113+
* CAUTION: serializeConfig() will initiate a filesystem write operation.
114+
* It might cause the LEDs to stutter and will cause flash wear if called too often.
115+
* Use it sparingly and always in the loop, never in network callbacks!
116+
*
117+
* addToConfig() will also not yet add your setting to one of the settings pages automatically.
118+
* To make that work you still have to add the setting to the HTML, xml.cpp and set.cpp manually.
119+
*
120+
* I highly recommend checking out the basics of ArduinoJson serialization and deserialization in order to use custom settings!
121+
*/
122+
void addToConfig(JsonObject& root)
123+
{
124+
JsonObject top = root.createNestedObject("exampleUsermod");
125+
top["great"] = userVar0; //save this var persistently whenever settings are saved
126+
}
127+
128+
129+
/*
130+
* readFromConfig() can be used to read back the custom settings you added with addToConfig().
131+
* This is called by WLED when settings are loaded (currently this only happens once immediately after boot)
132+
*
133+
* readFromConfig() is called BEFORE setup(). This means you can use your persistent values in setup() (e.g. pin assignments, buffer sizes),
134+
* but also that if you want to write persistent values to a dynamic buffer, you'd need to allocate it here instead of in setup.
135+
* If you don't know what that is, don't fret. It most likely doesn't affect your use case :)
136+
*/
137+
void readFromConfig(JsonObject& root)
138+
{
139+
JsonObject top = root["top"];
140+
userVar0 = top["great"] | 42; //The value right of the pipe "|" is the default value in case your setting was not present in cfg.json (e.g. first boot)
141+
}
142+
107143

108144
/*
109145
* getId() allows you to optionally give your V2 usermod an unique ID (please define it in const.h!).

wled00/FX.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2726,7 +2726,7 @@ uint16_t WS2812FX::candle(bool multi)
27262726

27272727
//max. flicker range controlled by intensity
27282728
uint8_t valrange = SEGMENT.intensity;
2729-
uint8_t rndval = valrange >> 1;
2729+
uint8_t rndval = valrange >> 1; //max 127
27302730

27312731
//step (how much to move closer to target per frame) coarsely set by speed
27322732
uint8_t speedFactor = 4;
@@ -2763,9 +2763,9 @@ uint16_t WS2812FX::candle(bool multi)
27632763
}
27642764

27652765
if (newTarget) {
2766-
s_target = random8(rndval) + random8(rndval);
2766+
s_target = random8(rndval) + random8(rndval); //between 0 and rndval*2 -2 = 252
27672767
if (s_target < (rndval >> 1)) s_target = (rndval >> 1) + random8(rndval);
2768-
uint8_t offset = (255 - valrange) >> 1;
2768+
uint8_t offset = (255 - valrange);
27692769
s_target += offset;
27702770

27712771
uint8_t dif = (s_target > s) ? s_target - s : s - s_target;

wled00/FX.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
/* each segment uses 52 bytes of SRAM memory, so if you're application fails because of
5151
insufficient memory, decreasing MAX_NUM_SEGMENTS may help */
5252
#ifdef ESP8266
53-
#define MAX_NUM_SEGMENTS 10
53+
#define MAX_NUM_SEGMENTS 12
5454
#else
55-
#define MAX_NUM_SEGMENTS 10
55+
#define MAX_NUM_SEGMENTS 16
5656
#endif
5757

5858
/* How much data bytes all segments combined may allocate */
@@ -452,6 +452,7 @@ class WS2812FX {
452452
setRange(uint16_t i, uint16_t i2, uint32_t col),
453453
setShowCallback(show_callback cb),
454454
setTransitionMode(bool t),
455+
calcGammaTable(float),
455456
trigger(void),
456457
setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t grouping = 0, uint8_t spacing = 0),
457458
resetSegments(),
@@ -485,6 +486,7 @@ class WS2812FX {
485486
//getFirstSelectedSegment(void),
486487
getMainSegmentId(void),
487488
gamma8(uint8_t),
489+
gamma8_cal(uint8_t, float),
488490
get_random_wheel_index(uint8_t);
489491

490492
int8_t

wled00/FX_fcn.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,8 +965,8 @@ void WS2812FX::setRgbwPwm(void) {
965965
void WS2812FX::setRgbwPwm() {}
966966
#endif
967967

968-
//gamma 2.4 lookup table used for color correction
969-
const byte gammaT[] = {
968+
//gamma 2.8 lookup table used for color correction
969+
byte gammaT[] = {
970970
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
971971
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
972972
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
@@ -984,6 +984,17 @@ const byte gammaT[] = {
984984
177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
985985
215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };
986986

987+
uint8_t WS2812FX::gamma8_cal(uint8_t b, float gamma) {
988+
return (int)(pow((float)b / 255.0, gamma) * 255 + 0.5);
989+
}
990+
991+
void WS2812FX::calcGammaTable(float gamma)
992+
{
993+
for (uint16_t i = 0; i < 256; i++) {
994+
gammaT[i] = gamma8_cal(i, gamma);
995+
}
996+
}
997+
987998
uint8_t WS2812FX::gamma8(uint8_t b)
988999
{
9891000
return gammaT[b];

wled00/alexa.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void onAlexaChange(EspalexaDevice* dev)
4646
bri = briLast;
4747
colorUpdated(NOTIFIER_CALL_MODE_ALEXA);
4848
}
49-
} else applyMacro(macroAlexaOn);
49+
} else applyPreset(macroAlexaOn);
5050
} else if (m == EspalexaDeviceProperty::off)
5151
{
5252
if (!macroAlexaOff)
@@ -57,7 +57,7 @@ void onAlexaChange(EspalexaDevice* dev)
5757
bri = 0;
5858
colorUpdated(NOTIFIER_CALL_MODE_ALEXA);
5959
}
60-
} else applyMacro(macroAlexaOff);
60+
} else applyPreset(macroAlexaOff);
6161
} else if (m == EspalexaDeviceProperty::bri)
6262
{
6363
bri = espalexaDevice->getValue();

wled00/button.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void shortPressAction()
1111
toggleOnOff();
1212
colorUpdated(NOTIFIER_CALL_MODE_BUTTON);
1313
} else {
14-
applyMacro(macroButton);
14+
applyPreset(macroButton);
1515
}
1616
}
1717

@@ -41,7 +41,7 @@ void handleButton()
4141
{
4242
if (!buttonLongPressed)
4343
{
44-
if (macroLongPress) {applyMacro(macroLongPress);}
44+
if (macroLongPress) {applyPreset(macroLongPress);}
4545
else _setRandomColor(false,true);
4646

4747
buttonLongPressed = true;
@@ -62,7 +62,7 @@ void handleButton()
6262
else if (!buttonLongPressed) { //short press
6363
if (macroDoublePress)
6464
{
65-
if (doublePress) applyMacro(macroDoublePress);
65+
if (doublePress) applyPreset(macroDoublePress);
6666
else buttonWaitTime = millis();
6767
} else shortPressAction();
6868
}

0 commit comments

Comments
 (0)