Browse Source

move device defined to environments

master
interfisch 2 months ago
parent
commit
948cf6b047
  1. 31
      data/homie/config.json
  2. 46
      platformio.ini
  3. 56
      src/main.cpp

31
data/homie/config.json

@ -1,17 +1,18 @@
{
"name": "kuechenlicht",
"device_id": "kuechenlicht",
"wifi": {
"ssid": "WLANSSID",
"password": "WLANPASSWORD"
},
"mqtt": {
"host": "10.0.0.1",
"port": 1883,
"auth": false,
"base_topic": ""
},
"ota": {
"enabled": false
}
"name": "kuechenlicht",
"device_id": "kuechenlicht",
"wifi": {
"ssid": "WLANSSID",
"password": "WLANPASSWORD"
},
"mqtt": {
"host": "10.0.0.1",
"port": 1883,
"auth": false,
"base_topic": ""
},
"ota": {
"enabled": false
}
}

46
platformio.ini

@ -8,7 +8,41 @@
; Please visit documentation for the other options and examples
; 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
board = d1_mini
framework = arduino
monitor_speed= 115200
lib_deps =
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
@ -17,3 +51,13 @@ 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\"

56
src/main.cpp

@ -3,21 +3,10 @@
* Flash Size: 4M (1M SPIFFS)
*/
//Upload config: platformio run --target uploadfs
//#define TISCHLICHT
#define KUECHENLICHT
#ifdef TISCHLICHT
#define DUALCOLOR
#endif
#include <Arduino.h>
#include <Homie.h>
#define FW_NAME "kuechenlicht"
#define FW_VERSION "1.0.0"
bool enableHandler(const HomieRange& range, const String& value);
@ -35,33 +24,9 @@ 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
#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;
float enable_fadevalue=0; //0=off, 1=on
@ -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
#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
#ifdef TISCHLICHT
#define BRIGHTNESSCURVE 1.4
#endif
#ifdef KUECHENLICHT
#define BRIGHTNESSCURVE 2
#endif
float brightness=set_brightness;
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
float set_temperature=(TEMPERATURE_MAX+TEMPERATURE_MIN)/2;
float temperature=set_temperature;
@ -137,23 +91,21 @@ void setup() {
Serial.println("Hello");
analogWriteFreq(PWM_FREQUENCY);
#ifdef TISCHLICHT
#ifdef DUALCOLOR
pinMode(LED_WW, OUTPUT);
pinMode(LED_CW, OUTPUT);
analogWrite(LED_CW, PWM_MAX); //high = off
analogWrite(LED_WW, PWM_MAX); //high = off
#endif
#ifdef KUECHENLICHT
#else
pinMode(LED_PWM, OUTPUT);
analogWrite(LED_PWM, PWM_MAX); //high = off
#endif
#ifdef TISCHLICHT
#ifdef DUALCOLOR
pinMode(BTN_A, INPUT);
pinMode(BTN_B, INPUT);
#endif
#ifdef KUECHENLICHT
#else
pinMode(BTN_A, INPUT);
#endif

Loading…
Cancel
Save