small improvements
This commit is contained in:
parent
a1151db62a
commit
4f9d75034a
@ -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() {
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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...");
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user