diff --git a/projects/IoTCenter/Views/Home/Node.cshtml b/projects/IoTCenter/Views/Home/Node.cshtml index 508228d4..59a108de 100644 --- a/projects/IoTCenter/Views/Home/Node.cshtml +++ b/projects/IoTCenter/Views/Home/Node.cshtml @@ -108,7 +108,12 @@
-

{{device.DisplayName||device.Name}}

+

+ {{device.DisplayName||device.Name}}{{getLightColor(GetDataValue(device.Number,'色调'),GetDataValue(device.Number,'饱和度'),GetDataValue(device.Number,'亮度'))}} +

@@ -613,8 +618,9 @@
@section scripts{ + - } \ No newline at end of file diff --git a/projects/IoTCenter/iotcenter.db b/projects/IoTCenter/iotcenter.db index d0336941..6db246fd 100644 Binary files a/projects/IoTCenter/iotcenter.db and b/projects/IoTCenter/iotcenter.db differ diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/node.js b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/node.js index ab80916d..1c186035 100644 --- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/node.js +++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/node.js @@ -457,9 +457,71 @@ function init() { Vue.nextTick(function () { ajax(url, null, 'get'); }); + }, + getLightColor(h, s, v) { + return hsvToRgb(parseInt(h * 360 / 255), parseInt(s * 100 / 255), parseInt(v * 100 / 255)); } } }); } -/*exec*/ -loadData(); +function hsvToRgb(h, s, v) { + if (h == "") h = 0; + if (s == "") s = 0; + if (v == "") v = 0; + h = parseFloat(h); + s = parseFloat(s); + v = parseFloat(v); + if (h < 0) h = 0; + if (s < 0) s = 0; + if (v < 0) v = 0; + if (h >= 360) h = 359; + if (s > 100) s = 100; + if (v > 100) v = 100; + s /= 100.0; + v /= 100.0; + C = v * s; + hh = h / 60.0; + X = C * (1.0 - Math.abs((hh % 2) - 1.0)); + r = g = b = 0; + if (hh >= 0 && hh < 1) { + r = C; + g = X; + } + else if (hh >= 1 && hh < 2) { + r = X; + g = C; + } + else if (hh >= 2 && hh < 3) { + g = C; + b = X; + } + else if (hh >= 3 && hh < 4) { + g = X; + b = C; + } + else if (hh >= 4 && hh < 5) { + r = X; + b = C; + } + else { + r = C; + b = X; + } + m = v - C; + r += m; + g += m; + b += m; + r *= 255.0; + g *= 255.0; + b *= 255.0; + r = Math.round(r); + g = Math.round(g); + b = Math.round(b); + hex = r * 65536 + g * 256 + b; + hex = hex.toString(16, 6); + len = hex.length; + if (len < 6) + for (i = 0; i < 6 - len; i++) + hex = '0' + hex; + return '#' + hex; +} \ No newline at end of file diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/node.html b/projects/IoTClient/Assets/StreamingAssets/wwwroot/node.html index ae3d6f62..313c2111 100644 --- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/node.html +++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/node.html @@ -77,7 +77,12 @@
-

{{device.DisplayName||device.Name}}

+

+ {{device.DisplayName||device.Name}}{{getLightColor(GetDataValue(device.Number,'色调'),GetDataValue(device.Number,'饱和度'),GetDataValue(device.Number,'亮度'))}} +

@@ -131,9 +136,10 @@ + - \ No newline at end of file diff --git a/projects/IoTNode/iotnode.db b/projects/IoTNode/iotnode.db index 29ab849e..6501d9c1 100644 Binary files a/projects/IoTNode/iotnode.db and b/projects/IoTNode/iotnode.db differ