small improvements

This commit is contained in:
Nicu Hodos 2021-12-06 22:54:01 +01:00
parent a1151db62a
commit 4f9d75034a
4 changed files with 10 additions and 7 deletions

View File

@ -5,7 +5,8 @@
#include "ntp_time.h"
#define DISPLAY_ADDRESS 0x70
#define BRIGHTNESS 1
#define BRIGHTNESS 0
#define BRIGHTNESS_STEP 1
namespace Display {
@ -36,7 +37,7 @@ namespace Display {
}
void changeBrightness(bool increase) {
increase ? brightness = (brightness + 2) % 15 : brightness = (brightness - 2) % 15;
increase ? brightness = (brightness + BRIGHTNESS_STEP) % 15 : brightness = (brightness - BRIGHTNESS_STEP) % 15;
clockDisplay.setBrightness(brightness);
}
@ -44,7 +45,7 @@ namespace Display {
if (currentHour > 8 && currentHour < 17) {
brightness = 11;
} else {
brightness = 1;
brightness = BRIGHTNESS;
}
clockDisplay.setBrightness(brightness);
}
@ -72,6 +73,7 @@ namespace Display {
void displayValue(int value) {
clockDisplay.print(value, HEX);
clockDisplay.writeDisplay();
}
void setup() {

View File

@ -21,7 +21,7 @@ namespace Ir {
bool readCommand() {
bool newCommand = false;
if (irrecv.decode(&results)) {
if (results.decode_type == NEC) {
if (results.decode_type == NEC && results.command != 0) {
Serial.print(F(" C=0x"));
Serial.print(results.command, HEX);
Serial.println();
@ -40,7 +40,6 @@ namespace Ir {
void loop() {
if (readCommand()) {
Display::displayValue(lastCommand);
switch (lastCommand)
{
case 0x9F:

View File

@ -44,9 +44,11 @@ namespace Mqtt {
void setup() {
client.onConnect([](bool sessionPresent) {
tPublish.enableDelayed();
Serial.println("Connected to MQTT");
});
client.onDisconnect([](AsyncMqttClientDisconnectReason reason) {
tPublish.disable();
Serial.println("Disconnected from MQTT");
});
client.setServer(MQTT_HOST, MQTT_PORT);
Serial.println("Connecting to MQTT...");

View File

@ -26,9 +26,9 @@ lib_deps =
build_flags = -D IR=1
[env:laptop_home]
build_flags = -D IR=0
build_flags = -D IR=1
[env:ota_home]
build_flags = -D IR=0
build_flags = -D IR=1
upload_port = 192.168.5.191
upload_protocol = espota