move device defined to environments

This commit is contained in:
interfisch 2021-10-07 20:35:02 +02:00
parent 4cc11361ea
commit 948cf6b047
3 changed files with 65 additions and 68 deletions

View File

@ -15,3 +15,4 @@
"enabled": false "enabled": false
} }
} }

View File

@ -8,7 +8,15 @@
; Please visit documentation for the other options and examples ; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
[env:d1_mini] # Flash upload with platformio run -t upload --environment sensorespx
[platformio]
#For Config upload comment in data_dir line and flash with platformio run -t uploadfs --environment sensorespx
data_dir=data_tischlicht
#data_dir=data_kuechenlicht
#Tischlicht
[env:tischlicht]
platform = espressif8266 platform = espressif8266
board = d1_mini board = d1_mini
framework = arduino framework = arduino
@ -17,3 +25,39 @@ monitor_speed= 115200
lib_deps = lib_deps =
Homie@3.0.0 Homie@3.0.0
build_flags =
-D DUALCOLOR
-D LED_WW=14 ;D5 = GPIO14 (pin5)
-D LED_CW=12 ;D6 = GPIO12 (pin6)
-D BTN_A=13 ;D7 = GPIO13 (pin 7)
-D BTN_B=15 ;D8 = GPIO15 (pin 10)
-D PWM_FREQUENCY=500 ;default: 1000 Hz
-D PWM_MAX=1023 ;10 bit dac
-D BRIGHTNESSCURVE=1.4
-D TEMPERATURE_MIN=2760 ;temperature of warm white leds
-D TEMPERATURE_MAX=5640 ;temperature of cold white leds
-D FW_NAME=\"tischlicht\"
#Kuechenlicht
[env:kuechenlicht]
platform = espressif8266
board = d1_mini
framework = arduino
monitor_speed= 115200
lib_deps =
Homie@3.0.0
build_flags =
-D LED_PWM=D5
-D BTN_A=D7
-D PWM_FREQUENCY=1000 ;default: 1000 Hz
-D PWM_MAX=1023 ;10 bit dac
-D PWM_MINDIMMED=PWM_MAX/3
-D BRIGHTNESSCURVE=2
-D FW_NAME=\"kuechenlicht\"

View File

@ -3,21 +3,10 @@
* Flash Size: 4M (1M SPIFFS) * Flash Size: 4M (1M SPIFFS)
*/ */
//Upload config: platformio run --target uploadfs
//#define TISCHLICHT
#define KUECHENLICHT
#ifdef TISCHLICHT
#define DUALCOLOR
#endif
#include <Arduino.h> #include <Arduino.h>
#include <Homie.h> #include <Homie.h>
#define FW_NAME "kuechenlicht"
#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);
@ -35,32 +24,8 @@ float mapFloat(float x, float in_min, float in_max, float out_min, float out_max
HomieNode lightNode("light", "Light", "light"); //paramters: topic, $name, $type HomieNode lightNode("light", "Light", "light"); //paramters: topic, $name, $type
#ifdef TISCHLICHT
#define LED_WW 14 //D5 = GPIO14 (pin5)
#define LED_CW 12 //D6 = GPIO12 (pin6)
#endif
#ifdef KUECHENLICHT
#define LED_PWM D5
#endif
#ifdef TISCHLICHT
#define BTN_A 13 //D7 = GPIO13 (pin 7)
#define BTN_B 15 //D8 = GPIO15 (pin 10)
#endif
#ifdef KUECHENLICHT
#define BTN_A D7
#endif
#define PWM_MAX 1023 //10 bit dac
#ifdef TISCHLICHT
#define PWM_FREQUENCY 500 //default: 1000 Hz
#endif
#ifdef KUECHENLICHT
#define PWM_FREQUENCY 1000 //default: 1000 Hz
#define PWM_MINDIMMED PWM_MAX/3 //if light turns on later than just above 0 pwm
#endif
boolean enable=false; boolean enable=false;
@ -70,22 +35,11 @@ float enable_fadevalue_change_per_loop=0.01; //fixed value. For manual calculato
float set_brightness=2; //0 to 2. 1 is maximum brightness with full color range still possible. 2 is full brightness regardless of possible color temp float set_brightness=2; //0 to 2. 1 is maximum brightness with full color range still possible. 2 is full brightness regardless of possible color temp
#define BRIGHTNESS_MIN 0.0 #define BRIGHTNESS_MIN 0.0
#define BRIGHTNESS_MAX 2.0 //if temperature is in between both strips brightness of 2 means both are at full power. otherwise brightness will be clipped #define BRIGHTNESS_MAX 2.0 //if temperature is in between both strips brightness of 2 means both are at full power. otherwise brightness will be clipped
#ifdef TISCHLICHT
#define BRIGHTNESSCURVE 1.4
#endif
#ifdef KUECHENLICHT
#define BRIGHTNESSCURVE 2
#endif
float brightness=set_brightness; float brightness=set_brightness;
float brightness_change_per_loop=0; //will be calculated by Handler float brightness_change_per_loop=0; //will be calculated by Handler
#ifdef TISCHLICHT
#define TEMPERATURE_MIN 2760 //temperature of warm white leds
#define TEMPERATURE_MAX 5640 //temperature of cold white leds
#endif
#ifdef DUALCOLOR #ifdef DUALCOLOR
float set_temperature=(TEMPERATURE_MAX+TEMPERATURE_MIN)/2; float set_temperature=(TEMPERATURE_MAX+TEMPERATURE_MIN)/2;
float temperature=set_temperature; float temperature=set_temperature;
@ -137,23 +91,21 @@ void setup() {
Serial.println("Hello"); Serial.println("Hello");
analogWriteFreq(PWM_FREQUENCY); analogWriteFreq(PWM_FREQUENCY);
#ifdef TISCHLICHT #ifdef DUALCOLOR
pinMode(LED_WW, OUTPUT); pinMode(LED_WW, OUTPUT);
pinMode(LED_CW, OUTPUT); pinMode(LED_CW, OUTPUT);
analogWrite(LED_CW, PWM_MAX); //high = off analogWrite(LED_CW, PWM_MAX); //high = off
analogWrite(LED_WW, PWM_MAX); //high = off analogWrite(LED_WW, PWM_MAX); //high = off
#endif #else
#ifdef KUECHENLICHT
pinMode(LED_PWM, OUTPUT); pinMode(LED_PWM, OUTPUT);
analogWrite(LED_PWM, PWM_MAX); //high = off analogWrite(LED_PWM, PWM_MAX); //high = off
#endif #endif
#ifdef TISCHLICHT #ifdef DUALCOLOR
pinMode(BTN_A, INPUT); pinMode(BTN_A, INPUT);
pinMode(BTN_B, INPUT); pinMode(BTN_B, INPUT);
#endif #else
#ifdef KUECHENLICHT
pinMode(BTN_A, INPUT); pinMode(BTN_A, INPUT);
#endif #endif