More work on aqhome-cgi.

This commit is contained in:
Martin Preuss
2025-10-09 20:19:04 +02:00
parent d0c8b3b284
commit 5a16117240
7 changed files with 95 additions and 43 deletions

View File

@@ -59,6 +59,8 @@ static void _writeValueListToTable(AQH_DATACLIENT *dc, const AQH_VALUE_LIST *val
static void _writeValueToTable(AQH_DATACLIENT *dc, const AQH_VALUE *value, GWEN_BUFFER *dbuf);
static void _addValueActionToForm(const AQH_VALUE *value, GWEN_BUFFER *dbuf);
static uint32_t _colorFromHexString(const char *s);
static uint32_t _htmlColorToValueRGBW(uint32_t colorIn);
static uint32_t _rgbwToHtmlColor(uint32_t colorIn);
static void _setRgbwData(AQH_DATACLIENT *dc, const AQH_VALUE *value, const char *sValue);
static void _setOnOffData(AQH_DATACLIENT *dc, const AQH_VALUE *value, const char *sValue);
static void _setOnOffAutoData(AQH_DATACLIENT *dc, const AQH_VALUE *value, const char *sValue);
@@ -404,7 +406,8 @@ void _writeValueListToTable(AQH_DATACLIENT *dc, const AQH_VALUE_LIST *valueList,
value=AQH_Value_List_First(valueList);
while(value) {
_writeValueToTable(dc, value, dbuf);
if (AQH_Value_GetModality(value)!=AQH_ValueModality_Stats)
_writeValueToTable(dc, value, dbuf);
value=AQH_Value_List_Next(value);
}
GBAS(dbuf,
@@ -487,7 +490,6 @@ void _addValueActionToForm(const AQH_VALUE *value, GWEN_BUFFER *dbuf)
uint32_t _colorFromHexString(const char *s)
{
uint32_t colorIn=0;
uint32_t colorOut;
while(*s && *s<33)
s++;
@@ -505,7 +507,30 @@ uint32_t _colorFromHexString(const char *s)
}
/* hex 00RRGGBB -> GGRRWWBB */
colorOut=(colorIn & 0x00ff0000) | ((colorIn & 0x00ff00)<<16) | (colorIn & 0x0000ff);
//return _htmlColorToValueRGBW(colorIn);
return colorIn;
}
uint32_t _htmlColorToValueRGBW(uint32_t colorIn)
{
uint32_t colorOut;
/* hex 00RRGGBB -> GGRRWWBB */
/* RGBW GGRRWWBB GGRRWWBB GGRRWWBB */
/* html 00RRGGBB 00RRGGBB 00RRGGBB*/
colorOut=(colorIn & 0x00ff0000) | ((colorIn<<16) & 0xff000000) | (colorIn & 0x000000ff);
return colorOut;
}
uint32_t _rgbwToHtmlColor(uint32_t colorIn)
{
uint32_t colorOut;
/* RGBW GGRRWWBB GGRRWWBB GGRRWWBB */
/* hex 00RRGGBB 00RRGGBB 00RRGGBB*/
colorOut=(colorIn & 0x00ff0000) | ( (colorIn>>16) & 0x0000ff00) | (colorIn & 0x000000ff);
return colorOut;
}
@@ -627,7 +652,20 @@ void _addLastValueToForm(AQH_DATACLIENT *dc, const AQH_VALUE *value, GWEN_BUFFER
DBG_ERROR(NULL, "Adding actor");
switch(AQH_Value_GetModality(value)) {
case AQH_ValueModality_RGBW:
GBAA(dbuf, "<input type=\"color\" name=\"%s\" value=\"#%08x\"/>", sValueName, (unsigned int) u.f);
DBG_ERROR(NULL, "Color: %.f RGBW=%08x HTML=%08x, RGBW2=%08x",
u.f,
(uint32_t) (u.f),
_rgbwToHtmlColor(u.f),
_htmlColorToValueRGBW(_rgbwToHtmlColor(u.f)));
#if 1
GBAA(dbuf, "<input type=\"text\" name=\"%s\" value=\"#%08x\"/>", sValueName, (uint32_t) (u.f));
#else
GBAA(dbuf, "<input type=\"color\" name=\"%s\" value=\"#%08x\"/>#%08x (#%08x)",
sValueName,
_rgbwToHtmlColor((unsigned int) (u.f)),
_rgbwToHtmlColor((unsigned int) (u.f)),
(uint32_t) (u.f));
#endif
break;
case AQH_ValueModality_OnOff:
GBAA(dbuf, "<select name=\"%s\">" "<option value=\"unchanged\" >unchanged</option>", sValueName);
@@ -643,7 +681,7 @@ void _addLastValueToForm(AQH_DATACLIENT *dc, const AQH_VALUE *value, GWEN_BUFFER
GBAS(dbuf, "</select>");
break;
default:
// GBAA(dbuf, "<input type=\"text\" name=\"%s\" value=\"%.2f\"/>", sValueName, u.f);
// GBAA(dbuf, "<input type=\"text\" name=\"%s\" value=\"%.2f\"/>", sValueName, u.f);
GBAA(dbuf, "%.2f", u.f);
break;
} /* switch */