Skip to content

Commit bd7cd32

Browse files
committed
Add mandatory refresh capability to remove type dependency.
1 parent 9cb3531 commit bd7cd32

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

wled00/bus_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ static String LEDTypesToJson(const std::vector<LEDType>& types) {
830830
String json;
831831
for (const auto &type : types) {
832832
// capabilities follows similar pattern as JSON API
833-
int capabilities = Bus::hasRGB(type.id) | Bus::hasWhite(type.id)<<1 | Bus::hasCCT(type.id)<<2 | Bus::is16bit(type.id)<<4;
833+
int capabilities = Bus::hasRGB(type.id) | Bus::hasWhite(type.id)<<1 | Bus::hasCCT(type.id)<<2 | Bus::is16bit(type.id)<<4 | Bus::mustRefresh(type.id)<<5;
834834
char str[256];
835835
sprintf_P(str, PSTR("{i:%d,c:%d,t:\"%s\",n:\"%s\"},"), type.id, capabilities, type.type, type.name);
836836
json += str;

wled00/bus_manager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class Bus {
104104
inline bool isPWM() const { return isPWM(_type); }
105105
inline bool isVirtual() const { return isVirtual(_type); }
106106
inline bool is16bit() const { return is16bit(_type); }
107+
inline bool mustRefresh() const { return mustRefresh(_type); }
107108
inline void setReversed(bool reversed) { _reversed = reversed; }
108109
inline void setStart(uint16_t start) { _start = start; }
109110
inline void setAutoWhiteMode(uint8_t m) { if (m < 5) _autoWhiteMode = m; }
@@ -142,6 +143,7 @@ class Bus {
142143
static constexpr bool isPWM(uint8_t type) { return (type >= TYPE_ANALOG_MIN && type <= TYPE_ANALOG_MAX); }
143144
static constexpr bool isVirtual(uint8_t type) { return (type >= TYPE_VIRTUAL_MIN && type <= TYPE_VIRTUAL_MAX); }
144145
static constexpr bool is16bit(uint8_t type) { return type == TYPE_UCS8903 || type == TYPE_UCS8904 || type == TYPE_SM16825; }
146+
static constexpr bool mustRefresh(uint8_t type) { return type == TYPE_TM1814; }
145147
static constexpr int numPWMPins(uint8_t type) { return (type - 40); }
146148

147149
static inline int16_t getCCT() { return _cct; }

wled00/data/settings_leds.htm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
function hasW(t) { return !!(gT(t).c & 0x02); } // has white channel
2323
function hasCCT(t) { return !!(gT(t).c & 0x04); } // is white CCT enabled
2424
function is16b(t) { return !!(gT(t).c & 0x10); } // is digital 16 bit type
25+
function mustR(t) { return !!(gT(t).c & 0x20); } // Off refresh is mandatory
2526
function numPins(t){ return Math.max(gT(t).t.length, 1); } // type length determines number of GPIO pins
2627
function S() {
2728
getLoc();
@@ -255,7 +256,7 @@
255256
d.Sf["LA"+n].min = (isVir(t) || isAna(t)) ? 0 : 1;
256257
d.Sf["MA"+n].min = (isVir(t) || isAna(t)) ? 0 : 250;
257258
}
258-
gId("rf"+n).onclick = (t == 31) ? (()=>{return false}) : (()=>{}); // prevent change for TM1814
259+
gId("rf"+n).onclick = mustR(t) ? (()=>{return false}) : (()=>{}); // prevent change change of "Refresh" checkmark when mandatory
259260
gRGBW |= hasW(t); // RGBW checkbox
260261
gId("co"+n).style.display = (isVir(t) || isAna(t)) ? "none":"inline"; // hide color order for PWM
261262
gId("dig"+n+"w").style.display = (isDig(t) && hasW(t)) ? "inline":"none"; // show swap channels dropdown
@@ -457,9 +458,9 @@
457458
});
458459
// disable inappropriate LED types
459460
let sel = d.getElementsByName("LT"+s)[0]
460-
if (i >= maxB || digitalB >= maxD) disable(sel,'option[data-type="D"]');
461-
if (i >= maxB || twopinB >= 1) disable(sel,'option[data-type="2P"]');
462-
disable(sel,`option[data-type^="${'A'.repeat(maxA-analogB+1)}"]`);
461+
if (i >= maxB || digitalB >= maxD) disable(sel,'option[data-type="D"]'); // NOTE: see isDig()
462+
if (i >= maxB || twopinB >= 1) disable(sel,'option[data-type="2P"]'); // NOTE: see isD2P()
463+
disable(sel,`option[data-type^="${'A'.repeat(maxA-analogB+1)}"]`); // NOTE: see isPWM()
463464
sel.selectedIndex = sel.querySelector('option:not(:disabled)').index;
464465
}
465466
if (n==-1) {

0 commit comments

Comments
 (0)