From fc863eb38a863db95eab15f411b8343b0abfdfd2 Mon Sep 17 00:00:00 2001 From: openshwprojects Date: Mon, 10 Apr 2023 10:13:54 +0200 Subject: [PATCH] better html main page for case where we have both multiple relays and sensors --- src/httpserver/http_fns.c | 67 +++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c index ed48c22ec..872542b07 100644 --- a/src/httpserver/http_fns.c +++ b/src/httpserver/http_fns.c @@ -155,6 +155,7 @@ int http_fn_index(http_request_t* request) { int iValue; bool bForceShowRGB; const char* inputName; + int channelType; bRawPWMs = CFG_HasFlag(OBK_FLAG_LED_RAWCHANNELSMODE); bForceShowRGBCW = CFG_HasFlag(OBK_FLAG_LED_FORCESHOWRGBCWCONTROLLER); @@ -271,7 +272,6 @@ int http_fn_index(http_request_t* request) { poststr(request, ""); //Table default to 100% width in stylesheet for (i = 0; i < CHANNEL_MAX; i++) { - int channelType; channelType = CHANNEL_GetType(i); // check ability to hide given channel from gui @@ -294,7 +294,45 @@ int http_fn_index(http_request_t* request) { } } poststr(request, "
"); + poststr(request, ""); //Table default to 100% width in stylesheet + for (i = 0; i < CHANNEL_MAX; i++) { + + // check ability to hide given channel from gui + if (BIT_CHECK(g_hiddenChannels, i)) { + continue; // hidden + } + + channelType = CHANNEL_GetType(i); + if (h_isChannelRelay(i) || channelType == ChType_Toggle) { + const char* c; + const char *prefix; + if (i <= 1) { + hprintf255(request, ""); + } + if (CHANNEL_Check(i)) { + c = "bgrn"; + } + else { + c = "bred"; + } + poststr(request, "", c, prefix, CHANNEL_GetLabel(i)); + if (i == CHANNEL_MAX - 1) { + poststr(request, ""); + } + } + } + poststr(request, "
"); + hprintf255(request, "", i); + + if (CHANNEL_ShouldAddTogglePrefixToUI(i)) { + prefix = "Toggle "; + } + else { + prefix = ""; + } + + hprintf255(request, "
"); poststr(request, ""); //Table default to 100% width in stylesheet for (i = 0; i < PLATFORM_GPIO_MAX; i++) { int role; @@ -318,7 +356,6 @@ int http_fn_index(http_request_t* request) { } for (i = 0; i < CHANNEL_MAX; i++) { - int channelType; // check ability to hide given channel from gui if (BIT_CHECK(g_hiddenChannels, i)) { @@ -570,31 +607,7 @@ int http_fn_index(http_request_t* request) { poststr(request, ""); } else if (h_isChannelRelay(i) || channelType == ChType_Toggle) { - const char* c; - const char *prefix; - if (i <= 1) { - hprintf255(request, ""); - } - if (CHANNEL_Check(i)) { - c = "bgrn"; - } - else { - c = "bred"; - } - poststr(request, "", c, prefix, CHANNEL_GetLabel(i)); - if (i == CHANNEL_MAX - 1) { - poststr(request, ""); - } + // HANDLED ABOVE in previous loop } else if ((bRawPWMs && h_isChannelPWM(i)) || (channelType == ChType_Dimmer) || (channelType == ChType_Dimmer256) || (channelType == ChType_Dimmer1000)) { int maxValue;
"); - hprintf255(request, "", i); - - if (CHANNEL_ShouldAddTogglePrefixToUI(i)) { - prefix = "Toggle "; - } - else { - prefix = ""; - } - - hprintf255(request, "