Skip to content

Commit 0c73ecf

Browse files
committed
Added Pin Manager
1 parent aa8c587 commit 0c73ecf

File tree

9 files changed

+1790
-1722
lines changed

9 files changed

+1790
-1722
lines changed

wled00/data/index.htm

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@
254254
width: calc(var(--n)*100%);
255255
height: calc(100% - var(--tp) - var(--bh));
256256
margin-top: var(--tp);
257-
transform: translate(calc(var(--tx, 0px) + var(--i, 0)/var(--n)*-100%));
257+
transform: translate(calc(var(--i, 0)/var(--n)*-100%));
258258
overscroll-behavior: none;
259259
}
260260

@@ -511,7 +511,7 @@
511511
#picker {
512512
margin: 10px auto;
513513
width: 260px;
514-
filter: drop-shadow(0px 0px 1px #000);
514+
/*filter: drop-shadow(0px 0px 1px #000);*/
515515
}
516516

517517
#rgbwrap {
@@ -527,7 +527,7 @@
527527
color: var(--c-f);
528528
border: 0px solid white;
529529
border-radius: 25px;
530-
filter: drop-shadow(0px 0px 1px #000);
530+
/*filter: drop-shadow(0px 0px 1px #000);*/
531531
transition-duration: 0.5s;
532532
-webkit-backface-visibility: hidden;
533533
-webkit-transform:translate3d(0,0,0);
@@ -603,7 +603,7 @@
603603
padding: 8px;
604604
margin: 6px 6px 6px 0;
605605
font-size: 19px;
606-
transition: background 0.2s;
606+
transition: background-color 0.2s;
607607
outline: none;
608608
width: 50px;
609609
-webkit-appearance: textfield;
@@ -838,9 +838,9 @@
838838
color: var(--c-f);
839839
border: 0px solid white;
840840
border-radius: 20px;
841-
filter: drop-shadow(0px 0px 1px #000);
841+
/*filter: drop-shadow(0px 0px 1px #000);*/
842842
text-align: left;
843-
transition: background 0.5s;
843+
transition: background-color 0.5s;
844844
}
845845

846846
.pres {
@@ -1122,7 +1122,7 @@
11221122
const ranges = RangeTouch.setup('input[type="range"]', {});
11231123
var pJson = {};
11241124
var pO = null, pN = "", pI = 0;
1125-
var pmt = 1, pmtLS = 0;
1125+
var pmt = 1, pmtLS = 0, pmtLast = 0;
11261126
var lastinfo = {};
11271127
var cfg = {
11281128
theme:{base:"dark", bg:{url:""}, alpha:{bg:0.6,tab:0.8}, color:{bg:""}},
@@ -1147,7 +1147,9 @@
11471147
{
11481148
component: iro.ui.Slider,
11491149
options: {
1150-
sliderType: 'kelvin'
1150+
sliderType: 'kelvin',
1151+
minTemperature: 2100,
1152+
maxTemperature: 10000
11511153
}
11521154
}
11531155
]
@@ -1762,7 +1764,8 @@
17621764
type = command ? 'post':'get';
17631765
if (command)
17641766
{
1765-
command.v = verbose;
1767+
command.v = verbose;
1768+
command.time = Math.floor(Date.now() / 1000);
17661769
req = JSON.stringify(command);
17671770
//console.log(req);
17681771
}
@@ -1791,7 +1794,10 @@
17911794
if (!command || rinfo) {
17921795
if (!rinfo) {
17931796
pmt = json.info.fs.pmt;
1794-
if (pmt != pmtLS || pmt == 0) setTimeout(loadPresets,99);
1797+
if (pmt != pmtLS || pmt == 0) {
1798+
setTimeout(loadPresets,99);
1799+
pmtLast = pmt;
1800+
}
17951801
else populatePresets(true);
17961802
var x='',y='<option value="0">Default</option>';
17971803
json.effects.shift(); //remove solid
@@ -1820,7 +1826,10 @@
18201826
isRgbw = info.leds.wv;
18211827
ledCount = info.leds.count;
18221828
syncTglRecv = info.str;
1823-
maxSeg = info.leds.maxseg;
1829+
maxSeg = info.leds.maxseg;
1830+
pmt = info.fs.pmt;
1831+
if (pmt != pmtLast) setTimeout(loadPresets,99);
1832+
pmtLast = pmt;
18241833
lastinfo = info;
18251834
if (isInfo) populateInfo(info);
18261835
s = json.state;
@@ -1884,7 +1893,7 @@
18841893
})
18851894
.catch(function (error) {
18861895
showToast(error, true);
1887-
console.log(error);
1896+
console.log(error);
18881897
})
18891898
}
18901899

@@ -2358,7 +2367,7 @@
23582367
//sliding UI
23592368
const _C = document.querySelector('.container'), N = 4;
23602369

2361-
let iSlide = 0, x0 = null, y0 = null, scrollS = 0, locked = false, w;
2370+
let iSlide = 0, x0 = null, scrollS = 0, locked = false, w;
23622371

23632372
function unify(e) { return e.changedTouches ? e.changedTouches[0] : e }
23642373

@@ -2367,33 +2376,23 @@
23672376
var l = e.target.classList;
23682377
if (l.contains('noslide') || l.contains('iro__wheel__saturation') || l.contains('iro__slider__value') || l.contains('iro__slider')) return;
23692378
x0 = unify(e).clientX;
2370-
y0 = unify(e).clientY;
23712379
scrollS = d.getElementsByClassName("tabcontent")[iSlide].scrollTop;
23722380

23732381
_C.classList.toggle('smooth', !(locked = true))
23742382
}
23752383

