Compare commits

..

No commits in common. "aa9f3effcb61ba240c35004e1f79e126497439c8" and "948cf6b04798a1a5b8d7030fc9a88bdbff1c89f8" have entirely different histories.

2 changed files with 11 additions and 7 deletions

View File

@ -29,8 +29,8 @@ lib_deps =
build_flags = build_flags =
-D DUALCOLOR -D DUALCOLOR
-D LED_WW=12 ;D6 = GPIO12 (pin6) -D LED_WW=14 ;D5 = GPIO14 (pin5)
-D LED_CW=14 ;D5 = GPIO14 (pin5) -D LED_CW=12 ;D6 = GPIO12 (pin6)
-D BTN_A=13 ;D7 = GPIO13 (pin 7) -D BTN_A=13 ;D7 = GPIO13 (pin 7)
-D BTN_B=15 ;D8 = GPIO15 (pin 10) -D BTN_B=15 ;D8 = GPIO15 (pin 10)
-D PWM_FREQUENCY=500 ;default: 1000 Hz -D PWM_FREQUENCY=500 ;default: 1000 Hz
@ -38,6 +38,7 @@ build_flags =
-D BRIGHTNESSCURVE=1.4 -D BRIGHTNESSCURVE=1.4
-D TEMPERATURE_MIN=2760 ;temperature of warm white leds -D TEMPERATURE_MIN=2760 ;temperature of warm white leds
-D TEMPERATURE_MAX=5640 ;temperature of cold white leds -D TEMPERATURE_MAX=5640 ;temperature of cold white leds
-D FW_NAME=\"tischlicht\"
#Kuechenlicht #Kuechenlicht
@ -59,3 +60,4 @@ build_flags =
-D PWM_MAX=1023 ;10 bit dac -D PWM_MAX=1023 ;10 bit dac
-D PWM_MINDIMMED=PWM_MAX/3 -D PWM_MINDIMMED=PWM_MAX/3
-D BRIGHTNESSCURVE=2 -D BRIGHTNESSCURVE=2
-D FW_NAME=\"kuechenlicht\"

View File

@ -6,7 +6,7 @@
#include <Arduino.h> #include <Arduino.h>
#include <Homie.h> #include <Homie.h>
#define FW_NAME "esplight"
#define FW_VERSION "1.0.0" #define FW_VERSION "1.0.0"
bool enableHandler(const HomieRange& range, const String& value); bool enableHandler(const HomieRange& range, const String& value);
@ -90,7 +90,6 @@ void setup() {
Serial.begin(115200); Serial.begin(115200);
Serial.println("Hello"); Serial.println("Hello");
analogWriteRange(PWM_MAX);
analogWriteFreq(PWM_FREQUENCY); analogWriteFreq(PWM_FREQUENCY);
#ifdef DUALCOLOR #ifdef DUALCOLOR
pinMode(LED_WW, OUTPUT); pinMode(LED_WW, OUTPUT);
@ -319,6 +318,7 @@ void loopHandler() {
if (enable_fadevalue<0) { enable_fadevalue=0; } //limit if (enable_fadevalue<0) { enable_fadevalue=0; } //limit
flag_updatePWM=true; //force update flag_updatePWM=true; //force update
} }
//calculate and update pwm //calculate and update pwm
#ifdef DUALCOLOR #ifdef DUALCOLOR
if (brightness != set_brightness || temperature != set_temperature || flag_updatePWM) { //if target not reached if (brightness != set_brightness || temperature != set_temperature || flag_updatePWM) { //if target not reached
@ -335,8 +335,6 @@ void loopHandler() {
pwmWW=pow((brightness*enable_fadevalue)/2.0, BRIGHTNESSCURVE) *2.0 *(1-temp) *PWM_MAX; pwmWW=pow((brightness*enable_fadevalue)/2.0, BRIGHTNESSCURVE) *2.0 *(1-temp) *PWM_MAX;
if (pwmCW>PWM_MAX) { pwmCW=PWM_MAX; } //limit if (pwmCW>PWM_MAX) { pwmCW=PWM_MAX; } //limit
if (pwmWW>PWM_MAX) { pwmWW=PWM_MAX; } //limit if (pwmWW>PWM_MAX) { pwmWW=PWM_MAX; } //limit
Serial.print("brightness"); Serial.println(brightness);
Serial.print("CW="); Serial.print(pwmCW); Serial.print(", WW="); Serial.println(pwmWW);
analogWrite(LED_WW, PWM_MAX-pwmWW); //full pwm is led off analogWrite(LED_WW, PWM_MAX-pwmWW); //full pwm is led off
analogWrite(LED_CW, PWM_MAX-pwmCW); //full pwm is led off analogWrite(LED_CW, PWM_MAX-pwmCW); //full pwm is led off
@ -353,6 +351,10 @@ void loopHandler() {
analogWrite(LED_PWM, PWM_MAX-pwm); //full pwm is led off analogWrite(LED_PWM, PWM_MAX-pwm); //full pwm is led off
#endif #endif
} }
} }