Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed building for ESP32 #464

Merged
merged 2 commits into from
Oct 18, 2024
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
5 changes: 3 additions & 2 deletions include/clockWork.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ class ClockWork {
};
stateBH1750Type stateBH1750 = stateBH1750Type::toBeInitialized;
float lux = 0.0;
uint16 adcValue0Lux = 10; // Hier wird der niedrigste LDR-ADC Wert getrackt,
// für eine dynamische offset korrektur bei 0 LUX
uint16_t adcValue0Lux =
10; // Hier wird der niedrigste LDR-ADC Wert getrackt,
// für eine dynamische offset korrektur bei 0 LUX

private:
//------------------------------------------------------------------------------
Expand Down
9 changes: 7 additions & 2 deletions include/clockWork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void ClockWork::loopAutoBrightLogic() {
// Using legacy LDR for ambient light measurement
// Electrical circuit = voltage divider: 3.3V--LDR-->ADC<--220
// Ohm--GND
uint16 adcValue = analogRead(
uint16_t adcValue = analogRead(
A0); // Read out ADC, pin TOUT = 0.0V - 1.0V = adcValue 0-1023
// Track lowest ADC value for offest correction at 0 LUX
if (adcValue < adcValue0Lux)
Expand All @@ -60,7 +60,8 @@ void ClockWork::loopAutoBrightLogic() {
// aBS=16 then ledGain should reach 100.0% at 500.0 LUX.
ledGain = (lux * (float)(G.autoBrightSlope + 1)) / 80.0;
// Add autoBrightOffset 0-255
ledGain += ((uint16)100 * (uint16)G.autoBrightOffset) / (uint16)255;
ledGain +=
((uint16_t)100 * (uint16_t)G.autoBrightOffset) / (uint16_t)255;
if (ledGain > 100.0)
ledGain = 100.0;
}
Expand All @@ -73,7 +74,11 @@ void ClockWork::loopAutoBrightLogic() {
// Initialize the I2C bus using SCL and SDA pins
// (BH1750 library doesn't do this automatically)
void ClockWork::initBH1750Logic() {
#ifdef ESP8266
Wire.begin(D4, D3);
#elif defined(ESP32)
Wire.begin(21, 22);
#endif
// begin returns a boolean that can be used to detect setup problems.
if (lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE)) {
Serial.println("BH1750 initialized. Using this sensor for ambient "
Expand Down
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ lib_deps =
adafruit/RTClib@^1.11.2
knolleary/PubSubClient@^2.8.0
https://github.com/tzapu/WiFiManager#v2.0.17
claws/BH1750@^1.3.0
extra_scripts = pre:extra_scripts.py
Loading