diff options
author | Thomas White <taw@physics.org> | 2019-06-30 18:40:30 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2019-06-30 18:40:30 +0200 |
commit | 2cc20dd211db43e31620661e674b20a0cb687a9b (patch) | |
tree | 3f7018735b6d44b64947c4a37f2265c6dc087afc /src | |
parent | f80065c24765ee1fcfc075c77f7ea55984a1d715 (diff) |
Tweak scaling between floating point and DMX values
We want 0.5 (or 0.0 for -1..+1 attributes) to mean 128 exactly
Diffstat (limited to 'src')
-rw-r--r-- | src/scanout.c | 7 |
1 files 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; } } |