GP output function added

This commit is contained in:
cschwinne 2017-01-27 22:59:01 +01:00
parent 02443ed697
commit b09f450171
3 changed files with 39 additions and 0 deletions

View File

@ -37,6 +37,9 @@
//Hardware-settings (only changeble via code) //Hardware-settings (only changeble via code)
#define LEDCOUNT 84 #define LEDCOUNT 84
uint8_t buttonPin = 0; //needs pull-up uint8_t buttonPin = 0; //needs pull-up
uint8_t auxPin = 16; //use e.g. for external relay
uint8_t auxDefaultState = 0; //0: input 1: high 2: low
uint8_t auxTriggeredState = 0; //0: input 1: high 2: low
//AP and OTA default passwords (change them!) //AP and OTA default passwords (change them!)
String appass = "wled1234"; String appass = "wled1234";
@ -133,6 +136,9 @@ boolean nixiePause;
long countdownTime = 1483225200L; long countdownTime = 1483225200L;
boolean arlsTimeout = false; boolean arlsTimeout = false;
long arlsTimeoutTime; long arlsTimeoutTime;
uint8_t auxTime = 0;
long auxStartTime;
boolean auxActive, auxActiveBefore;
ESP8266WebServer server(80); ESP8266WebServer server(80);
ESP8266HTTPUpdateServer httpUpdater; ESP8266HTTPUpdateServer httpUpdater;

View File

@ -281,6 +281,12 @@ boolean handleSet(String req)
nightlightStartTime = millis(); nightlightStartTime = millis();
} }
} }
pos = req.indexOf("AX=");
if (pos > 0) {
auxTime = req.substring(pos + 3).toInt();
auxActive = true;
if (auxTime == 0) auxActive = false;
}
XML_response(); XML_response();
if (effectUpdated) if (effectUpdated)
{ {

View File

@ -28,4 +28,31 @@ void handleButton()
} }
} }
} }
//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;
}
}
}
} }