From 61bfbfe2ecd148d34b7d1137c7e3d0a8ca4dd4e6 Mon Sep 17 00:00:00 2001 From: openshwprojects Date: Mon, 6 Mar 2023 15:39:16 +0100 Subject: [PATCH] two more channel types for fans --- docs/README.md | 2 +- docs/channelTypes.md | 2 ++ docs/json/channelTypes.json | 16 ++++++++++++++++ src/httpserver/http_fns.c | 16 ++++++++++++++-- src/new_pins.h | 14 ++++++++++++++ 5 files changed, 47 insertions(+), 3 deletions(-) diff --git a/docs/README.md b/docs/README.md index cc3fdcbf9..7252fbab6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,7 +5,7 @@ All descriptions were taken from code. Do not add anything here, as it will overwritten with next rebuild. | Section | Comment | |:------------- |------:| -| [Channel Types](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/channelTypes.md) (33 total) | todo | +| [Channel Types](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/channelTypes.md) (35 total) | todo | | [IO/Pin Roles](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/ioRoles.md) (65 total) | todo | | [Console/Script commands](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md) (225 total) | todo | | [Flags](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/flags.md) (38 total) | todo | diff --git a/docs/channelTypes.md b/docs/channelTypes.md index 4c15f5d8f..8841ceba9 100644 --- a/docs/channelTypes.md +++ b/docs/channelTypes.md @@ -37,4 +37,6 @@ Do not add anything here, as it will overwritten with next rebuild. | OpenClosed_Inv | Like OpenClosed, but values are inversed. | | BatteryLevelPercent | This will show current value as a battery level percent on the main WWW panel. | | OffDimBright | A 3 options radio button for lighting control. | +| LowMidHighHighest | Like LowMidHigh, but with 4 options. Some of TuyaMCU fans might require that. | +| OffLowMidHighHighest | Like LowMidHigh, but with 5 options. Some of TuyaMCU fans might require that. | | Max | This is the current total number of available channel types. | diff --git a/docs/json/channelTypes.json b/docs/json/channelTypes.json index de1168baf..2b0902679 100644 --- a/docs/json/channelTypes.json +++ b/docs/json/channelTypes.json @@ -255,6 +255,22 @@ "file": "new_pins.h", "driver": "" }, + { + "name": "LowMidHighHighest", + "title": "TODO", + "descr": "Like LowMidHigh, but with 4 options. Some of TuyaMCU fans might require that.", + "enum": "ChType_LowMidHighHighest", + "file": "new_pins.h", + "driver": "" + }, + { + "name": "OffLowMidHighHighest", + "title": "TODO", + "descr": "Like LowMidHigh, but with 5 options. Some of TuyaMCU fans might require that.", + "enum": "ChType_OffLowMidHighHighest", + "file": "new_pins.h", + "driver": "" + }, { "name": "Max", "title": "TODO", diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c index 0b5f64b7c..06d61f6fc 100644 --- a/src/httpserver/http_fns.c +++ b/src/httpserver/http_fns.c @@ -446,17 +446,29 @@ int http_fn_index(http_request_t* request) { poststr(request, ""); } - else if (channelType == ChType_OffLowMidHigh || channelType == ChType_OffLowestLowMidHighHighest || channelType == ChType_LowestLowMidHighHighest) { + else if (channelType == ChType_OffLowMidHigh || channelType == ChType_OffLowestLowMidHighHighest + || channelType == ChType_LowestLowMidHighHighest || channelType == ChType_LowMidHighHighest + || channelType == ChType_OffLowMidHighHighest) { const char** types; const char* types4[] = { "Off","Low","Mid","High" }; + const char* typesLowMidHighHighest[] = { "Low","Mid","High","Highest" }; + const char* typesOffLowMidHighHighest[] = { "Off", "Low","Mid","High","Highest" }; const char* types6[] = { "Off", "Lowest", "Low", "Mid", "High", "Highest" }; const char* types5NoOff[] = { "Lowest", "Low", "Mid", "High", "Highest" }; int numTypes; - + if (channelType == ChType_OffLowMidHigh) { types = types4; numTypes = 4; } + else if (channelType == ChType_LowMidHighHighest) { + types = typesLowMidHighHighest; + numTypes = 4; + } + else if (channelType == ChType_OffLowMidHighHighest) { + types = typesOffLowMidHighHighest; + numTypes = 5; + } else if (channelType == ChType_LowestLowMidHighHighest) { types = types5NoOff; numTypes = 5; diff --git a/src/new_pins.h b/src/new_pins.h index 2bd32d9e7..732a58836 100644 --- a/src/new_pins.h +++ b/src/new_pins.h @@ -690,6 +690,20 @@ typedef enum channelType_e { //chandetail:"file":"new_pins.h", //chandetail:"driver":""} ChType_OffDimBright, + //chandetail:{"name":"LowMidHighHighest", + //chandetail:"title":"TODO", + //chandetail:"descr":"Like LowMidHigh, but with 4 options. Some of TuyaMCU fans might require that.", + //chandetail:"enum":"ChType_LowMidHighHighest", + //chandetail:"file":"new_pins.h", + //chandetail:"driver":""} + ChType_LowMidHighHighest, + //chandetail:{"name":"OffLowMidHighHighest", + //chandetail:"title":"TODO", + //chandetail:"descr":"Like LowMidHigh, but with 5 options. Some of TuyaMCU fans might require that.", + //chandetail:"enum":"ChType_OffLowMidHighHighest", + //chandetail:"file":"new_pins.h", + //chandetail:"driver":""} + ChType_OffLowMidHighHighest, //chandetail:{"name":"Max", //chandetail:"title":"TODO", //chandetail:"descr":"This is the current total number of available channel types.",