summaryrefslogtreecommitdiff
path: root/src/illuminate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/illuminate.c')
-rw-r--r--src/illuminate.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/illuminate.c b/src/illuminate.c
index a0f146d..92c8fac 100644
--- a/src/illuminate.c
+++ b/src/illuminate.c
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include "illuminate.h"
// FTDI Vendor ID
@@ -84,12 +85,22 @@ int dmx_init() {
return 0;
}
+inline int projector_correction(int in) {
+ //int out=powf(((in-108.f)/162.f),3.f)*256.f+80.f;
+ int out=in*0.25f+0.75*(powf(((in-100.f)/162.f),3.f)*256.f+48.f);
+ if (out>255) out=255;
+ if (out<0) out=0;
+ return out;
+}
+
int dmx_write_rgb(int r, int g, int b) {
if (! ftdi.usb_dev ) return -1;
- universe[2]=r;
- universe[3]=g;
- universe[4]=b;
+ universe[2]=projector_correction(r);
+ universe[3]=projector_correction(g);
+ universe[4]=projector_correction(b);
+
+// printf("rgb %3i %3i %3i dmx %3i %3i %3i\n", r,g,b, universe[2], universe[3], universe[4]);
return dmx_universe_write(&ftdi, universe, DMX_CHANNELS);
}