summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cethcan/can.c10
-rw-r--r--cethcan/cethcan.h2
-rw-r--r--cethcan/cethcan.json4
-rw-r--r--cethcan/main.c7
-rwxr-xr-xcethcan/start19
-rw-r--r--svg/subcan.js27
-rw-r--r--svg/subcan_dxf.svg74
7 files changed, 124 insertions, 19 deletions
diff --git a/cethcan/can.c b/cethcan/can.c
index 5145871..39da3f1 100644
--- a/cethcan/can.c
+++ b/cethcan/can.c
@@ -40,10 +40,12 @@ void can_broadcast(struct can_user *origin, struct can_message *msg)
lprintf("invalid CAN message (DLC = %zu)", msg->dlc);
return;
}
- for (size_t i = 0; i < msg->dlc; i++)
- sprintf(buf + 3 * i, " %02x", msg->bytes[i]);
- lprintf("%s: %08x (%zu)%s", origin->name,
- (unsigned)msg->daddr, msg->dlc, buf);
+ if (verbosity >= 1) {
+ for (size_t i = 0; i < msg->dlc; i++)
+ sprintf(buf + 3 * i, " %02x", msg->bytes[i]);
+ lprintf("%s: %08x (%zu)%s", origin->name,
+ (unsigned)msg->daddr, msg->dlc, buf);
+ }
for (u = users; u; u = u->next)
if (u != origin)
diff --git a/cethcan/cethcan.h b/cethcan/cethcan.h
index ab5edde..5b42f54 100644
--- a/cethcan/cethcan.h
+++ b/cethcan/cethcan.h
@@ -27,6 +27,8 @@
#include "protocol.h"
+extern int verbosity;
+
#define lprintf(...) do { \
struct timeval tv; struct tm tm; char tvbuf[64]; \
gettimeofday(&tv, NULL); localtime_r(&tv.tv_sec, &tm); \
diff --git a/cethcan/cethcan.json b/cethcan/cethcan.json
index 25aaea8..ae84cb4 100644
--- a/cethcan/cethcan.json
+++ b/cethcan/cethcan.json
@@ -18,9 +18,9 @@
{ "addr": 1098, "name": "dali.hacklab.west.outer" }
],
"beans": [
- { "addr": 256, "name": "door.right", "values": [ "open", "closed" ] },
+ { "addr": 256, "name": "toilet.lock", "values": [ "open", "closed" ] },
{ "addr": 257, "name": "door.left", "values": [ "open", "closed" ] },
- { "addr": 258, "name": "door.light", "values": [ "triggered", "normal" ] },
+ { "addr": 258, "name": "door.right", "values": [ "open", "closed" ] },
{ "addr": 259, "name": "door.lock", "values": [ "open", "closed" ] }
],
"espnet": [ {
diff --git a/cethcan/main.c b/cethcan/main.c
index 961c543..2b9154e 100644
--- a/cethcan/main.c
+++ b/cethcan/main.c
@@ -2,6 +2,8 @@
struct event_base *ev_base;
+int verbosity = 0;
+
int main(int argc, char **argv)
{
int optch = 0;
@@ -11,11 +13,14 @@ int main(int argc, char **argv)
struct sigaction sa;
do {
- optch = getopt(argc, argv, "c:");
+ optch = getopt(argc, argv, "vc:");
switch (optch) {
case 'c':
cfgfile = optarg;
break;
+ case 'v':
+ verbosity++;
+ break;
case -1:
break;
}
diff --git a/cethcan/start b/cethcan/start
new file mode 100755
index 0000000..33a9be2
--- /dev/null
+++ b/cethcan/start
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+sleep 1
+
+/sbin/modprobe c_can_platform
+/sbin/modprobe can-raw
+
+sleep 1
+
+/sbin/ip link set can0 down
+/sbin/ip link set can0 type can tq 1500 prop-seg 2 phase-seg1 1 phase-seg2 2 sjw 1
+# /sbin/ip link set can0 type can bitrate 111111
+/sbin/ip link set can0 type can restart-ms 100 listen-only off berr-reporting on
+/sbin/ip link set can0 promisc on up
+
+sleep 1
+
+exec /root/spaceautomation/cethcan/cethcan
+
diff --git a/svg/subcan.js b/svg/subcan.js
index 63d0e74..4b328cf 100644
--- a/svg/subcan.js
+++ b/svg/subcan.js
@@ -45,12 +45,26 @@ function picker_begin(target) {
var pickelem = document.getElementById('picker');
pickelem.style.visibility = 'visible';
- picktimer = window.setTimeout(picker_end, 5000);
+ picktimer = window.setTimeout(picker_end, 30000);
}
function picker_refresh() {
window.clearTimeout(picktimer);
- picktimer = window.setTimeout(picker_end, 5000);
+ picktimer = window.setTimeout(picker_end, 30000);
+}
+
+function rgb2dmx(r, g, b) {
+ r = Math.floor((Math.pow(4.0, r / 255.0) - 1) / 3 * 255);
+ g = Math.floor((Math.pow(4.0, g / 255.0) - 1) / 3 * 180);
+ b = Math.floor((Math.pow(4.0, b / 255.0) - 1) / 3 * 144);
+ return [r,g,b];
+}
+function dmx2rgb(r, g, b) {
+ l4 = 255.0 / Math.log(4.0);
+ r = Math.floor(Math.log(r / 255.0 * 3 + 1) * l4);
+ g = Math.floor(Math.log(g / 180.0 * 3 + 1) * l4);
+ b = Math.floor(Math.log(g / 144.0 * 3 + 1) * l4);
+ return [r,g,b];
}
function on_picker(hex, hsv, rgb) {
@@ -58,7 +72,7 @@ function on_picker(hex, hsv, rgb) {
picker_refresh();
$.jsonRPC.request('light_set', {
- params: [picktgt, [rgb.r, rgb.g, rgb.b]],
+ params: [picktgt, rgb2dmx(rgb.r, rgb.g, rgb.b)],
error: function(result) {
console.log('light_set RGB error', result);
},
@@ -383,10 +397,11 @@ function update_elements(json) {
continue;
if (node.localName == "path") {
+ rgb = dmx2rgb(dataelem['r'], dataelem['g'], dataelem['b']);
node.style.fill = "rgb("
- + dataelem['r'] + ", "
- + dataelem['g'] + ", "
- + dataelem['b'] + ")";
+ + rgb[0] + ", "
+ + rgb[1] + ", "
+ + rgb[2] + ")";
} else {
console.log("unknown dynamic content type", node.localName);
}
diff --git a/svg/subcan_dxf.svg b/svg/subcan_dxf.svg
index 7e923c2..5a4ca69 100644
--- a/svg/subcan_dxf.svg
+++ b/svg/subcan_dxf.svg
@@ -175,8 +175,8 @@
borderopacity="1.0"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
- inkscape:zoom="1.3229167"
- inkscape:cx="420"
+ inkscape:zoom="1.3"
+ inkscape:cx="480"
inkscape:cy="240"
inkscape:document-units="px"
inkscape:current-layer="layer1"
@@ -234,6 +234,66 @@
</g>
<g
inkscape:groupmode="layer"
+ id="layer14"
+ inkscape:label="toilet.lock=open"
+ style="display:none">
+ <rect
+ style="fill:#6be56b;fill-opacity:1;stroke:none;display:inline"
+ id="rect4638"
+ width="47.586224"
+ height="50.368931"
+ x="709.59534"
+ y="389.13208" />
+ <text
+ xml:space="preserve"
+ style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:100%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:sans;-inkscape-font-specification:sans"
+ x="733.3819"
+ y="412.82153"
+ id="text4658"
+ sodipodi:linespacing="100%"><tspan
+ sodipodi:role="line"
+ x="733.3819"
+ y="412.82153"
+ id="tspan4662">WC frei</tspan><tspan
+ sodipodi:role="line"
+ x="733.3819"
+ y="422.82153"
+ id="tspan4668">WC free</tspan></text>
+ </g>
+ <g
+ inkscape:groupmode="layer"
+ id="layer15"
+ inkscape:label="toilet.lock=closed"
+ style="display:none">
+ <rect
+ style="fill:#e13737;fill-opacity:1;stroke:none;display:inline"
+ id="rect4638-3"
+ width="47.586224"
+ height="50.368931"
+ x="709.59534"
+ y="389.13208" />
+ <text
+ xml:space="preserve"
+ style="font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:100%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:sans;-inkscape-font-specification:sans"
+ x="733.56665"
+ y="406.98746"
+ id="text4658-1"
+ sodipodi:linespacing="100%"><tspan
+ sodipodi:role="line"
+ x="733.56665"
+ y="406.98746"
+ id="tspan4662-0">WC</tspan><tspan
+ sodipodi:role="line"
+ x="733.56665"
+ y="416.98746"
+ id="tspan4700">besetzt</tspan><tspan
+ sodipodi:role="line"
+ x="733.56665"
+ y="426.98746"
+ id="tspan4668-9">occupied</tspan></text>
+ </g>
+ <g
+ inkscape:groupmode="layer"
id="layer10"
inkscape:label="static_v2"
style="display:inline">
@@ -1004,9 +1064,10 @@
inkscape:connector-curvature="0" />
<path
style="font-size:9px;font-style:normal;font-weight:400;fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;font-family:Sans Serif"
- d="m 709.59531,439.50101 c 13.63094,0 27.26187,0 40.89281,0"
+ d="m 709.59531,439.50101 c 13.63094,0 33.95531,0 47.58625,0 l 0,-50.36334 -6.90808,-0.006"
id="polyline7219"
- inkscape:connector-curvature="0" />
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccc" />
<path
style="font-size:9px;font-style:normal;font-weight:400;fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;font-family:Sans Serif"
d="m 216.49552,439.50101 c 1.70434,0 3.40868,0 5.11302,0"
@@ -1140,9 +1201,10 @@
sodipodi:nodetypes="cc" />
<path
style="font-size:9px;font-style:normal;font-weight:400;fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;font-family:Sans Serif"
- d="m 750.48812,237.76391 c 0,67.2457 0,134.49141 0,201.7371"
+ d="m 750.48812,237.76391 c 0,67.2457 0,84.12247 0,151.36816"
id="polyline7333"
- inkscape:connector-curvature="0" />
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
<path
style="font-size:9px;font-style:normal;font-weight:400;fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;font-family:Sans Serif"
d="m 696.55143,168.24954 0,-1.36347"