esp_clock: use directive to enable/disable IR
This commit is contained in:
parent
bab484f357
commit
584e1ffc4e
@ -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);
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
#if IR
|
||||
|
||||
#include <queue>
|
||||
#include <AsyncMqttClient.h>
|
||||
#include <IRremoteESP8266.h>
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -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]
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user