aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2020-02-28 21:10:45 +0100
committercbdev <cb@cbcdn.com>2020-02-28 21:10:45 +0100
commit454e757f740b74d714e9fa47bfa4954cb30e67ba (patch)
treea850ba74bc2f7c241dd7831f97d536502c48c126
parenta103c7a7dcabdb84399dce2a1ed517299d0f5414 (diff)
downloadmidimonster-454e757f740b74d714e9fa47bfa4954cb30e67ba.tar.gz
midimonster-454e757f740b74d714e9fa47bfa4954cb30e67ba.tar.bz2
midimonster-454e757f740b74d714e9fa47bfa4954cb30e67ba.zip
Implement openpixelcontrol 16bit server mode
-rw-r--r--backends/openpixelcontrol.c35
-rw-r--r--backends/openpixelcontrol.md2
2 files changed, 32 insertions, 5 deletions
diff --git a/backends/openpixelcontrol.c b/backends/openpixelcontrol.c
index 0f590c6..62cdb68 100644
--- a/backends/openpixelcontrol.c
+++ b/backends/openpixelcontrol.c
@@ -385,9 +385,38 @@ static ssize_t openpixel_client_pixeldata(instance* inst, openpixel_client* clie
return u;
}
else{
- //TODO byte-order conversion may be on recv boundary
- //if over buffer length, ignore
- //skip non-multiple-of 6 trailing data
+ for(u = 0; u < bytes_left; u++){
+ //if over buffer length, ignore
+ if(u + client->offset >= data->buffer[client->buffer].bytes){
+ client->buffer = -2;
+ break;
+ }
+
+ //if at start of trailing non-multiple of 6, ignore
+ if((client->offset + u) >= (client->offset + client->left) - ((client->offset + client->left) % 6)){
+ client->buffer = -2;
+ break;
+ }
+
+ //byte-order conversion may be on message boundary, do it via a buffer
+ client->boundary.u8[(client->offset + u) % 2] = buffer[u];
+
+ //detect and update changed channels
+ if((client->offset + u) % 2
+ && data->buffer[client->buffer].data.u16[(u + client->offset) / 2] != be16toh(client->boundary.u16)){
+ data->buffer[client->buffer].data.u16[(u + client->offset) / 2] = be16toh(client->boundary.u16);
+ chan = mm_channel(inst, ((uint64_t) client->hdr.strip << 32) | ((u + client->offset) / 2 + 1), 0);
+ if(chan){
+ //push event
+ val.raw.u64 = be16toh(client->boundary.u16);;
+ val.normalised = (double) val.raw.u64 / 65535.0;
+ if(mm_channel_event(chan, val)){
+ LOG("Failed to push channel event to core");
+ }
+ }
+
+ }
+ }
}
}
return -1;
diff --git a/backends/openpixelcontrol.md b/backends/openpixelcontrol.md
index 6dd38bc..5a8686f 100644
--- a/backends/openpixelcontrol.md
+++ b/backends/openpixelcontrol.md
@@ -50,5 +50,3 @@ This behaviour may be changed in future releases.
While acting as an OpenPixelControl server, the backend allows multiple clients to connect.
This may lead to confusing data output when multiple clients are trying to control the same strip.
-
-16 bit server mode is not implemented yet. This will be fixed in a future release.