summaryrefslogtreecommitdiff
path: root/src/scanout.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-06-26 09:18:22 +0200
committerThomas White <taw@physics.org>2019-06-27 23:02:59 +0200
commite07e0540e7b599e09fa009a4e2c165b01a7a34e3 (patch)
treeb1d2f1e3d4ce812a4eac4493f051eae09c16a465 /src/scanout.c
parentc269b1fa9eaa247ef2b863367c249b996b4a01be (diff)
New way of doing attributes
The program now has its own view of what it wants ("this position", "this gobo" etc), and the fixture class contains instructions on how to turn that view into DMX values.
Diffstat (limited to 'src/scanout.c')
-rw-r--r--src/scanout.c94
1 files changed, 76 insertions, 18 deletions
diff --git a/src/scanout.c b/src/scanout.c
index 53d78c9..53e5948 100644
--- a/src/scanout.c
+++ b/src/scanout.c
@@ -28,6 +28,21 @@
#include "nanolight.h"
+static void set_val(int *dmx, int base_addr, int attr_offset, float value, int sixteenbit)
+{
+ /* Minus one to convert DMX address to indexing in 'dmx' array */
+ int pos = base_addr + attr_offset - 1;
+
+ if ( sixteenbit ) {
+ int val = value * 65535;
+ dmx[pos] = (val & 0xff00) >> 8;
+ dmx[pos+1] = val & 0xff;
+ } else {
+ dmx[pos] = value * 255;
+ }
+}
+
+
int scanout_all(struct nanolight *nl)
{
SoupSession *sess;
@@ -42,32 +57,75 @@ int scanout_all(struct nanolight *nl)
/* Loop over fixtures and set values */
for ( i=0; i<nl->n_fixtures; i++ ) {
+
int j;
struct fixture *fix = &nl->fixtures[i];
- for ( j=0; j<fix->cls->n_attrs; j++ ) {
+ struct fixture_class *cls = fix->cls;
- /* Minus one to convert DMX address to indexing in 'dmx' array */
- int pos = fix->base_addr + fix->cls->attrs[j].addr_offset - 1;
+ if ( universe < 0 ) universe = fix->universe;
+ if ( fix->universe != universe ) {
+ fprintf(stderr, "Sorry, only one universe for now!\n");
+ abort();
+ }
- if ( universe < 0 ) universe = fix->universe;
- if ( fix->universe != universe ) {
- fprintf(stderr, "Sorry, only one universe for now!\n");
- abort();
- }
+ for ( j=0; j<cls->n_magic; j++ ) {
+ dmx[fix->base_addr + cls->magic_chans[j] - 1] = cls->magic_vals[j];
+ }
- if ( fix->cls->attrs[j].props & ATTR_STOP ) {
+ if ( cls->attributes & INTENSITY ) {
+ set_val(dmx, fix->base_addr, cls->intensity_offset, fix->intensity,
+ cls->attributes16 & INTENSITY);
+ }
- int v = fix->attr_vals[j];
- assert(!(fix->cls->attrs[j].props & ATTR_16BIT));
- dmx[pos] = fix->cls->attrs[j].stops[v];
+ if ( cls->attributes & PANTILT ) {
+ float pan_val, tilt_val;
+ pan_val = (fix->pan + 1.0)/2.0;
+ tilt_val = (fix->tilt + 1.0)/2.0;
+ set_val(dmx, fix->base_addr, cls->pan_offset, pan_val,
+ cls->attributes16 & PANTILT);
+ set_val(dmx, fix->base_addr, cls->tilt_offset, tilt_val,
+ cls->attributes16 & PANTILT);
+ }
- } else if ( fix->cls->attrs[j].props & ATTR_16BIT ) {
- dmx[pos] = (fix->attr_vals[j] & 0xff00) >> 8;
- dmx[pos+1] = fix->attr_vals[j] & 0xff;
- } else {
- dmx[pos] = fix->attr_vals[j];
- }
+ if ( cls->attributes & COL_CMY ) {
+ set_val(dmx, fix->base_addr, cls->cyan_offset, fix->cyan,
+ cls->attributes16 & COL_CMY);
+ set_val(dmx, fix->base_addr, cls->magenta_offset, fix->magenta,
+ cls->attributes16 & COL_CMY);
+ set_val(dmx, fix->base_addr, cls->yellow_offset, fix->yellow,
+ cls->attributes16 & COL_CMY);
}
+
+ if ( cls->attributes & COL_RGB ) {
+ set_val(dmx, fix->base_addr, cls->red_offset, fix->red,
+ cls->attributes16 & COL_RGB);
+ set_val(dmx, fix->base_addr, cls->green_offset, fix->green,
+ cls->attributes16 & COL_RGB);
+ set_val(dmx, fix->base_addr, cls->blue_offset, fix->blue,
+ cls->attributes16 & COL_RGB);
+ }
+
+ if ( cls->attributes & FOCUS ) {
+ set_val(dmx, fix->base_addr, cls->focus_offset, fix->focus,
+ cls->attributes16 & FOCUS);
+ }
+
+ if ( cls->attributes & ZOOM ) {
+ set_val(dmx, fix->base_addr, cls->zoom_offset, fix->zoom,
+ cls->attributes16 & ZOOM);
+ }
+
+ if ( cls->attributes & FROST ) {
+ set_val(dmx, fix->base_addr, cls->frost_offset, fix->frost,
+ cls->attributes16 & FROST);
+ }
+
+ if ( cls->attributes & IRIS ) {
+ set_val(dmx, fix->base_addr, cls->iris_offset, fix->iris,
+ cls->attributes16 & IRIS);
+ }
+
+
}
if ( universe == -1 ) return 0; /* Nothing to do! */