minor improvements from upstream
* add checkSettingsPIN() and get_random_wheel_index() functions * add on/off state to UDP data * small robustness improvements
This commit is contained in:
@@ -370,9 +370,11 @@ void releaseJSONBufferLock();
|
|||||||
uint8_t extractModeName(uint8_t mode, const char *src, char *dest, uint8_t maxLen);
|
uint8_t extractModeName(uint8_t mode, const char *src, char *dest, uint8_t maxLen);
|
||||||
uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxLen, uint8_t *var = nullptr);
|
uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxLen, uint8_t *var = nullptr);
|
||||||
int16_t extractModeDefaults(uint8_t mode, const char *segVar);
|
int16_t extractModeDefaults(uint8_t mode, const char *segVar);
|
||||||
|
void checkSettingsPIN(const char *pin);
|
||||||
uint16_t __attribute__((pure)) crc16(const unsigned char* data_p, size_t length); // WLEDMM: added attribute pure
|
uint16_t __attribute__((pure)) crc16(const unsigned char* data_p, size_t length); // WLEDMM: added attribute pure
|
||||||
um_data_t* simulateSound(uint8_t simulationId);
|
um_data_t* simulateSound(uint8_t simulationId);
|
||||||
// WLEDMM enumerateLedmaps(); moved to FX.h
|
// WLEDMM enumerateLedmaps(); moved to FX.h
|
||||||
|
uint8_t get_random_wheel_index(uint8_t pos);
|
||||||
CRGB getCRGBForBand(int x, uint8_t *fftResult, int pal); //WLEDMM netmindz ar palette
|
CRGB getCRGBForBand(int x, uint8_t *fftResult, int pal); //WLEDMM netmindz ar palette
|
||||||
char *cleanUpName(char *in); // to clean up a name that was read from file
|
char *cleanUpName(char *in); // to clean up a name that was read from file
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ void stateUpdated(byte callMode) {
|
|||||||
if (stateChanged) currentPreset = 0; //something changed, so we are no longer in the preset
|
if (stateChanged) currentPreset = 0; //something changed, so we are no longer in the preset
|
||||||
|
|
||||||
if (callMode != CALL_MODE_NOTIFICATION && callMode != CALL_MODE_NO_NOTIFY) notify(callMode);
|
if (callMode != CALL_MODE_NOTIFICATION && callMode != CALL_MODE_NO_NOTIFY) notify(callMode);
|
||||||
|
if (bri != briOld && nodeBroadcastEnabled) sendSysInfoUDP(); // update on state
|
||||||
|
|
||||||
//set flag to update ws and mqtt
|
//set flag to update ws and mqtt
|
||||||
interfaceUpdateCallMode = callMode;
|
interfaceUpdateCallMode = callMode;
|
||||||
@@ -193,12 +194,15 @@ void handleTransitions()
|
|||||||
if (tper >= 1.0f)
|
if (tper >= 1.0f)
|
||||||
{
|
{
|
||||||
strip.setTransitionMode(false);
|
strip.setTransitionMode(false);
|
||||||
|
// restore (global) transition time if not called from UDP notifier or single/temporary transition from JSON (also playlist)
|
||||||
|
if (jsonTransitionOnce) strip.setTransition(transitionDelay);
|
||||||
transitionActive = false;
|
transitionActive = false;
|
||||||
|
jsonTransitionOnce = false;
|
||||||
tperLast = 0;
|
tperLast = 0;
|
||||||
applyFinalBri();
|
applyFinalBri();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tper - tperLast < 0.004) return;
|
if (tper - tperLast < 0.004f) return;
|
||||||
tperLast = tper;
|
tperLast = tper;
|
||||||
briT = briOld + ((bri - briOld) * tper);
|
briT = briOld + ((bri - briOld) * tper);
|
||||||
|
|
||||||
@@ -208,7 +212,7 @@ void handleTransitions()
|
|||||||
|
|
||||||
|
|
||||||
// legacy method, applies values from col, effectCurrent, ... to selected segments
|
// legacy method, applies values from col, effectCurrent, ... to selected segments
|
||||||
void colorUpdated(byte callMode){
|
void colorUpdated(byte callMode) {
|
||||||
applyValuesToSelectedSegs();
|
applyValuesToSelectedSegs();
|
||||||
stateUpdated(callMode);
|
stateUpdated(callMode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -712,6 +712,7 @@ void sendSysInfoUDP()
|
|||||||
#else
|
#else
|
||||||
data[38] = NODE_TYPE_ID_UNDEFINED;
|
data[38] = NODE_TYPE_ID_UNDEFINED;
|
||||||
#endif
|
#endif
|
||||||
|
if (bri) data[38] |= 0x80U; // add on/off state
|
||||||
data[39] = ip[3]; // unit ID == last IP number
|
data[39] = ip[3]; // unit ID == last IP number
|
||||||
|
|
||||||
uint32_t build = VERSION;
|
uint32_t build = VERSION;
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ bool requestJSONBufferLock(uint8_t module)
|
|||||||
{
|
{
|
||||||
unsigned long now = millis();
|
unsigned long now = millis();
|
||||||
|
|
||||||
while (jsonBufferLock && millis()-now < 1200) delay(1); // wait for fraction for buffer lock
|
while (jsonBufferLock && millis()-now < 1100) delay(1); // wait for fraction for buffer lock
|
||||||
|
|
||||||
if (jsonBufferLock) {
|
if (jsonBufferLock) {
|
||||||
USER_PRINT(F("ERROR: Locking JSON buffer failed! (still locked by "));
|
USER_PRINT(F("ERROR: Locking JSON buffer failed! (still locked by "));
|
||||||
@@ -239,9 +239,10 @@ uint8_t extractModeName(uint8_t mode, const char *src, char *dest, uint8_t maxLe
|
|||||||
{
|
{
|
||||||
if (src == JSON_mode_names || src == nullptr) {
|
if (src == JSON_mode_names || src == nullptr) {
|
||||||
if (mode < strip.getModeCount()) {
|
if (mode < strip.getModeCount()) {
|
||||||
char lineBuffer[256];
|
char lineBuffer[256] = { '\0' };
|
||||||
//strcpy_P(lineBuffer, (const char*)pgm_read_dword(&(WS2812FX::_modeData[mode])));
|
//strcpy_P(lineBuffer, (const char*)pgm_read_dword(&(WS2812FX::_modeData[mode])));
|
||||||
strcpy_P(lineBuffer, strip.getModeData(mode));
|
strncpy_P(lineBuffer, strip.getModeData(mode), sizeof(lineBuffer)/sizeof(char)-1);
|
||||||
|
lineBuffer[sizeof(lineBuffer)/sizeof(char)-1] = '\0'; // terminate string
|
||||||
size_t len = strlen(lineBuffer);
|
size_t len = strlen(lineBuffer);
|
||||||
size_t j = 0;
|
size_t j = 0;
|
||||||
for (; j < maxLen && j < len; j++) {
|
for (; j < maxLen && j < len; j++) {
|
||||||
@@ -253,6 +254,12 @@ uint8_t extractModeName(uint8_t mode, const char *src, char *dest, uint8_t maxLe
|
|||||||
} else return 0;
|
} else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (src == JSON_palette_names && mode > GRADIENT_PALETTE_COUNT) {
|
||||||
|
snprintf_P(dest, maxLen, PSTR("~ Custom %d~"), 255-mode);
|
||||||
|
dest[maxLen-1] = '\0';
|
||||||
|
return strlen(dest);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t qComma = 0;
|
uint8_t qComma = 0;
|
||||||
bool insideQuotes = false;
|
bool insideQuotes = false;
|
||||||
uint8_t printedChars = 0;
|
uint8_t printedChars = 0;
|
||||||
@@ -363,9 +370,9 @@ uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxL
|
|||||||
int16_t extractModeDefaults(uint8_t mode, const char *segVar)
|
int16_t extractModeDefaults(uint8_t mode, const char *segVar)
|
||||||
{
|
{
|
||||||
if (mode < strip.getModeCount()) {
|
if (mode < strip.getModeCount()) {
|
||||||
char lineBuffer[128] = "";
|
char lineBuffer[256] = { '\0' };
|
||||||
strncpy_P(lineBuffer, strip.getModeData(mode), 127);
|
strncpy_P(lineBuffer, strip.getModeData(mode), sizeof(lineBuffer)/sizeof(char)-1);
|
||||||
lineBuffer[127] = '\0'; // terminate string
|
lineBuffer[sizeof(lineBuffer)/sizeof(char)-1] = '\0'; // terminate string
|
||||||
if (lineBuffer[0] != 0) {
|
if (lineBuffer[0] != 0) {
|
||||||
char* startPtr = strrchr(lineBuffer, ';'); // last ";" in FX data
|
char* startPtr = strrchr(lineBuffer, ';'); // last ";" in FX data
|
||||||
if (!startPtr) return -1;
|
if (!startPtr) return -1;
|
||||||
@@ -381,6 +388,16 @@ int16_t extractModeDefaults(uint8_t mode, const char *segVar)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void checkSettingsPIN(const char* pin) {
|
||||||
|
if (!pin) return;
|
||||||
|
if (!correctPIN && millis() - lastEditTime < PIN_RETRY_COOLDOWN) return; // guard against PIN brute force
|
||||||
|
bool correctBefore = correctPIN;
|
||||||
|
correctPIN = (strlen(settingsPIN) == 0 || strncmp(settingsPIN, pin, 4) == 0);
|
||||||
|
if (correctBefore != correctPIN) createEditHandler(correctPIN);
|
||||||
|
lastEditTime = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint16_t crc16(const unsigned char* data_p, size_t length) {
|
uint16_t crc16(const unsigned char* data_p, size_t length) {
|
||||||
uint8_t x;
|
uint8_t x;
|
||||||
uint16_t crc = 0xFFFF;
|
uint16_t crc = 0xFFFF;
|
||||||
@@ -401,9 +418,9 @@ uint16_t crc16(const unsigned char* data_p, size_t length) {
|
|||||||
// (only 2 used as stored in 1 bit in segment options, consider switching to a single global simulation type)
|
// (only 2 used as stored in 1 bit in segment options, consider switching to a single global simulation type)
|
||||||
typedef enum UM_SoundSimulations {
|
typedef enum UM_SoundSimulations {
|
||||||
UMS_BeatSin = 0,
|
UMS_BeatSin = 0,
|
||||||
UMS_WeWillRockYou
|
UMS_WeWillRockYou,
|
||||||
//UMS_10_13,
|
UMS_10_13,
|
||||||
//UMS_14_3
|
UMS_14_3
|
||||||
} um_soundSimulations_t;
|
} um_soundSimulations_t;
|
||||||
|
|
||||||
um_data_t* simulateSound(uint8_t simulationId)
|
um_data_t* simulateSound(uint8_t simulationId)
|
||||||
@@ -491,7 +508,7 @@ um_data_t* simulateSound(uint8_t simulationId)
|
|||||||
fftResult[i] = 0;
|
fftResult[i] = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/*case UMS_10_3:
|
case UMS_10_13:
|
||||||
for (int i = 0; i<16; i++)
|
for (int i = 0; i<16; i++)
|
||||||
fftResult[i] = inoise8(beatsin8(90 / (i+1), 0, 200)*15 + (ms>>10), ms>>3);
|
fftResult[i] = inoise8(beatsin8(90 / (i+1), 0, 200)*15 + (ms>>10), ms>>3);
|
||||||
volumeSmth = fftResult[8];
|
volumeSmth = fftResult[8];
|
||||||
@@ -500,11 +517,11 @@ um_data_t* simulateSound(uint8_t simulationId)
|
|||||||
for (int i = 0; i<16; i++)
|
for (int i = 0; i<16; i++)
|
||||||
fftResult[i] = inoise8(beatsin8(120 / (i+1), 10, 30)*10 + (ms>>14), ms>>3);
|
fftResult[i] = inoise8(beatsin8(120 / (i+1), 10, 30)*10 + (ms>>14), ms>>3);
|
||||||
volumeSmth = fftResult[8];
|
volumeSmth = fftResult[8];
|
||||||
break;*/
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
samplePeak = random8() > 250;
|
samplePeak = random8() > 250;
|
||||||
FFT_MajorPeak = 21 + (volumeSmth*volumeSmth) / 8.0f; // WLEDMM 21hz...8200hz
|
FFT_MajorPeak = 21 + (volumeSmth*volumeSmth) / 8.0f; // walk thru full range of 21hz...8200hz
|
||||||
maxVol = 31; // this gets feedback fro UI
|
maxVol = 31; // this gets feedback fro UI
|
||||||
binNum = 8; // this gets feedback fro UI
|
binNum = 8; // this gets feedback fro UI
|
||||||
volumeRaw = volumeSmth;
|
volumeRaw = volumeSmth;
|
||||||
@@ -545,6 +562,20 @@ CRGB getCRGBForBand(int x, uint8_t *fftResult, int pal) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns a new, random color wheel index with a minimum distance of 42 from pos.
|
||||||
|
*/
|
||||||
|
uint8_t get_random_wheel_index(uint8_t pos) {
|
||||||
|
uint8_t r = 0, x = 0, y = 0, d = 0;
|
||||||
|
while (d < 42) {
|
||||||
|
r = random8();
|
||||||
|
x = abs(pos - r);
|
||||||
|
y = 255 - x;
|
||||||
|
d = MIN(x, y);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
// WLEDMM extended "trim string" function to support enumerateLedmaps
|
// WLEDMM extended "trim string" function to support enumerateLedmaps
|
||||||
// The function takes char* as input, and removes all leading and trailing "decorations" like spaces, tabs, line endings, quotes, colons
|
// The function takes char* as input, and removes all leading and trailing "decorations" like spaces, tabs, line endings, quotes, colons
|
||||||
// The conversion is "in place" (destructive).
|
// The conversion is "in place" (destructive).
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2402252
|
#define VERSION 2404090
|
||||||
|
|
||||||
// WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED.
|
// WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED.
|
||||||
#define _MoonModules_WLED_
|
#define _MoonModules_WLED_
|
||||||
|
|||||||
Reference in New Issue
Block a user