summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-06-14 23:49:28 +0200
committerThomas White <taw@physics.org>2019-06-14 23:49:28 +0200
commit6969eb14314ab89a100394a5f6f327e53258cc95 (patch)
tree01e971f5defff343c16c3153f4aa67445c3511cc
parent8fde1a64d48b1456520cc042a6121f29b72b866f (diff)
Move DMX universe number into fixture
-rw-r--r--src/nanolight.c11
-rw-r--r--src/nanolight.h1
-rw-r--r--src/scanout.c10
3 files changed, 16 insertions, 6 deletions
diff --git a/src/nanolight.c b/src/nanolight.c
index 46f6efc..9b3c699 100644
--- a/src/nanolight.c
+++ b/src/nanolight.c
@@ -238,7 +238,7 @@ static gboolean draw_sig(GtkWidget *widget, cairo_t *cr, struct nanolight *nl)
static struct fixture *create_fixture(struct nanolight *nl, struct fixture_class *cls,
- const char *label, int base_addr)
+ const char *label, int universe, int base_addr)
{
struct fixture *fix;
int i;
@@ -253,6 +253,7 @@ static struct fixture *create_fixture(struct nanolight *nl, struct fixture_class
fix = &nl->fixtures[nl->n_fixtures++];
fix->label = strdup(label);
+ fix->universe = universe;
fix->base_addr = base_addr;
fix->cls = cls;
fix->attr_vals = calloc(cls->n_attrs, sizeof(int));
@@ -626,10 +627,10 @@ int main(int argc, char *argv[])
nl.sel_attr = ATT_TILT;
nl.dragging = 0;
- create_fixture(&nl, &cls, "mh1", 1);
- create_fixture(&nl, &cls, "mh2", 52);
- create_fixture(&nl, &cls, "mh3", 103);
- create_fixture(&nl, &cls, "mh4", 154);
+ create_fixture(&nl, &cls, "mh1", 0, 1);
+ create_fixture(&nl, &cls, "mh2", 0, 52);
+ create_fixture(&nl, &cls, "mh3", 0, 103);
+ create_fixture(&nl, &cls, "mh4", 0, 154);
/* Set up output */
g_timeout_add(100, scanout_cb, &nl);
diff --git a/src/nanolight.h b/src/nanolight.h
index 1e0a0fd..046ea38 100644
--- a/src/nanolight.h
+++ b/src/nanolight.h
@@ -58,6 +58,7 @@ struct fixture_class
struct fixture
{
char *label;
+ int universe;
int base_addr;
struct fixture_class *cls;
int *attr_vals;
diff --git a/src/scanout.c b/src/scanout.c
index 49c6b6b..a12094f 100644
--- a/src/scanout.c
+++ b/src/scanout.c
@@ -34,6 +34,7 @@ int scanout_all(struct nanolight *nl)
int i;
int dmx[512];
char str[8200];
+ signed int universe = -1;
/* Start from zero */
for ( i=0; i<512; i++ ) dmx[i] = 0;
@@ -45,6 +46,11 @@ int scanout_all(struct nanolight *nl)
for ( j=0; j<fix->cls->n_attrs; j++ ) {
/* 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 ( fix->cls->attrs[j].props & ATTR_16BIT ) {
dmx[pos] = (fix->attr_vals[j] & 0xff00) >> 8;
dmx[pos+1] = fix->attr_vals[j] & 0xff;
@@ -54,8 +60,10 @@ int scanout_all(struct nanolight *nl)
}
}
+ if ( universe == -1 ) return 0; /* Nothing to do! */
+
/* Loop over DMX channels and prepare request */
- strcpy(str, "u=1&d=");
+ snprintf(str, 16, "u=%i&d=", universe);
for ( i=0; i<512; i++ ) {
char tmp[6];
snprintf(tmp, 5, "%i,", dmx[i]);