esp_clock: use directive to enable/disable IR

This commit is contained in:
Nicu Hodos 2021-11-19 21:09:29 +01:00
parent bab484f357
commit 584e1ffc4e
4 changed files with 20 additions and 4 deletions

View File

@ -42,7 +42,7 @@ void changeBrightness(bool increase) {
void adjustBrightness() { void adjustBrightness() {
int currentHour = hour(); int currentHour = hour();
if (currentHour > 9 && currentHour < 17) { if (currentHour > 8 && currentHour < 17) {
brightness = 11; brightness = 11;
} else { } else {
brightness = 1; brightness = 1;
@ -54,3 +54,7 @@ void displayColon(bool on) {
clockDisplay.drawColon(on); clockDisplay.drawColon(on);
clockDisplay.writeDisplay(); clockDisplay.writeDisplay();
} }
void displayValue(int value) {
clockDisplay.print(value, HEX);
}

View File

@ -1,3 +1,5 @@
#if IR
#include <queue> #include <queue>
#include <AsyncMqttClient.h> #include <AsyncMqttClient.h>
#include <IRremoteESP8266.h> #include <IRremoteESP8266.h>
@ -55,3 +57,5 @@ bool readIrCommand() {
uint8_t getCurrentCommand() { uint8_t getCurrentCommand() {
return irCommands.empty() ? 0 : irCommands.front(); return irCommands.empty() ? 0 : irCommands.front();
} }
#endif

View File

@ -20,6 +20,7 @@ lib_deps =
jchristensen/Timezone@^1.2.4 jchristensen/Timezone@^1.2.4
ottowinter/AsyncMqttClient-esphome@^0.8.5 ottowinter/AsyncMqttClient-esphome@^0.8.5
crankyoldgit/IRremoteESP8266@^2.7.18 crankyoldgit/IRremoteESP8266@^2.7.18
build_flags = -D IR=0
[env:laptop_home] [env:laptop_home]

View File

@ -5,7 +5,7 @@
#include "display.h" #include "display.h"
#include "ir.h" #include "ir.h"
#define STAY_CONNECTED_AFTER_BOOT 1*60 #define STAY_CONNECTED_AFTER_BOOT 5*60
int currentHour = -1; int currentHour = -1;
time_t timeAtStartup; time_t timeAtStartup;
@ -28,11 +28,17 @@ void setup() {
timeAtStartup = updateTime(); timeAtStartup = updateTime();
adjustBrightness(); adjustBrightness();
#if IR
setupIr(); setupIr();
#endif
} }
void loop() { void loop() {
#if IR
if (readIrCommand()) { if (readIrCommand()) {
displayValue(lastIrCommand);
displayColon(false);
delay(1000);
switch (lastIrCommand) switch (lastIrCommand)
{ {
case 0x9F: case 0x9F:
@ -62,6 +68,7 @@ void loop() {
irCommands.pop(); irCommands.pop();
} }
sendCommand(); sendCommand();
#endif
if ((currentHour != hour())) { if ((currentHour != hour())) {
adjustBrightness(); adjustBrightness();
wifi.reconnect(); wifi.reconnect();