2376-
function drag(e) {
2377-
if (!locked || pcMode) return;
2378-
if (d.getElementsByClassName("tabcontent")[iSlide].scrollTop != scrollS) {
2379-
move(e); return;
2380-
}
2381-
2382-
_C.style.setProperty('--tx', `${Math.round(unify(e).clientX - x0)}px`)
2383-
}
2384-
23852384
function move(e) {
23862385
if(!locked || pcMode) return;
23872386
var dx = unify(e).clientX - x0, s = Math.sign(dx),
23882387
f = +(s*dx/w).toFixed(2);
23892388

2390-
if((iSlide > 0 || s < 0) && (iSlide < N - 1 || s > 0) && f > .12) {
2389+
if((iSlide > 0 || s < 0) && (iSlide < N - 1 || s > 0)
2390+
&& f > .12
2391+
&& d.getElementsByClassName("tabcontent")[iSlide].scrollTop == scrollS) {
23912392
_C.style.setProperty('--i', iSlide -= s);
23922393
f = 1 - f;
23932394
updateTablinks(iSlide);
23942395
}
2395-
2396-
_C.style.setProperty('--tx', '0px');
23972396
_C.style.setProperty('--f', f);
23982397
_C.classList.toggle('smooth', !(locked = false));
23992398
x0 = null
@@ -2425,12 +2424,7 @@
24252424
d.getElementById('buttonPcm').className = (pcMode) ? "active":"";
24262425
d.getElementById('bot').style.height = (pcMode && !cfg.comp.pcmbot) ? "0":"auto";
24272426
sCol('--bh', d.getElementById('bot').clientHeight + "px");
2428-
if (pcMode)
2429-
{
2430-
_C.style.width = '100%';
2431-
} else {
2432-
_C.style.width = '400%';
2433-
}
2427+
_C.style.width = (pcMode)?'100%':'400%';
24342428
lastw = w;
24352429
}
24362430

@@ -2463,9 +2457,6 @@
24632457
_C.addEventListener('mousedown', lock, false);
24642458
_C.addEventListener('touchstart', lock, false);
24652459

2466-
_C.addEventListener('mousemove', drag, false);
2467-
_C.addEventListener('touchmove', drag, false);
2468-
24692460
_C.addEventListener('mouseout', move, false);
24702461
_C.addEventListener('mouseup', move, false);
24712462
_C.addEventListener('touchend', move, false);

wled00/fcn_declare.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,22 @@ void setCronixie();
147147
void _overlayCronixie();
148148
void _drawOverlayCronixie();
149149

150+
//pin_manager.cpp
151+
class PinManagerClass {
152+
private:
153+
#ifdef ESP8266
154+
uint8_t pinAlloc[3] = {0x00, 0x00, 0x00}; //24bit, 1 bit per pin, we use first 17bits
155+
#else
156+
uint8_t pinAlloc[5] = {0x00, 0x00, 0x00, 0x00, 0x00}; //40bit, 1 bit per pin, we use all bits
157+
#endif
158+
159+
public:
160+
void deallocatePin(byte gpio);
161+
bool allocatePin(byte gpio, bool output = true);
162+
bool isPinAllocated(byte gpio);
163+
bool isPinOk(byte gpio, bool output = true);
164+
};
165+
150166
//playlist.cpp
151167
void loadPlaylist(JsonObject playlistObject);
152168
void handlePlaylist();

wled00/html_settings.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,9 @@ HTTP traffic is unencrypted. An attacker in the same network can intercept form
360360
href="https://github.com/Aircoookie/WLED/wiki/Contributors-&-About"
361361
target="_blank">Contributors, dependencies and special thanks</a><br>
362362
A huge thank you to everyone who helped me create WLED!<br><br>
363-
(c) 2016-2020 Christian Schwinne<br><i>Licensed under the <a href="https://github.com/Aircoookie/WLED/blob/master/LICENSE" target="_blank">MIT license</a></i><br>
364-
<br>Server message: <span class="sip">Response error!</span><hr><button
365-
type="button" onclick="B()">Back</button><button type="submit">Save & Reboot
366-
</button></form></body></html>)=====";
363+
(c) 2016-2020 Christian Schwinne<br><i>Licensed under the <a
364+
href="https://github.com/Aircoookie/WLED/blob/master/LICENSE" target="_blank">
365+
MIT license</a></i><br><br>Server message: <span class="sip">Response error!
366+
</span><hr><button type="button" onclick="B()">Back</button><button
367+
type="submit">Save & Reboot</button></form></body></html>)=====";
367368

0 commit comments

Comments
 (0)