implement button on/off
This commit is contained in:
parent
d01877d32b
commit
d190964b95
4
TODO.txt
4
TODO.txt
@ -1,11 +1,9 @@
|
||||
color cycle
|
||||
sequence
|
||||
simple slide transition
|
||||
add toolbar conf in settings
|
||||
additional color picker field
|
||||
implement all settings setters
|
||||
implement OTA lock / security
|
||||
implement button
|
||||
implement HSB slider option
|
||||
implement ranges
|
||||
implement discrete range color setter
|
||||
@ -15,7 +13,9 @@ svg icons in html
|
||||
notifier function -> send get request
|
||||
nightlight function -> turns off after set time (+implement fading)
|
||||
(replace StrContains and num functions)
|
||||
add preferred colors to settings -> quickly t. UI, button select,
|
||||
|
||||
BUGS
|
||||
static ip disables mdns
|
||||
XXX authentification for security relevant areas (/edit, /update (!!!), /list, /down, [/settings, /reset, /cleareeprom])
|
||||
(Unverified) led_amount does nothing (is always 16) because NeoPixelBus is initiated before EEPROM read
|
||||
|
@ -64,6 +64,10 @@
|
||||
{
|
||||
window.open("/settings","_self");
|
||||
}
|
||||
function ToggleNightMode()
|
||||
{
|
||||
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.ctrl_box {
|
||||
@ -118,9 +122,9 @@
|
||||
.tool_box {
|
||||
|
||||
}
|
||||
.settingsbutton {
|
||||
width: 1.5cm;
|
||||
height: 1.5cm;
|
||||
input[type=image] {
|
||||
width: 10vmin;
|
||||
height: 10vmin;
|
||||
margin-top: 4px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
@ -184,6 +188,7 @@
|
||||
<body onload="Startup()" class=" __plain_text_READY__">
|
||||
<div id="tbB" class="tool_box">
|
||||
<input type="image" class="settingsbutton" src="/button.png" onclick="OpenSettings()"id="tool">
|
||||
<input type="image" class="nightbutton" src="/moon.png" onclick="ToggleNightMode()"id="night">
|
||||
</div>
|
||||
<div id="cdB" class="ctrl_box">
|
||||
<form id="form_c" name="Ctrl_form">
|
||||
|
BIN
wled00/data/moon.png
Normal file
BIN
wled00/data/moon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
@ -32,7 +32,7 @@
|
||||
document.S_form.APPASS.value = this.responseXML.getElementsByTagName('appass')[0].innerHTML; //fake pass like ******
|
||||
document.S_form.APCHAN.value = this.responseXML.getElementsByTagName('apchan')[0].innerHTML;
|
||||
document.S_form.LEDS.value = this.responseXML.getElementsByTagName('leds')[0].innerHTML;
|
||||
document.S_form.BTNP.value = this.responseXML.getElementsByTagName('btnp')[0].innerHTML;
|
||||
document.S_form.BTNON.checked = (this.responseXML.getElementsByTagName('btnon')[0].innerHTML)!=0?true:false;
|
||||
document.S_form.TFADE.checked = (this.responseXML.getElementsByTagName('tfade')[0].innerHTML)!=0?true:false;
|
||||
document.S_form.TDLAY.value = this.responseXML.getElementsByTagName('tdlay')[0].innerHTML;
|
||||
document.S_form.NOOTA.checked = (this.responseXML.getElementsByTagName('noota')[0].innerHTML)!=0?true:false;
|
||||
@ -100,8 +100,7 @@
|
||||
The default boot LED color is the current color when settings are saved. <br>
|
||||
LED amount: <input type="text" name="LEDS" maxlength="3" size="2"> <br>
|
||||
<h3>Button setup</h3>
|
||||
Button pin: <input type="text" name="BTNP" maxlength="2" size="2"> <br>
|
||||
Button function: Toggle on/off <br>
|
||||
On/Off button enabled: <input type="checkbox" name="BTNON" value="0"> <br>
|
||||
<h3>Transitions</h3>
|
||||
Fade: <input type="checkbox" name="TFADE" value="0"> <br>
|
||||
Transition Delay: <input type="text" name="TDLAY" maxlength="5" size="2"> ms <br>
|
||||
|
@ -32,6 +32,8 @@ uint16_t transitionDelay = 1500;
|
||||
boolean ota_lock = false;
|
||||
boolean only_ap = false;
|
||||
int led_amount = 16;
|
||||
int buttonPin = 3; //needs pull-up
|
||||
boolean buttonEnabled = true;
|
||||
|
||||
//Internal vars
|
||||
byte col_old[]{0, 0, 0};
|
||||
@ -40,7 +42,9 @@ long transitionStartTime;
|
||||
byte bri = 127;
|
||||
byte bri_old = 0;
|
||||
byte bri_t = 0;
|
||||
byte bri_last = 127;
|
||||
boolean transitionActive = false;
|
||||
boolean buttonPressedBefore = false;
|
||||
|
||||
NeoPixelBus<NeoGrbFeature, NeoEsp8266Uart800KbpsMethod> strip(led_amount, 1);
|
||||
|
||||
@ -106,6 +110,7 @@ void saveSettingsToEEPROM()
|
||||
EEPROM.write(228, aphide);
|
||||
EEPROM.write(227, apchannel);
|
||||
EEPROM.write(229, led_amount);
|
||||
EEPROM.write(232, buttonEnabled);
|
||||
EEPROM.write(234, staticip[0]);
|
||||
EEPROM.write(235, staticip[1]);
|
||||
EEPROM.write(236, staticip[2]);
|
||||
@ -170,6 +175,7 @@ void loadSettingsFromEEPROM()
|
||||
apchannel = EEPROM.read(227);
|
||||
if (apchannel > 13 || apchannel < 1) apchannel = 1;
|
||||
led_amount = EEPROM.read(229);
|
||||
buttonEnabled = EEPROM.read(232);
|
||||
staticip[0] = EEPROM.read(234);
|
||||
staticip[1] = EEPROM.read(235);
|
||||
staticip[2] = EEPROM.read(236);
|
||||
@ -269,13 +275,14 @@ void XML_response_settings()
|
||||
resp = resp + "</apchan>";
|
||||
resp = resp + "<leds>";
|
||||
resp = resp + led_amount;
|
||||
resp = resp + "</leds>";
|
||||
resp = resp + "<btnp>0</btnp>"; //NI
|
||||
resp = resp + "<tfade>";
|
||||
resp = resp + "</leds><tfade>";
|
||||
resp = resp + bool2int(fadeTransition);
|
||||
resp = resp + "</tfade><tdlay>";
|
||||
resp = resp + transitionDelay;
|
||||
resp = resp + "</tdlay><noota>0</noota>"; //NI
|
||||
resp = resp + "</tdlay>";
|
||||
resp = resp + "<btnon>";
|
||||
resp = resp + bool2int(buttonEnabled);
|
||||
resp = resp + "</btnon><noota>0</noota>"; //NI
|
||||
resp = resp + "<norap>0</norap>"; //NI
|
||||
resp = resp + "<sip>";
|
||||
if (!WiFi.localIP()[0] == 0)
|
||||
@ -454,6 +461,7 @@ void handleSettingsSet()
|
||||
int i = server.arg("LEDS").toInt();
|
||||
if (i > 0) led_amount = i;
|
||||
}
|
||||
buttonEnabled = server.hasArg("BTNON");
|
||||
fadeTransition = server.hasArg("TFADE");
|
||||
if (server.hasArg("TDLAY"))
|
||||
{
|
||||
@ -652,6 +660,7 @@ void colorUpdated()
|
||||
{
|
||||
return; //no change
|
||||
}
|
||||
if (bri > 0) bri_last = bri;
|
||||
notify();
|
||||
if (fadeTransition || seqTransition)
|
||||
{
|
||||
@ -697,6 +706,31 @@ void handleTransitions()
|
||||
|
||||
void handleAnimations(){};
|
||||
|
||||
void handleButton()
|
||||
{
|
||||
if (digitalRead(buttonPin) == LOW && !buttonPressedBefore)
|
||||
{
|
||||
buttonPressedBefore = true;
|
||||
if (bri == 0)
|
||||
{
|
||||
bri = bri_last;
|
||||
} else
|
||||
{
|
||||
bri_last = bri;
|
||||
bri = 0;
|
||||
}
|
||||
colorUpdated();
|
||||
}
|
||||
else if (digitalRead(buttonPin) == HIGH && buttonPressedBefore)
|
||||
{
|
||||
delay(15);
|
||||
if (digitalRead(buttonPin) == HIGH)
|
||||
{
|
||||
buttonPressedBefore = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
@ -779,22 +813,14 @@ void setup() {
|
||||
reset();
|
||||
});
|
||||
if (!ota_lock){
|
||||
//load editor
|
||||
server.on("/edit", HTTP_GET, [](){
|
||||
if(!handleFileRead("/edit.htm")) server.send(404, "text/plain", "FileNotFound");
|
||||
});
|
||||
//create file
|
||||
server.on("/edit", HTTP_PUT, handleFileCreate);
|
||||
//delete file
|
||||
server.on("/edit", HTTP_DELETE, handleFileDelete);
|
||||
//first callback is called after the request has ended with all parsed arguments
|
||||
//second callback handles file uploads at that location
|
||||
server.on("/edit", HTTP_POST, [](){ server.send(200, "text/plain", ""); }, handleFileUpload);
|
||||
//list directory
|
||||
server.on("/list", HTTP_GET, handleFileList);
|
||||
//kill module
|
||||
server.on("/down", HTTP_GET, down);
|
||||
//clear eeprom
|
||||
server.on("/cleareeprom", HTTP_GET, clearEEPROM);
|
||||
//init ota page
|
||||
httpUpdater.setup(&server);
|
||||
@ -814,12 +840,14 @@ void setup() {
|
||||
// Initialize NeoPixel Strip
|
||||
strip.Begin();
|
||||
colorUpdated();
|
||||
pinMode(buttonPin, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
server.handleClient();
|
||||
handleTransitions();
|
||||
handleAnimations();
|
||||
handleButton();
|
||||
}
|
||||
|
||||
void initAP(){
|
||||
|
Loading…
Reference in New Issue
Block a user