Sliming down and simplifying
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
16
src/main.cpp
16
src/main.cpp
@ -2,7 +2,7 @@
|
||||
#include <WiFiUdp.h>
|
||||
|
||||
const int PIN_RELAY = D1;
|
||||
#define OUTPUT_SET(x) digitalWrite(PIN_RELAY, x ? LOW : HIGH);
|
||||
#define OUTPUT_SET(x) digitalWrite(PIN_RELAY, x ? LOW : HIGH)
|
||||
unsigned int timer = 0;
|
||||
unsigned int next_timer_update = 0;
|
||||
HomieNode powerNode("power", "Power", "switch");
|
||||
@ -49,13 +49,14 @@ void loopHandler() {
|
||||
if(timer)
|
||||
{
|
||||
if(timer < millis())
|
||||
{
|
||||
{ //Timer has expired. (Ignore the wraparound...)
|
||||
timer = 0;
|
||||
OUTPUT_SET(false);
|
||||
powerNode.setProperty("timer").send("0");
|
||||
powerNode.setProperty("state").send("off");
|
||||
}
|
||||
if(millis() > next_timer_update) {
|
||||
|
||||
if(next_timer_update && millis() > next_timer_update) {
|
||||
next_timer_update = millis() + 60*1000;
|
||||
unsigned int time_remaining = timer - millis();
|
||||
unsigned int min_left = time_remaining / (60*1000);
|
||||
@ -69,13 +70,8 @@ void loopHandler() {
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial << endl << endl;
|
||||
Serial << "Firmware 0.0.1" << endl;
|
||||
Serial << endl << endl;
|
||||
|
||||
Homie_setFirmware("deskcontrol", "1.0.0");
|
||||
Homie_setBrand("FuryFire");
|
||||
|
||||
Homie_setFirmware("deskcontrol", "1.1.0");
|
||||
|
||||
Homie.disableResetTrigger();
|
||||
powerNode.advertise("state").settable(powerStateHandler);
|
||||
powerNode.advertise("timer").settable(powerTimerHandler);
|
||||
|
Reference in New Issue
Block a user