diff --git a/docs/commands-extended.md b/docs/commands-extended.md
index 9aad24821..3787d0750 100644
--- a/docs/commands-extended.md
+++ b/docs/commands-extended.md
@@ -18,7 +18,7 @@ Do not add anything here, as it will overwritten with next rebuild.
| PinDeepSleep | | Starts a pin deep sleep (deep sleep that can be interrupted by external IO events like a button press) | File: cmnds/cmd_channels.c
Function: CMD_PinDeepSleep |
| SetFlag | [FlagIndex][1or0] | Enables/disables given flag. | File: cmnds/cmd_channels.c
Function: CMD_SetFlag |
| FullBootTime | [Value] | Sets time in seconds after which boot is marked as valid. This is related to emergency AP mode which is enabled by powering on/off device 5 times quickly. | File: cmnds/cmd_channels.c
Function: CMD_FullBootTime |
-| SetChannelLabel | [ChannelIndex][Str] | Sets a channel label for UI. | File: cmnds/cmd_channels.c
Function: CMD_SetChannelLabel |
+| SetChannelLabel | [ChannelIndex][Str][bHideTogglePrefix] | Sets a channel label for UI. If you use 1 for bHideTogglePrefix, then the 'Toggle ' prefix from button will be omitted | File: cmnds/cmd_channels.c
Function: CMD_SetChannelLabel |
| MapRanges | [TargetChannel][InputValue][RangeVal0][RangeVal1][RangeValN] | This will set given channel to an index showing where given input value is within given range sections. For example, MapRanges 10 0.5 0.3 0.6 0.9 will set channel 10 to 1 because 0.5 value is between 0.3 and 0.6 | File: cmnds/cmd_channels.c
Function: CMD_MapRanges |
| Map | [TargetChannel][InputValue][InMin][InMax][OutMin][OutMax] | qqq | File: cmnds/cmd_channels.c
Function: CMD_Map |
| SetChannelVisible | | NULL | File: cmnds/cmd_channels.c
Function: CMD_SetChannelVisible |
diff --git a/docs/commands.md b/docs/commands.md
index c3c88f988..785943f19 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -18,7 +18,7 @@ Do not add anything here, as it will overwritten with next rebuild.
| PinDeepSleep | | Starts a pin deep sleep (deep sleep that can be interrupted by external IO events like a button press) |
| SetFlag | [FlagIndex][1or0] | Enables/disables given flag. |
| FullBootTime | [Value] | Sets time in seconds after which boot is marked as valid. This is related to emergency AP mode which is enabled by powering on/off device 5 times quickly. |
-| SetChannelLabel | [ChannelIndex][Str] | Sets a channel label for UI. |
+| SetChannelLabel | [ChannelIndex][Str][bHideTogglePrefix] | Sets a channel label for UI. If you use 1 for bHideTogglePrefix, then the 'Toggle ' prefix from button will be omitted |
| MapRanges | [TargetChannel][InputValue][RangeVal0][RangeVal1][RangeValN] | This will set given channel to an index showing where given input value is within given range sections. For example, MapRanges 10 0.5 0.3 0.6 0.9 will set channel 10 to 1 because 0.5 value is between 0.3 and 0.6 |
| Map | [TargetChannel][InputValue][InMin][InMax][OutMin][OutMax] | qqq |
| SetChannelVisible | | NULL |
diff --git a/docs/json/commands.json b/docs/json/commands.json
index 58235a671..aae81b836 100644
--- a/docs/json/commands.json
+++ b/docs/json/commands.json
@@ -118,8 +118,8 @@
},
{
"name": "SetChannelLabel",
- "args": "[ChannelIndex][Str]",
- "descr": "Sets a channel label for UI.",
+ "args": "[ChannelIndex][Str][bHideTogglePrefix]",
+ "descr": "Sets a channel label for UI. If you use 1 for bHideTogglePrefix, then the 'Toggle ' prefix from button will be omitted",
"fn": "CMD_SetChannelLabel",
"file": "cmnds/cmd_channels.c",
"requires": "",
diff --git a/src/cmnds/cmd_channels.c b/src/cmnds/cmd_channels.c
index 4d528c246..f7f4e901e 100644
--- a/src/cmnds/cmd_channels.c
+++ b/src/cmnds/cmd_channels.c
@@ -11,8 +11,9 @@
// If given bit is set, then given channel is hidden
int g_hiddenChannels = 0;
static char *g_channelLabels[CHANNEL_MAX] = { 0 };
+static int g_bHideTogglePrefix = 0;
-void CHANNEL_SetLabel(int ch, const char *s) {
+void CHANNEL_SetLabel(int ch, const char *s, int bHideTogglePrefix) {
if (ch < 0)
return;
if (ch >= CHANNEL_MAX)
@@ -20,6 +21,18 @@ void CHANNEL_SetLabel(int ch, const char *s) {
if (g_channelLabels[ch])
free(g_channelLabels[ch]);
g_channelLabels[ch] = strdup(s);
+ if (ch >= 0 && ch <= 32) {
+ BIT_SET_TO(g_bHideTogglePrefix, ch, bHideTogglePrefix);
+ }
+}
+bool CHANNEL_ShouldAddTogglePrefixToUI(int ch) {
+ if (ch < 0)
+ return true;
+ if (ch >= 32)
+ return true;
+ if (BIT_CHECK(g_bHideTogglePrefix, ch))
+ return false;
+ return true;
}
const char *CHANNEL_GetLabel(int ch) {
if (ch >= 0 && ch < CHANNEL_MAX) {
@@ -34,6 +47,7 @@ const char *CHANNEL_GetLabel(int ch) {
static commandResult_t CMD_SetChannelLabel(const void *context, const char *cmd, const char *args, int cmdFlags) {
int ch;
const char *s;
+ int bHideTogglePrefix = 0;
Tokenizer_TokenizeString(args, TOKENIZER_ALLOW_QUOTES);
// following check must be done after 'Tokenizer_TokenizeString',
@@ -45,8 +59,11 @@ static commandResult_t CMD_SetChannelLabel(const void *context, const char *cmd,
ch = Tokenizer_GetArgInteger(0);
s = Tokenizer_GetArg(1);
+ if (Tokenizer_GetArgsCount() > 2) {
+ bHideTogglePrefix = Tokenizer_GetArg(2);
+ }
- CHANNEL_SetLabel(ch, s);
+ CHANNEL_SetLabel(ch, s, bHideTogglePrefix);
return CMD_RES_OK;
}
@@ -454,8 +471,8 @@ void CMD_InitChannelCommands(){
//cmddetail:"fn":"CMD_FullBootTime","file":"cmnds/cmd_channels.c","requires":"",
//cmddetail:"examples":""}
CMD_RegisterCommand("FullBootTime", CMD_FullBootTime, NULL);
- //cmddetail:{"name":"SetChannelLabel","args":"[ChannelIndex][Str]",
- //cmddetail:"descr":"Sets a channel label for UI.",
+ //cmddetail:{"name":"SetChannelLabel","args":"[ChannelIndex][Str][bHideTogglePrefix]",
+ //cmddetail:"descr":"Sets a channel label for UI. If you use 1 for bHideTogglePrefix, then the 'Toggle ' prefix from button will be omitted",
//cmddetail:"fn":"CMD_SetChannelLabel","file":"cmnds/cmd_channels.c","requires":"",
//cmddetail:"examples":""}
CMD_RegisterCommand("SetChannelLabel", CMD_SetChannelLabel, NULL);
diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c
index fdf8d33ac..e1b109a81 100644
--- a/src/httpserver/http_fns.c
+++ b/src/httpserver/http_fns.c
@@ -635,6 +635,7 @@ int http_fn_index(http_request_t* request) {
}
else if (h_isChannelRelay(i) || channelType == ChType_Toggle) {
const char* c;
+ const char *prefix;
if (i <= 1) {
hprintf255(request, "