2016-12-31 00:38:51 +01:00
|
|
|
/*
|
|
|
|
* Physical IO
|
|
|
|
*/
|
|
|
|
|
2016-11-19 19:39:17 +01:00
|
|
|
void handleButton()
|
|
|
|
{
|
|
|
|
if (buttonEnabled)
|
|
|
|
{
|
|
|
|
if (digitalRead(buttonPin) == LOW && !buttonPressedBefore)
|
|
|
|
{
|
|
|
|
buttonPressedBefore = true;
|
2017-12-28 00:37:13 +01:00
|
|
|
if (buttonMacro == 255)
|
2016-11-19 19:39:17 +01:00
|
|
|
{
|
2017-12-28 00:37:13 +01:00
|
|
|
if (bri == 0)
|
|
|
|
{
|
|
|
|
bri = bri_last;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
bri_last = bri;
|
|
|
|
bri = 0;
|
|
|
|
}
|
|
|
|
colorUpdated(2);
|
|
|
|
} else {
|
|
|
|
applyMacro(buttonMacro);
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (digitalRead(buttonPin) == HIGH && buttonPressedBefore)
|
|
|
|
{
|
2017-12-28 00:37:13 +01:00
|
|
|
delay(15); //debounce
|
2016-11-19 19:39:17 +01:00
|
|
|
if (digitalRead(buttonPin) == HIGH)
|
|
|
|
{
|
|
|
|
buttonPressedBefore = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-27 22:59:01 +01:00
|
|
|
|
|
|
|
//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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-11-19 19:39:17 +01:00
|
|
|
}
|