aqhome-cgi: fixed a bug with RGBW values on pages.
This commit is contained in:
@@ -260,36 +260,36 @@ uint32_t AQH_ModDevices_RgbwFromComponents(int r, int g, int b, int w)
|
||||
{
|
||||
uint32_t colorOut;
|
||||
|
||||
colorOut=((r & 0xff)<<16) | ((g & 0xff)<<24) | (b &0xff) | ((w & 0xff)<<8);
|
||||
colorOut=((r & 0xff)<<16) | ((g & 0xff)<<24) | (b & 0xff) | ((w & 0xff)<<8);
|
||||
return colorOut;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AQH_ModDevices_RgbwGetR(uint32_t color)
|
||||
{
|
||||
return (color & 0xff0000)>>16;
|
||||
{ /* GGRRWWBB */
|
||||
return (color & 0x00ff0000)>>16;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AQH_ModDevices_RgbwGetG(uint32_t color)
|
||||
{
|
||||
{ /* GGRRWWBB */
|
||||
return (color & 0xff000000)>>24;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AQH_ModDevices_RgbwGetB(uint32_t color)
|
||||
{
|
||||
return (color & 0xff);
|
||||
{ /* GGRRWWBB */
|
||||
return (color & 0x000000ff);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AQH_ModDevices_RgbwGetW(uint32_t color)
|
||||
{
|
||||
return (color & 0xff00)>>8;
|
||||
{ /* GGRRWWBB */
|
||||
return (color & 0x0000ff00)>>8;
|
||||
}
|
||||
|
||||
|
||||
@@ -485,6 +485,33 @@ int AQH_ModDevices_ValueGetLastDataAsInt(AQH_DATACLIENT *dc, const AQH_VALUE *va
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_ModDevices_ValueGetLastDataAsUint32(AQH_DATACLIENT *dc, const AQH_VALUE *value, uint32_t defaultValue)
|
||||
{
|
||||
const char *sValueSystemName;
|
||||
uint64_t dataPoints[2];
|
||||
uint64_t recvdNum;
|
||||
// uint64_t timestamp;
|
||||
union {double f; uint64_t i;} u;
|
||||
uint32_t uintVal;
|
||||
|
||||
sValueSystemName=AQH_Value_GetNameForSystem(value);
|
||||
recvdNum=AQH_DataClient_GetLastData(dc, sValueSystemName, &dataPoints[0], 1);
|
||||
if (recvdNum>0) {
|
||||
// timestamp=dataPoints[0];
|
||||
u.i=dataPoints[1];
|
||||
uintVal=(uint32_t) u.f;
|
||||
DBG_ERROR(NULL, "Transformed value %.2f -> %08x", u.f, uintVal);
|
||||
}
|
||||
else {
|
||||
DBG_INFO(NULL, "No last value for \"%s\"", sValueSystemName);
|
||||
uintVal=defaultValue;
|
||||
}
|
||||
|
||||
return uintVal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AQDG_GRAPH_DATAPAIR_LIST *AQH_ModDevices_RequestDataPairList(AQH_DATACLIENT *dc, const char *systemValueName,
|
||||
uint64_t tsBegin, uint64_t tsEnd, uint64_t num)
|
||||
|
||||
@@ -59,6 +59,7 @@ int AQH_ModDevices_RgbwGetW(uint32_t color);
|
||||
AQH_VALUE *AQH_ModDevices_GetValueForDevice(AQH_DATACLIENT *dc, const char *sDeviceName, const char *sValueName);
|
||||
AQH_DEVICE *AQH_ModDevices_GetDevice(AQH_DATACLIENT *dc, const char *sDeviceName);
|
||||
int AQH_ModDevices_ValueGetLastDataAsInt(AQH_DATACLIENT *dc, const AQH_VALUE *value, int defaultValue);
|
||||
uint32_t AQH_ModDevices_ValueGetLastDataAsUint32(AQH_DATACLIENT *dc, const AQH_VALUE *value, uint32_t defaultValue);
|
||||
|
||||
AQDG_GRAPH_DATAPAIR_LIST *AQH_ModDevices_RequestDataPairList(AQH_DATACLIENT *dc, const char *systemValueName,
|
||||
uint64_t tsBegin, uint64_t tsEnd, uint64_t num);
|
||||
|
||||
@@ -570,11 +570,11 @@ void _writeActor(AQH_DATACLIENT *dc, const char *sPageId, GWEN_XMLNODE *n, int l
|
||||
|
||||
value=AQH_ModDevices_GetValueForDevice(dc, sDeviceName, sValueName);
|
||||
if (value) {
|
||||
int lastData;
|
||||
uint32_t lastData;
|
||||
|
||||
if (layout!=MY_LAYOUT_NONE)
|
||||
GBAS(dbuf, "<td>\n");
|
||||
lastData=AQH_ModDevices_ValueGetLastDataAsInt(dc, value, 0);
|
||||
lastData=AQH_ModDevices_ValueGetLastDataAsUint32(dc, value, 0);
|
||||
GBAS(dbuf,"<form action=\"page.html\" method=\"post\">\n");
|
||||
GBAA(dbuf, "<input type=\"hidden\" name=\"page\" value=\"%s\">\n", sPageId);
|
||||
GBAA(dbuf, "<input type=\"hidden\" name=\"actor\" value=\"%s\">\n", sActorId);
|
||||
@@ -645,6 +645,12 @@ void _addGraphLink(const char *sPageId, const char *sGraphId, int w, int h, GWEN
|
||||
void _writeRgbwToForm(const char *sValueName, uint32_t color, GWEN_BUFFER *dbuf)
|
||||
{
|
||||
#if 1
|
||||
DBG_ERROR(NULL, "Color=%08x (%d, %d, %d, %d)",
|
||||
color,
|
||||
AQH_ModDevices_RgbwGetR(color),
|
||||
AQH_ModDevices_RgbwGetG(color),
|
||||
AQH_ModDevices_RgbwGetB(color),
|
||||
AQH_ModDevices_RgbwGetW(color));
|
||||
GBAA(dbuf, "<label for=\"%s_r\">R:</label>", sValueName);
|
||||
GBAA(dbuf, "<input type=\"number\" min=\"0\" max=\"255\" name=\"%s_r\" id=name=\"%s_r\" value=\"%d\">",
|
||||
sValueName, sValueName, AQH_ModDevices_RgbwGetR(color));
|
||||
|
||||
@@ -80,7 +80,7 @@ void AQH_ModDevices_RunSetDevice(AQH_MODULE *m, AQCGI_REQUEST *rq, AQH_SESSION *
|
||||
GWEN_BUFFER *pbuf;
|
||||
|
||||
pbuf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||
GBAS(pbuf, "Location: /aqbt/devices/device.html?device=");
|
||||
GBAS(pbuf, "Location: device.html?device=");
|
||||
GWEN_Text_EscapeToBuffer(sDeviceName, pbuf);
|
||||
AQCGI_Request_AddResponseHeaderData(rq, GWEN_Buffer_GetStart(pbuf));
|
||||
GWEN_Buffer_free(pbuf);
|
||||
|
||||
Reference in New Issue
Block a user