diff --git a/apps/aqhome-cgi/modules/devices/mdevices.c b/apps/aqhome-cgi/modules/devices/mdevices.c index aef7878..12939d6 100644 --- a/apps/aqhome-cgi/modules/devices/mdevices.c +++ b/apps/aqhome-cgi/modules/devices/mdevices.c @@ -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) diff --git a/apps/aqhome-cgi/modules/devices/mdevices.h b/apps/aqhome-cgi/modules/devices/mdevices.h index fadfe80..047155d 100644 --- a/apps/aqhome-cgi/modules/devices/mdevices.h +++ b/apps/aqhome-cgi/modules/devices/mdevices.h @@ -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); diff --git a/apps/aqhome-cgi/modules/devices/mdevices_page.c b/apps/aqhome-cgi/modules/devices/mdevices_page.c index 60eac5c..f6def1d 100644 --- a/apps/aqhome-cgi/modules/devices/mdevices_page.c +++ b/apps/aqhome-cgi/modules/devices/mdevices_page.c @@ -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, "