Added Pin Manager
This commit is contained in:
parent
aa8c587ac8
commit
0c73ecf6a8
@ -254,7 +254,7 @@ button {
|
||||
width: calc(var(--n)*100%);
|
||||
height: calc(100% - var(--tp) - var(--bh));
|
||||
margin-top: var(--tp);
|
||||
transform: translate(calc(var(--tx, 0px) + var(--i, 0)/var(--n)*-100%));
|
||||
transform: translate(calc(var(--i, 0)/var(--n)*-100%));
|
||||
overscroll-behavior: none;
|
||||
}
|
||||
|
||||
@ -511,7 +511,7 @@ input[type=range]::-moz-range-thumb {
|
||||
#picker {
|
||||
margin: 10px auto;
|
||||
width: 260px;
|
||||
filter: drop-shadow(0px 0px 1px #000);
|
||||
/*filter: drop-shadow(0px 0px 1px #000);*/
|
||||
}
|
||||
|
||||
#rgbwrap {
|
||||
@ -527,7 +527,7 @@ input[type=range]::-moz-range-thumb {
|
||||
color: var(--c-f);
|
||||
border: 0px solid white;
|
||||
border-radius: 25px;
|
||||
filter: drop-shadow(0px 0px 1px #000);
|
||||
/*filter: drop-shadow(0px 0px 1px #000);*/
|
||||
transition-duration: 0.5s;
|
||||
-webkit-backface-visibility: hidden;
|
||||
-webkit-transform:translate3d(0,0,0);
|
||||
@ -603,7 +603,7 @@ input[type=number], input[type=text] {
|
||||
padding: 8px;
|
||||
margin: 6px 6px 6px 0;
|
||||
font-size: 19px;
|
||||
transition: background 0.2s;
|
||||
transition: background-color 0.2s;
|
||||
outline: none;
|
||||
width: 50px;
|
||||
-webkit-appearance: textfield;
|
||||
@ -838,9 +838,9 @@ input[type=number]::-webkit-outer-spin-button {
|
||||
color: var(--c-f);
|
||||
border: 0px solid white;
|
||||
border-radius: 20px;
|
||||
filter: drop-shadow(0px 0px 1px #000);
|
||||
/*filter: drop-shadow(0px 0px 1px #000);*/
|
||||
text-align: left;
|
||||
transition: background 0.5s;
|
||||
transition: background-color 0.5s;
|
||||
}
|
||||
|
||||
.pres {
|
||||
@ -1122,7 +1122,7 @@ var d = document;
|
||||
const ranges = RangeTouch.setup('input[type="range"]', {});
|
||||
var pJson = {};
|
||||
var pO = null, pN = "", pI = 0;
|
||||
var pmt = 1, pmtLS = 0;
|
||||
var pmt = 1, pmtLS = 0, pmtLast = 0;
|
||||
var lastinfo = {};
|
||||
var cfg = {
|
||||
theme:{base:"dark", bg:{url:""}, alpha:{bg:0.6,tab:0.8}, color:{bg:""}},
|
||||
@ -1147,7 +1147,9 @@ var cpick = new iro.ColorPicker("#picker", {
|
||||
{
|
||||
component: iro.ui.Slider,
|
||||
options: {
|
||||
sliderType: 'kelvin'
|
||||
sliderType: 'kelvin',
|
||||
minTemperature: 2100,
|
||||
maxTemperature: 10000
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -1762,7 +1764,8 @@ function requestJson(command, rinfo = true, verbose = true) {
|
||||
type = command ? 'post':'get';
|
||||
if (command)
|
||||
{
|
||||
command.v = verbose;
|
||||
command.v = verbose;
|
||||
command.time = Math.floor(Date.now() / 1000);
|
||||
req = JSON.stringify(command);
|
||||
//console.log(req);
|
||||
}
|
||||
@ -1791,7 +1794,10 @@ function requestJson(command, rinfo = true, verbose = true) {
|
||||
if (!command || rinfo) {
|
||||
if (!rinfo) {
|
||||
pmt = json.info.fs.pmt;
|
||||
if (pmt != pmtLS || pmt == 0) setTimeout(loadPresets,99);
|
||||
if (pmt != pmtLS || pmt == 0) {
|
||||
setTimeout(loadPresets,99);
|
||||
pmtLast = pmt;
|
||||
}
|
||||
else populatePresets(true);
|
||||
var x='',y='<option value="0">Default</option>';
|
||||
json.effects.shift(); //remove solid
|
||||
@ -1820,7 +1826,10 @@ function requestJson(command, rinfo = true, verbose = true) {
|
||||
isRgbw = info.leds.wv;
|
||||
ledCount = info.leds.count;
|
||||
syncTglRecv = info.str;
|
||||
maxSeg = info.leds.maxseg;
|
||||
maxSeg = info.leds.maxseg;
|
||||
pmt = info.fs.pmt;
|
||||
if (pmt != pmtLast) setTimeout(loadPresets,99);
|
||||
pmtLast = pmt;
|
||||
lastinfo = info;
|
||||
if (isInfo) populateInfo(info);
|
||||
s = json.state;
|
||||
@ -1884,7 +1893,7 @@ function requestJson(command, rinfo = true, verbose = true) {
|
||||
})
|
||||
.catch(function (error) {
|
||||
showToast(error, true);
|
||||
console.log(error);
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
@ -2358,7 +2367,7 @@ function unfocusSliders() {
|
||||
//sliding UI
|
||||
const _C = document.querySelector('.container'), N = 4;
|
||||
|
||||
let iSlide = 0, x0 = null, y0 = null, scrollS = 0, locked = false, w;
|
||||
let iSlide = 0, x0 = null, scrollS = 0, locked = false, w;
|
||||
|
||||
function unify(e) { return e.changedTouches ? e.changedTouches[0] : e }
|
||||
|
||||
@ -2367,33 +2376,23 @@ function lock(e) {
|
||||
var l = e.target.classList;
|
||||
if (l.contains('noslide') || l.contains('iro__wheel__saturation') || l.contains('iro__slider__value') || l.contains('iro__slider')) return;
|
||||
x0 = unify(e).clientX;
|
||||
y0 = unify(e).clientY;
|
||||
scrollS = d.getElementsByClassName("tabcontent")[iSlide].scrollTop;
|
||||
|
||||
_C.classList.toggle('smooth', !(locked = true))
|
||||
}
|
||||
|
||||
function drag(e) {
|
||||
if (!locked || pcMode) return;
|
||||
if (d.getElementsByClassName("tabcontent")[iSlide].scrollTop != scrollS) {
|
||||
move(e); return;
|
||||
}
|
||||
|
||||
_C.style.setProperty('--tx', `${Math.round(unify(e).clientX - x0)}px`)
|
||||
}
|
||||
|
||||
function move(e) {
|
||||
if(!locked || pcMode) return;
|
||||
var dx = unify(e).clientX - x0, s = Math.sign(dx),
|
||||
f = +(s*dx/w).toFixed(2);
|
||||
|
||||
if((iSlide > 0 || s < 0) && (iSlide < N - 1 || s > 0) && f > .12) {
|
||||
if((iSlide > 0 || s < 0) && (iSlide < N - 1 || s > 0)
|
||||
&& f > .12
|
||||
&& d.getElementsByClassName("tabcontent")[iSlide].scrollTop == scrollS) {
|
||||
_C.style.setProperty('--i', iSlide -= s);
|
||||
f = 1 - f;
|
||||
updateTablinks(iSlide);
|
||||
}
|
||||
|
||||
_C.style.setProperty('--tx', '0px');
|
||||
_C.style.setProperty('--f', f);
|
||||
_C.classList.toggle('smooth', !(locked = false));
|
||||
x0 = null
|
||||
@ -2425,12 +2424,7 @@ function togglePcMode(fromB = false)
|
||||
d.getElementById('buttonPcm').className = (pcMode) ? "active":"";
|
||||
d.getElementById('bot').style.height = (pcMode && !cfg.comp.pcmbot) ? "0":"auto";
|
||||
sCol('--bh', d.getElementById('bot').clientHeight + "px");
|
||||
if (pcMode)
|
||||
{
|
||||
_C.style.width = '100%';
|
||||
} else {
|
||||
_C.style.width = '400%';
|
||||
}
|
||||
_C.style.width = (pcMode)?'100%':'400%';
|
||||
lastw = w;
|
||||
}
|
||||
|
||||
@ -2463,9 +2457,6 @@ window.addEventListener('resize', size, false);
|
||||
_C.addEventListener('mousedown', lock, false);
|
||||
_C.addEventListener('touchstart', lock, false);
|
||||
|
||||
_C.addEventListener('mousemove', drag, false);
|
||||
_C.addEventListener('touchmove', drag, false);
|
||||
|
||||
_C.addEventListener('mouseout', move, false);
|
||||
_C.addEventListener('mouseup', move, false);
|
||||
_C.addEventListener('touchend', move, false);
|
||||
|
@ -147,6 +147,22 @@ void setCronixie();
|
||||
void _overlayCronixie();
|
||||
void _drawOverlayCronixie();
|
||||
|
||||
//pin_manager.cpp
|
||||
class PinManagerClass {
|
||||
private:
|
||||
#ifdef ESP8266
|
||||
uint8_t pinAlloc[3] = {0x00, 0x00, 0x00}; //24bit, 1 bit per pin, we use first 17bits
|
||||
#else
|
||||
uint8_t pinAlloc[5] = {0x00, 0x00, 0x00, 0x00, 0x00}; //40bit, 1 bit per pin, we use all bits
|
||||
#endif
|
||||
|
||||
public:
|
||||
void deallocatePin(byte gpio);
|
||||
bool allocatePin(byte gpio, bool output = true);
|
||||
bool isPinAllocated(byte gpio);
|
||||
bool isPinOk(byte gpio, bool output = true);
|
||||
};
|
||||
|
||||
//playlist.cpp
|
||||
void loadPlaylist(JsonObject playlistObject);
|
||||
void handlePlaylist();
|
||||
|
@ -360,8 +360,9 @@ HTTP traffic is unencrypted. An attacker in the same network can intercept form
|
||||
href="https://github.com/Aircoookie/WLED/wiki/Contributors-&-About"
|
||||
target="_blank">Contributors, dependencies and special thanks</a><br>
|
||||
A huge thank you to everyone who helped me create WLED!<br><br>
|
||||
(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>
|
||||
<br>Server message: <span class="sip">Response error!</span><hr><button
|
||||
type="button" onclick="B()">Back</button><button type="submit">Save & Reboot
|
||||
</button></form></body></html>)=====";
|
||||
(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><br>Server message: <span class="sip">Response error!
|
||||
</span><hr><button type="button" onclick="B()">Back</button><button
|
||||
type="submit">Save & Reboot</button></form></body></html>)=====";
|
||||
|
||||
|
3356
wled00/html_ui.h
3356
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
@ -188,8 +188,12 @@ bool deserializeState(JsonObject root)
|
||||
receiveNotifications = udpn[F("recv")] | receiveNotifications;
|
||||
bool noNotification = udpn[F("nn")]; //send no notification just for this request
|
||||
|
||||
int timein = root[F("time")] | -1;
|
||||
if (timein != -1 && millis() - ntpLastSyncTime > 50000000L) setTime(timein);
|
||||
unsigned long timein = root[F("time")] | -1;
|
||||
if (timein != -1) {
|
||||
if (millis() - ntpLastSyncTime > 50000000L) setTime(timein);
|
||||
if (presetsModifiedTime == 0) presetsModifiedTime = timein;
|
||||
}
|
||||
|
||||
doReboot = root[F("rb")] | doReboot;
|
||||
|
||||
realtimeOverride = root[F("lor")] | realtimeOverride;
|
||||
|
@ -96,7 +96,7 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
|
||||
}
|
||||
} else if (strcmp(topic, "") == 0)
|
||||
{
|
||||
parseMQTTBriPayload(payload);
|
||||
parseMQTTBriPayload(payload);
|
||||
}
|
||||
}
|
||||
|
||||
|
54
wled00/pin_manager.cpp
Normal file
54
wled00/pin_manager.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#include "wled.h"
|
||||
|
||||
/*
|
||||
* Registers pins so there is no attempt for two interfaces to use the same pin
|
||||
*/
|
||||
|
||||
void PinManagerClass::deallocatePin(byte gpio)
|
||||
{
|
||||
if (!isPinOk(gpio, false)) return;
|
||||
|
||||
byte by = gpio >> 3;
|
||||
byte bi = gpio - 8*by;
|
||||
bitWrite(pinAlloc[by], bi, false);
|
||||
}
|
||||
|
||||
bool PinManagerClass::allocatePin(byte gpio, bool output)
|
||||
{
|
||||
if (!isPinOk(gpio, output)) return false;
|
||||
if (isPinAllocated(gpio)) {
|
||||
DEBUG_PRINT(F("Attempted duplicate allocation of pin "));
|
||||
DEBUG_PRINTLN(gpio);
|
||||
return false;
|
||||
}
|
||||
|
||||
byte by = gpio >> 3;
|
||||
byte bi = gpio - 8*by;
|
||||
bitWrite(pinAlloc[by], bi, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PinManagerClass::isPinAllocated(byte gpio)
|
||||
{
|
||||
if (!isPinOk(gpio, false)) return true;
|
||||
|
||||
byte by = gpio >> 3;
|
||||
byte bi = gpio - 8*by;
|
||||
return bitRead(pinAlloc[by], bi);
|
||||
}
|
||||
|
||||
bool PinManagerClass::isPinOk(byte gpio, bool output)
|
||||
{
|
||||
if (gpio < 6) return true;
|
||||
if (gpio < 12) return false; //SPI flash pins
|
||||
|
||||
#ifdef ESP8266
|
||||
if (gpio < 17) return true;
|
||||
#else //ESP32
|
||||
if (gpio < 34) return true;
|
||||
if (gpio < 40 && !output) return true; //34-39 input only
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
@ -255,6 +255,7 @@ void WLED::beginStrip()
|
||||
strip.setShowCallback(handleOverlayDraw);
|
||||
|
||||
#ifdef BTNPIN
|
||||
pinManager.allocatePin(BTNPIN, false);
|
||||
pinMode(BTNPIN, INPUT_PULLUP);
|
||||
#endif
|
||||
|
||||
@ -263,6 +264,7 @@ void WLED::beginStrip()
|
||||
|
||||
// init relay pin
|
||||
#if RLYPIN >= 0
|
||||
pinManager.allocatePin(RLYPIN);
|
||||
pinMode(RLYPIN, OUTPUT);
|
||||
#if RLYMDE
|
||||
digitalWrite(RLYPIN, bri);
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2011121
|
||||
#define VERSION 2011151
|
||||
|
||||
// ESP8266-01 (blue) got too little storage space to work with WLED. 0.10.2 is the last release supporting this unit.
|
||||
|
||||
@ -522,6 +522,8 @@ WLED_GLOBAL WS2812FX strip _INIT(WS2812FX());
|
||||
// Usermod manager
|
||||
WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
|
||||
|
||||
WLED_GLOBAL PinManagerClass pinManager _INIT(PinManagerClass());
|
||||
|
||||
// Status LED
|
||||
#if STATUSLED && STATUSLED != LEDPIN
|
||||
WLED_GLOBAL unsigned long ledStatusLastMillis _INIT(0);
|
||||
|
Loading…
Reference in New Issue
Block a user