From 2cc20dd211db43e31620661e674b20a0cb687a9b Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 30 Jun 2019 18:40:30 +0200 Subject: Tweak scaling between floating point and DMX values We want 0.5 (or 0.0 for -1..+1 attributes) to mean 128 exactly --- src/scanout.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/scanout.c b/src/scanout.c index 8a8b2d0..57a03da 100644 --- a/src/scanout.c +++ b/src/scanout.c @@ -34,11 +34,14 @@ static void set_val(int *dmx, int base_addr, int attr_offset, float value, int s int pos = base_addr + attr_offset - 1; if ( sixteenbit ) { - int val = value * 65535; + int val = value * 65536; + if ( val >= 65536 ) val = 65535; dmx[pos] = (val & 0xff00) >> 8; dmx[pos+1] = val & 0xff; } else { - dmx[pos] = value * 255; + int val = value * 255; + if ( val >= 255 ) val = 255; + dmx[pos] = value * 256; } } -- cgit v1.2.3