mirror of https://github.com/arendst/Tasmota.git
Add light synonyms
Add commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend``, ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105 and 106`` respectively
This commit is contained in:
parent
adf05a5a3c
commit
b4ceb9e5e9
|
@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
|
|||
## [9.2.0.4]
|
||||
### Added
|
||||
- Function ``AddLog`` to provide logging for up to 128 (LOGSZ) characters to save stack space
|
||||
- Commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend``, ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105 and 106`` respectively
|
||||
|
||||
### Changed
|
||||
- Maximum chars in ``AddLog_P`` logging restored from 128 to 700 (MAX_LOGSZ) to solve broken error messages
|
||||
|
|
|
@ -65,6 +65,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
|
|||
- Command ``SetOption43 1..255`` to control Rotary step (#10407)
|
||||
- Command ``SetOption118 1`` to move ZbReceived from JSON message and into the subtopic replacing "SENSOR" default [#10353](https://github.com/arendst/Tasmota/issues/10353)
|
||||
- Command ``SetOption119 1`` to remove the device addr from json payload, can be used with zb_topic_fname where the addr is already known from the topic [#10355](https://github.com/arendst/Tasmota/issues/10355)
|
||||
- Commands ``ChannelRemap``, ``MultiPWM``, ``AlexaCTRange``, ``PowerOnFade``, ``PWMCT``, ``WhiteBlend``, ``VirtualCT`` as synonyms for ``SetOption37, 68, 82, 91, 92, 105 and 106`` respectively
|
||||
- Milliseconds to console output [#10152](https://github.com/arendst/Tasmota/issues/10152)
|
||||
- Gpio ``Option_a1`` enabling PWM2 high impedance if powered off as used by Wyze bulbs [#10196](https://github.com/arendst/Tasmota/issues/10196)
|
||||
- Rotary No Pullup GPIO selection ``Rotary A/B_n`` [#10407](https://github.com/arendst/Tasmota/issues/10407)
|
||||
|
|
|
@ -420,6 +420,13 @@
|
|||
#define D_JSON_MAXENERGYREACHED "MaxEnergyReached"
|
||||
|
||||
// Commands xdrv_04_light.ino
|
||||
#define D_SO_CHANNELREMAP "ChannelRemap" // SO37
|
||||
#define D_SO_MULTIPWM "MultiPWM" // SO68
|
||||
#define D_SO_ALEXACTRANGE "AlexaCTRange" // SO82
|
||||
#define D_SO_POWERONFADE "PowerOnFade" // SO91
|
||||
#define D_SO_PWMCT "PWMCT" // SO92
|
||||
#define D_SO_WHITEBLEND "WhiteBlend" // SO105
|
||||
#define D_SO_VIRTUALCT "VirtualCT" // SO106
|
||||
#define D_CMND_CHANNEL "Channel"
|
||||
#define D_CMND_COLOR "Color"
|
||||
#define D_CMND_COLORTEMPERATURE "CT"
|
||||
|
@ -771,6 +778,8 @@ const float kSpeedConversionFactor[] = {1, // none
|
|||
// xdrv_02_webserver.ino
|
||||
#ifdef USE_WEBSERVER
|
||||
// {s} = <tr><th>, {m} = </th><td>, {e} = </td></tr>
|
||||
const char HTTP_SNS_F_TEMP[] PROGMEM = "{s}%s " D_TEMPERATURE "{m}%*_f " D_UNIT_DEGREE "%c{e}";
|
||||
|
||||
const char HTTP_SNS_TEMP[] PROGMEM = "{s}%s " D_TEMPERATURE "{m}%s " D_UNIT_DEGREE "%c{e}";
|
||||
const char HTTP_SNS_HUM[] PROGMEM = "{s}%s " D_HUMIDITY "{m}%s " D_UNIT_PERCENT "{e}";
|
||||
const char HTTP_SNS_DEW[] PROGMEM = "{s}%s " D_DEWPOINT "{m}%s " D_UNIT_DEGREE "%c{e}";
|
||||
|
|
|
@ -916,8 +916,8 @@ int GetCommandCode(char* destination, size_t destination_size, const char* needl
|
|||
return result;
|
||||
}
|
||||
|
||||
bool DecodeCommand(const char* haystack, void (* const MyCommand[])(void))
|
||||
{
|
||||
bool DecodeCommand(const char* haystack, void (* const MyCommand[])(void), const uint8_t *synonyms = nullptr);
|
||||
bool DecodeCommand(const char* haystack, void (* const MyCommand[])(void), const uint8_t *synonyms) {
|
||||
GetTextIndexed(XdrvMailbox.command, CMDSZ, 0, haystack); // Get prefix if available
|
||||
int prefix_length = strlen(XdrvMailbox.command);
|
||||
if (prefix_length) {
|
||||
|
@ -927,10 +927,18 @@ bool DecodeCommand(const char* haystack, void (* const MyCommand[])(void))
|
|||
return false; // Prefix not in command
|
||||
}
|
||||
}
|
||||
size_t syn_count = synonyms ? pgm_read_byte(synonyms) : 0;
|
||||
int command_code = GetCommandCode(XdrvMailbox.command + prefix_length, CMDSZ, XdrvMailbox.topic + prefix_length, haystack);
|
||||
if (command_code > 0) { // Skip prefix
|
||||
XdrvMailbox.command_code = command_code -1;
|
||||
if (command_code > syn_count) {
|
||||
// We passed the synonyms zone, it's a regular command
|
||||
XdrvMailbox.command_code = command_code - 1 - syn_count;
|
||||
MyCommand[XdrvMailbox.command_code]();
|
||||
} else {
|
||||
// We have a SetOption synonym
|
||||
XdrvMailbox.index = pgm_read_byte(synonyms + command_code);
|
||||
CmndSetoptionBase(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -129,6 +129,10 @@ enum LightSchemes { LS_POWER, LS_WAKEUP, LS_CYCLEUP, LS_CYCLEDN, LS_RANDOM, LS_M
|
|||
const uint8_t LIGHT_COLOR_SIZE = 25; // Char array scolor size
|
||||
|
||||
const char kLightCommands[] PROGMEM = "|" // No prefix
|
||||
// SetOptions synonyms
|
||||
D_SO_CHANNELREMAP "|" D_SO_MULTIPWM "|" D_SO_ALEXACTRANGE "|" D_SO_POWERONFADE "|" D_SO_PWMCT "|"
|
||||
D_SO_WHITEBLEND "|" D_SO_VIRTUALCT "|"
|
||||
// Other commands
|
||||
D_CMND_COLOR "|" D_CMND_COLORTEMPERATURE "|" D_CMND_DIMMER "|" D_CMND_DIMMER_RANGE "|" D_CMND_DIMMER_STEP "|" D_CMND_LEDTABLE "|" D_CMND_FADE "|"
|
||||
D_CMND_RGBWWTABLE "|" D_CMND_SCHEME "|" D_CMND_SPEED "|" D_CMND_WAKEUP "|" D_CMND_WAKEUPDURATION "|"
|
||||
D_CMND_WHITE "|" D_CMND_CHANNEL "|" D_CMND_HSBCOLOR
|
||||
|
@ -144,6 +148,12 @@ const char kLightCommands[] PROGMEM = "|" // No prefix
|
|||
#endif // USE_DGR_LIGHT_SEQUENCE
|
||||
"|UNDOCA" ;
|
||||
|
||||
const uint8_t kLightSynonyms[] PROGMEM = {
|
||||
7, // number of entries
|
||||
37, 68, 82, 91, 92,
|
||||
105, 106,
|
||||
};
|
||||
|
||||
void (* const LightCommand[])(void) PROGMEM = {
|
||||
&CmndColor, &CmndColorTemperature, &CmndDimmer, &CmndDimmerRange, &CmndDimmerStep, &CmndLedTable, &CmndFade,
|
||||
&CmndRgbwwTable, &CmndScheme, &CmndSpeed, &CmndWakeup, &CmndWakeupDuration,
|
||||
|
@ -3078,7 +3088,7 @@ bool Xdrv04(uint8_t function)
|
|||
LightSetPower();
|
||||
break;
|
||||
case FUNC_COMMAND:
|
||||
result = DecodeCommand(kLightCommands, LightCommand);
|
||||
result = DecodeCommand(kLightCommands, LightCommand, kLightSynonyms);
|
||||
if (!result) {
|
||||
result = XlgtCall(FUNC_COMMAND);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue