From 1d36406d88766d5e54a1f4a27ce6f6d90e1d163a Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 15 Jun 2019 11:14:29 +0200 Subject: Add stop attributes --- src/nanolight.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- src/nanolight.h | 3 +++ src/scanout.c | 12 +++++++++++- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/src/nanolight.c b/src/nanolight.c index df93495..246cce1 100644 --- a/src/nanolight.c +++ b/src/nanolight.c @@ -451,7 +451,11 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, struct nanoligh event->state & GDK_SHIFT_MASK); signed int nv = fix->attr_vals_start[n] + inc; cap_value(fix, n, &nv); - fix->attr_vals[n] = nv; + if ( !(fix->cls->attrs[n].props & ATTR_STOP) ) { + fix->attr_vals[n] = nv; + } else { + printf("Can't change step attr with mouse\n"); + } } } } @@ -461,6 +465,30 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, struct nanoligh } +static void change_stop_attr(struct nanolight *nl, signed int inc) +{ + int i; + for ( i=0; in_sel; i++ ) { + + struct fixture *fix = &nl->fixtures[nl->selection[i]]; + int n; + + if ( find_attribute(fix, nl->sel_attr, &n) ) { + if ( !(fix->cls->attrs[n].props & ATTR_STOP) ) { + printf("Can't change continuous attr with keys\n"); + continue; + } + if ( (fix->attr_vals[n] == 0) && (inc < 0) ) continue; + if ( (fix->attr_vals[n] == fix->cls->attrs[n].n_stops-1) && (inc > 0) ) { + continue; + } + fix->attr_vals[n] += inc; + } + + } + redraw(nl); +} + static void home_value(struct nanolight *nl) { int i; @@ -501,6 +529,14 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, struct nanoligh case GDK_KEY_Right : break; + case GDK_KEY_Up : + change_stop_attr(nl, +1); + break; + + case GDK_KEY_Down : + change_stop_attr(nl, -1); + break; + case GDK_KEY_Return : execute_command(nl); break; @@ -725,10 +761,13 @@ int main(int argc, char *argv[]) cls.attrs[6].addr_offset = 12; cls.attrs[6].home = 0; + int rgobo_stops[] = {0, 6, 10, 15, 19, 24, 28}; cls.attrs[7].cls = ATT_RGOBO; - cls.attrs[7].props = 0; + cls.attrs[7].props = ATTR_STOP; cls.attrs[7].addr_offset = 24; cls.attrs[7].home = 0; + cls.attrs[7].stops = rgobo_stops; + cls.attrs[7].home = 7; cls.attrs[8].cls = ATT_ZOOM; cls.attrs[8].props = ATTR_16BIT; @@ -740,15 +779,21 @@ int main(int argc, char *argv[]) cls.attrs[9].addr_offset = 34; cls.attrs[9].home = 0; + int gobo_stops[] = {0, 67, 73, 78, 84, 89, 95, 100, 106}; cls.attrs[10].cls = ATT_GOBO; - cls.attrs[10].props = 0; + cls.attrs[10].props = ATTR_STOP; cls.attrs[10].addr_offset = 22; cls.attrs[10].home = 0; + cls.attrs[10].stops = gobo_stops; + cls.attrs[10].n_stops = 9; + int prism_stops[] = {0, 50}; cls.attrs[11].cls = ATT_PRISM; - cls.attrs[11].props = 0; + cls.attrs[11].props = ATTR_STOP; cls.attrs[11].addr_offset = 27; cls.attrs[11].home = 0; + cls.attrs[11].stops = prism_stops; + cls.attrs[11].n_stops = 2; nl.fixture_width = 80.0; nl.fixtures = NULL; diff --git a/src/nanolight.h b/src/nanolight.h index 5947665..dfe7b6a 100644 --- a/src/nanolight.h +++ b/src/nanolight.h @@ -28,6 +28,7 @@ /* Attribute flags */ #define ATTR_NONE (0) #define ATTR_16BIT (1) +#define ATTR_STOP (2) enum attr_class { @@ -52,6 +53,8 @@ struct attribute int props; int addr_offset; int home; + int *stops; + int n_stops; }; diff --git a/src/scanout.c b/src/scanout.c index a12094f..53d78c9 100644 --- a/src/scanout.c +++ b/src/scanout.c @@ -23,6 +23,7 @@ #include #include +#include #include #include "nanolight.h" @@ -44,14 +45,23 @@ int scanout_all(struct nanolight *nl) int j; struct fixture *fix = &nl->fixtures[i]; for ( j=0; jcls->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 ) { + + if ( fix->cls->attrs[j].props & ATTR_STOP ) { + + int v = fix->attr_vals[j]; + assert(!(fix->cls->attrs[j].props & ATTR_16BIT)); + dmx[pos] = fix->cls->attrs[j].stops[v]; + + } 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 { -- cgit v1.2.3