WLED/wled00/wled09_button.ino
cschwinne bbb27dd70b Interim commit
Added option to send UDP notifications twice to increase reliability
Added a C64 color theme
Added clock options
Added 12 timezones
Merged Cronixie and useoverlay build options
Removed abbrev char[] from Timezone lib to save memory
Added setting to reverse/flip LEDs
Added long press random color button function
2018-03-06 23:47:08 +01:00

73 lines
1.8 KiB
C++

/*
* Physical IO
*/
void handleButton()
{
if (buttonEnabled)
{
if (digitalRead(buttonPin) == LOW && !buttonPressedBefore)
{
buttonPressedTime = millis();
buttonPressedBefore = true;
}
else if (digitalRead(buttonPin) == HIGH && buttonPressedBefore)
{
delay(15); //debounce
if (digitalRead(buttonPin) == HIGH)
{
if (millis() - buttonPressedTime > 7000) {initAP();}
else if (millis() - buttonPressedTime > 700)
{
if (buttonLongPressMacro != 0) {applyMacro(buttonLongPressMacro);}
else _setRandomColor(false);
}
else {
if (buttonMacro == 0)
{
if (bri == 0)
{
bri = bri_last;
} else
{
bri_last = bri;
bri = 0;
}
colorUpdated(2);
} else {
applyMacro(buttonMacro);
}
}
buttonPressedBefore = false;
}
}
}
//output
if (auxActive || auxActiveBefore)
{
if (!auxActiveBefore)
{
auxActiveBefore = true;
switch (auxTriggeredState)
{
case 0: pinMode(auxPin, INPUT); break;
case 1: pinMode(auxPin, OUTPUT); digitalWrite(auxPin, HIGH); break;
case 2: pinMode(auxPin, OUTPUT); digitalWrite(auxPin, LOW); break;
}
auxStartTime = millis();
}
if ((millis() - auxStartTime > auxTime*1000 && auxTime != 255) || !auxActive)
{
auxActive = false;
auxActiveBefore = false;
switch (auxDefaultState)
{
case 0: pinMode(auxPin, INPUT); break;
case 1: pinMode(auxPin, OUTPUT); digitalWrite(auxPin, HIGH); break;
case 2: pinMode(auxPin, OUTPUT); digitalWrite(auxPin, LOW); break;
}
}
}
}