Fix HsbColor

Fix HsbColor (#3430) and enable multiple DS18X20 sensors as default
This commit is contained in:
Theo Arends 2018-08-29 16:05:27 +02:00
parent 3efd969350
commit ebb7f929a0
4 changed files with 109 additions and 116 deletions

View File

@ -17,7 +17,7 @@ If you like **Sonoff-Tasmota**, give it a star, or fork it and contribute!
[![Download Dev](https://img.shields.io/badge/download-development-yellow.svg)](http://thehackbox.org/tasmota/)
[![Build Status](https://img.shields.io/travis/arendst/Sonoff-Tasmota.svg)](https://travis-ci.org/arendst/Sonoff-Tasmota)
See [RELEASENOTES.md](https://github.com/arendst/Sonoff-Tasmota/blob/development/RELEASENOTES.md) for release information and [sonoff/_changelog.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_changelog.ino) for change information.
See [RELEASENOTES.md](https://github.com/arendst/Sonoff-Tasmota/blob/development/RELEASENOTES.md) for release information and [sonoff/_changelog.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_changelog.ino) for detailed change information.
The compiled development versions from current codebase are built around 6AM GMT+2 everyday and posted at http://thehackbox.org/tasmota/ (this web address can be used for OTA too).
@ -94,82 +94,6 @@ The following devices are supported:
- [Luani HVIO board](https://luani.de/projekte/esp8266-hvio/)
- Wemos D1 mini, NodeMcu and Ledunia
#### Available Features and Sensors
| Feature or Sensor | sonoff | classic | minimal | knx | sensors |
|--------------------------------|--------|---------|---------|------|---------|
| ESP/Arduino lib v2.3.0 | 472k | 476k | 340k | 491k | 497k |
| ESP/Arduino lib v2.4.2 | 490k | 490k | 360k | 508k | 513k |
| | | | | | |
| MY_LANGUAGE en-GB | x | x | x | x | x |
| USE_WPS | - | x | - | - | - |
| USE_SMARTCONFIG | - | x | - | - | - |
| USE_ARDUINO_OTA | - | - | - | - | - |
| MQTT_LIBRARY_TYPE PUBSUBCLIENT | x | x | x | x | x |
| USE_DOMOTICZ | x | x | - | x | x |
| USE_HOME_ASSISTANT | x | x | - | x | x |
| USE_MQTT_TLS | - | - | - | - | - |
| USE_KNX | - | - | - | x | - |
| USE_WEBSERVER | x | x | x | x | x |
| USE_EMULATION | x | x | - | - | x |
| USE_DISCOVERY | x | x | - | x | x |
| WEBSERVER_ADVERTISE | x | x | - | x | x |
| MQTT_HOST_DISCOVERY | x | x | - | x | x |
| USE_TIMERS | x | - | - | x | x |
| USE_TIMERS_WEB | x | - | - | x | x |
| USE_SUNRISE | x | - | - | x | x |
| USE_RULES | x | - | - | x | x |
| | | | | | |
| Feature or Sensor | sonoff | classic | minimal | knx | sensors |
| USE_ADC_VCC | x | x | x | x | x |
| USE_DS18B20 | x | x | - | x | - |
| USE_DS18x20 | - | - | - | - | x |
| USE_DS18x20_LEGACY | - | - | - | - | - |
| | | | | | |
| USE_I2C | x | - | - | x | x |
| USE_SHT | x | - | - | x | x |
| USE_HTU | x | - | - | x | x |
| USE_BMP | x | - | - | x | x |
| USE_BME680 | - | - | - | - | x |
| USE_BH1750 | x | - | - | x | x |
| USE_VEML6070 | - | - | - | - | x |
| USE_ADS1115 | - | - | - | - | x |
| USE_ADS1115_I2CDEV | - | - | - | - | - |
| USE_INA219 | - | - | - | - | x |
| USE_SHT3X | x | - | - | x | x |
| USE_TSL2561 | - | - | - | - | x |
| USE_MGS | - | - | - | - | x |
| USE_SGP30 | x | - | - | x | x |
| USE_SI1145 | - | - | - | - | x |
| USE_LM75AD | x | - | - | x | x |
| USE_APDS9960 | - | - | - | - | - |
| USE_MCP230xx | - | - | - | - | - |
| USE_MPR121 | - | - | - | - | - |
| USE_CCS811 | - | - | - | - | - |
| USE_MPU6050 | - | - | - | - | - |
| | | | | | |
| Feature or Sensor | sonoff | classic | minimal | knx | sensors |
| USE_SPI | - | - | - | - | - |
| USE_MHZ19 | x | - | - | x | x |
| USE_SENSEAIR | x | - | - | x | x |
| USE_PMS5003 | x | - | - | x | x |
| USE_NOVA_SDS | x | - | - | x | x |
| USE_PZEM004T | x | - | - | x | x |
| USE_SERIAL_BRIDGE | x | - | - | x | x |
| USE_SDM120 | - | - | - | - | x |
| USE_SDM630 | - | - | - | - | x |
| USE_IR_REMOTE | x | - | - | x | x |
| USE_IR_HVAC | - | - | - | - | x |
| USE_IR_RECEIVE | x | - | - | x | x |
| USE_WS2812 | x | x | - | x | x |
| USE_WS2812_DMA | - | - | - | - | - |
| USE_ARILUX_RF | x | - | - | x | x |
| USE_SR04 | x | - | - | x | x |
| USE_TM1638 | - | - | - | - | - |
| USE_RF_FLASH | x | - | - | x | x |
See [Tasmota ESP/Arduino library version related issues](https://github.com/arendst/Sonoff-Tasmota/wiki/Theo's-Tasmota-Tips#20180523---relation-tasmota-and-esp8266arduino-core-version) for more information.
### Contribute
You can contribute to Sonoff-Tasmota by
- providing Pull Requests (Features, Proof of Concepts, Language files or Fixes)

View File

@ -8,7 +8,7 @@ See [wiki migration path](https://github.com/arendst/Sonoff-Tasmota/wiki/Upgrade
## Release notes
### Change in default initial configuration tool
Firmware binary **sonoff-classic.bin** supports **WifiManager, Wps and SmartConfig** for initial configuration. The default tools is Wps.
Firmware binary **sonoff-classic.bin** supports **WifiManager, Wps and SmartConfig** for initial configuration. The default tool is **Wps**.
To save memory space all other binaries support **WifiManager only**.
@ -29,6 +29,80 @@ The following binary downloads have been compiled with ESP8266/Arduino library v
See [Tasmota ESP/Arduino library version related issues](https://github.com/arendst/Sonoff-Tasmota/wiki/Theo's-Tasmota-Tips#20180523---relation-tasmota-and-esp8266arduino-core-version) why these files are still released using ESP/Arduino library version v2.3.0.
### Available Features and Sensors
| Feature or Sensor | minimal | classic | sonoff | knx | sensors | Remarks
|--------------------------------|---------|---------|--------|------|---------|--------
| ESP/Arduino lib v2.3.0 | 340k | 476k | 472k | 491k | 497k |
| ESP/Arduino lib v2.4.2 | 360k | 490k | 490k | 508k | 513k | No sleep
| | | | | | |
| MY_LANGUAGE en-GB | x | x | x | x | x |
| USE_WPS | - | x | - | - | - |
| USE_SMARTCONFIG | - | x | - | - | - |
| USE_ARDUINO_OTA | - | - | - | - | - |
| MQTT_LIBRARY_TYPE PUBSUBCLIENT | x | x | x | x | x |
| USE_DOMOTICZ | - | x | x | x | x |
| USE_HOME_ASSISTANT | - | x | x | x | x |
| USE_MQTT_TLS | - | - | - | - | - |
| USE_KNX | - | - | - | x | - |
| USE_WEBSERVER | x | x | x | x | x | WifiManager
| USE_EMULATION | - | x | x | - | x |
| USE_DISCOVERY | - | x | x | x | x |
| WEBSERVER_ADVERTISE | - | x | x | x | x |
| MQTT_HOST_DISCOVERY | - | x | x | x | x |
| USE_TIMERS | - | - | x | x | x |
| USE_TIMERS_WEB | - | - | x | x | x |
| USE_SUNRISE | - | - | x | x | x |
| USE_RULES | - | - | x | x | x |
| | | | | | |
| USE_ADC_VCC | x | x | x | x | x |
| USE_DS18B20 | - | - | - | - | - | Single sensor
| USE_DS18x20 | - | x | x | x | x | Multiple sensors
| USE_DS18x20_LEGACY | - | - | - | - | - | Multiple sensors
| | | | | | |
| Feature or Sensor | minimal | classic | sonoff | knx | sensors |
| USE_I2C | - | - | x | x | x |
| USE_SHT | - | - | x | x | x |
| USE_HTU | - | - | x | x | x |
| USE_BMP | - | - | x | x | x |
| USE_BME680 | - | - | - | - | x |
| USE_BH1750 | - | - | x | x | x |
| USE_VEML6070 | - | - | - | - | x |
| USE_ADS1115 | - | - | - | - | x |
| USE_ADS1115_I2CDEV | - | - | - | - | - |
| USE_INA219 | - | - | - | - | x |
| USE_SHT3X | - | - | x | x | x |
| USE_TSL2561 | - | - | - | - | x |
| USE_MGS | - | - | - | - | x |
| USE_SGP30 | - | - | x | x | x |
| USE_SI1145 | - | - | - | - | x |
| USE_LM75AD | - | - | x | x | x |
| USE_APDS9960 | - | - | - | - | - |
| USE_MCP230xx | - | - | - | - | - |
| USE_MPR121 | - | - | - | - | - |
| USE_CCS811 | - | - | - | - | - |
| USE_MPU6050 | - | - | - | - | - |
| | | | | | |
| Feature or Sensor | minimal | classic | sonoff | knx | sensors |
| USE_SPI | - | - | - | - | - |
| USE_MHZ19 | - | - | x | x | x |
| USE_SENSEAIR | - | - | x | x | x |
| USE_PMS5003 | - | - | x | x | x |
| USE_NOVA_SDS | - | - | x | x | x |
| USE_PZEM004T | - | - | x | x | x |
| USE_SERIAL_BRIDGE | - | - | x | x | x |
| USE_SDM120 | - | - | - | - | x |
| USE_SDM630 | - | - | - | - | x |
| USE_IR_REMOTE | - | - | x | x | x |
| USE_IR_HVAC | - | - | - | - | x |
| USE_IR_RECEIVE | - | - | x | x | x |
| USE_WS2812 | - | x | x | x | x |
| USE_WS2812_DMA | - | - | - | - | - |
| USE_ARILUX_RF | - | - | x | x | x |
| USE_SR04 | - | - | x | x | x |
| USE_TM1638 | - | - | - | - | - |
| USE_RF_FLASH | - | - | x | x | x |
## Changelog
Version 6.2.0 20180901

View File

@ -270,7 +270,7 @@
// -- One wire sensors ----------------------------
// WARNING: Select none for default one DS18B20 sensor or enable one of the following two options for multiple sensors
//#define USE_DS18x20 // Optional for more than one DS18x20 sensors with id sort, single scan and read retry (+1k3 code)
#define USE_DS18x20 // Optional for more than one DS18x20 sensors with id sort, single scan and read retry (+1k3 code)
//#define USE_DS18x20_LEGACY // Optional for more than one DS18x20 sensors with dynamic scan using library OneWire (+1k5 code)
// -- I2C sensors ---------------------------------

View File

@ -1083,50 +1083,45 @@ boolean LightCommand()
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_NVALUE, command, XdrvMailbox.index, round(light_current_color[XdrvMailbox.index -1] / 2.55));
}
else if ((CMND_HSBCOLOR == command_code) && ( light_subtype >= LST_RGB)) {
// Implement method to "direct set" color by HSB (HSB is passed comma separated, 0<H<360 0<S<100 0<B<100 )
uint16_t HSB[3];
bool validHSB = true;
bool validHSB = (XdrvMailbox.data_len > 0);
if (validHSB) {
uint16_t HSB[3];
if (strstr(XdrvMailbox.data, ",")) { // Command with 3 comma separated parameters, Hue (0<H<360), Saturation (0<S<100) AND Brightness (0<B<100)
for (int i = 0; i < 3; i++) {
char *substr;
if (strstr(XdrvMailbox.data, ",")) { // Command with 3 comma separated parameters (Hue, Saturation AND Brightness)
for (int i = 0; i < 3; i++) {
char *substr;
if (0 == i) {
substr = strtok(XdrvMailbox.data, ",");
} else {
substr = strtok(NULL, ",");
if (0 == i) {
substr = strtok(XdrvMailbox.data, ",");
} else {
substr = strtok(NULL, ",");
}
if (substr != NULL) {
HSB[i] = atoi(substr);
} else {
validHSB = false;
}
}
if (substr != NULL) {
HSB[i] = atoi(substr);
} else { // Command with only 1 parameter, Hue (0<H<360), Saturation (0<S<100) OR Brightness (0<B<100)
float hsb[3];
LightGetHsb(&hsb[0],&hsb[1],&hsb[2]);
HSB[0] = round(hsb[0] * 360);
HSB[1] = round(hsb[1] * 100);
HSB[2] = round(hsb[2] * 100);
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index < 4)) {
HSB[XdrvMailbox.index -1] = XdrvMailbox.payload;
} else {
validHSB = false;
}
}
} else { // Command with only 1 parameter (Hue, Saturation OR Brightness)
float hsb[3];
LightGetHsb(&hsb[0],&hsb[1],&hsb[2]);
HSB[0] = round(hsb[0] * 360);
HSB[1] = round(hsb[1] * 100);
HSB[2] = round(hsb[2] * 100);
if (XdrvMailbox.index = 1) { // Hue
HSB[0] = XdrvMailbox.payload;
} else if (XdrvMailbox.index = 2) { // Saturation
HSB[1] = XdrvMailbox.payload;
} else if (XdrvMailbox.index = 3) { // Brightness
HSB[2] = XdrvMailbox.payload;
} else {
validHSB = false;
if (validHSB) {
// Translate to fractional elements as required by LightHsbToRgb
// Keep the results <=1 in the event someone passes something out of range.
LightSetHsb(( (HSB[0]>360) ? (HSB[0] % 360) : HSB[0] ) /360.0,
( (HSB[1]>100) ? (HSB[1] % 100) : HSB[1] ) /100.0,
( (HSB[2]>100) ? (HSB[2] % 100) : HSB[2] ) /100.0,
0);
}
}
if (validHSB) {
// Translate to fractional elements as required by LightHsbToRgb
// Keep the results <=1 in the event someone passes something
// out of range.
LightSetHsb(( (HSB[0]>360) ? (HSB[0] % 360) : HSB[0] ) /360.0,
( (HSB[1]>100) ? (HSB[1] % 100) : HSB[1] ) /100.0,
( (HSB[2]>100) ? (HSB[2] % 100) : HSB[2] ) /100.0,
0);
} else {
LightState(0);
}