Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: DoozyX/clang-format-lint-action@v0.18.2
with:
source: '.'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/platformio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
Expand Down
3 changes: 3 additions & 0 deletions include/Uhr.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ struct GLOBAL {
bool bootShowIP;

Birthday birthday[MAX_BIRTHDAY_COUNT];

uint8_t ldrType; // 0 = 1 LDR, 1 = 4 LDR parallel
};
GLOBAL G = {};

Expand Down Expand Up @@ -253,6 +255,7 @@ enum CommandWords {
COMMAND_SET_AUTO_BRIGHT = 102,
COMMAND_SET_LAYOUT_VARIANT = 103,
COMMAND_SET_MQTT_HA_DISCOVERY = 104,
COMMAND_SET_LDR_TYPE = 105,

COMMAND_SPEED = 152,

Expand Down
21 changes: 14 additions & 7 deletions include/clockWork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ void ClockWork::loopAutoBrightLogic() {
if (adcValue < adcValue0Lux)
adcValue0Lux = adcValue;
float ldrValue = adcValue - adcValue0Lux;
// Derive LUX value from ldrValue via a second degree polinomial.
// The polinomial was derived using an Excel trend line, see
// LDR-Calibration.xlsx
const float x2 = 0.0427;
const float x1 = 2.679;
const float x0 = 10.857;
lux = x2 * ldrValue * ldrValue + x1 * ldrValue + x0;

// Derive LUX value from ldrValue via a second degree polinomial based on LDR type
if (G.ldrType == 0) { // 1 LDR Sensor
const float x2 = 0.0427;
const float x1 = 2.679;
const float x0 = 10.857;
lux = x2 * ldrValue * ldrValue + x1 * ldrValue + x0;
} else { // 4 LDR Sensoren parallel
const float x2 = 0.0005;
const float x1 = 0.0687;
const float x0 = 3.9907;
lux = x2 * ldrValue * ldrValue - x1 * ldrValue + x0;
}
}

// Based on the LUX value derive the gain for the LEDs 0.0 - 100.0%
Expand Down Expand Up @@ -1178,6 +1184,7 @@ void ClockWork::loop(struct tm &tm) {
config["bootShowWifi"] = G.bootShowWifi;
config["bootShowIP"] = G.bootShowIP;
config["autoBrightEnabled"] = G.autoBrightEnabled;
config["ldrType"] = G.ldrType;
config["isRomanLanguage"] = isRomanLanguage();
config["hasDreiviertel"] = usedUhrType->hasDreiviertel();
config["hasZwanzig"] = usedUhrType->hasZwanzig();
Expand Down
16 changes: 12 additions & 4 deletions include/mqtt.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <Arduino.h>
#include <ArduinoJson.h>

class Mqtt {
private:
Expand All @@ -11,15 +11,23 @@ class Mqtt {
static void processScrollingText(const JsonDocument &doc);
static void processColor(const JsonDocument &doc);
static void processBrightness(const JsonDocument &doc);
static void processAutobrightSwitch(const JsonDocument &doc);
static void processBrightOffset(const JsonDocument &doc);
static void processBrightSlope(const JsonDocument &doc);
static void processScrollSpeed(const JsonDocument &doc);
static void processEffectSpeed(const JsonDocument &doc);
static bool checkIfMqttUserIsEmpty();

public:
Mqtt() = default;
~Mqtt() = default;
Mqtt();
~Mqtt();

void init();
void loop();
void sendState();
void sendDiscovery();

bool isConnected();
};

// Globale Instanz
extern Mqtt* mqttInstance;
Loading