diff --git a/include/display.h b/include/display.h index aa18d26..322e4c1 100644 --- a/include/display.h +++ b/include/display.h @@ -42,7 +42,7 @@ void changeBrightness(bool increase) { void adjustBrightness() { int currentHour = hour(); - if (currentHour > 9 && currentHour < 17) { + if (currentHour > 8 && currentHour < 17) { brightness = 11; } else { brightness = 1; @@ -54,3 +54,7 @@ void displayColon(bool on) { clockDisplay.drawColon(on); clockDisplay.writeDisplay(); } + +void displayValue(int value) { + clockDisplay.print(value, HEX); +} diff --git a/include/ir.h b/include/ir.h index 13f269c..999a89d 100644 --- a/include/ir.h +++ b/include/ir.h @@ -1,3 +1,5 @@ +#if IR + #include #include #include @@ -48,10 +50,12 @@ bool readIrCommand() { newCommand = true; } irrecv.resume(); // Receive the next value - } + } return newCommand; } uint8_t getCurrentCommand() { return irCommands.empty() ? 0 : irCommands.front(); -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 6d2ab19..d01ed35 100644 --- a/platformio.ini +++ b/platformio.ini @@ -20,6 +20,7 @@ lib_deps = jchristensen/Timezone@^1.2.4 ottowinter/AsyncMqttClient-esphome@^0.8.5 crankyoldgit/IRremoteESP8266@^2.7.18 +build_flags = -D IR=0 [env:laptop_home] diff --git a/src/esp_clock.cpp b/src/esp_clock.cpp index 87f62d5..4a7e965 100644 --- a/src/esp_clock.cpp +++ b/src/esp_clock.cpp @@ -5,7 +5,7 @@ #include "display.h" #include "ir.h" -#define STAY_CONNECTED_AFTER_BOOT 1*60 +#define STAY_CONNECTED_AFTER_BOOT 5*60 int currentHour = -1; time_t timeAtStartup; @@ -28,11 +28,17 @@ void setup() { timeAtStartup = updateTime(); adjustBrightness(); +#if IR setupIr(); +#endif } void loop() { +#if IR if (readIrCommand()) { + displayValue(lastIrCommand); + displayColon(false); + delay(1000); switch (lastIrCommand) { case 0x9F: @@ -62,6 +68,7 @@ void loop() { irCommands.pop(); } sendCommand(); +#endif if ((currentHour != hour())) { adjustBrightness(); wifi.reconnect();