From 6bc2911f1fa3a2be98512186538bdaa8ba5b6850 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 30 Jun 2019 17:57:52 +0200 Subject: Gobo selection and rotation --- src/display.c | 7 ++- src/nanolight.c | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- src/nanolight.h | 13 +++++- src/scanout.c | 59 ++++++++++++++++++++++++ 4 files changed, 209 insertions(+), 11 deletions(-) diff --git a/src/display.c b/src/display.c index 742863f..4e80908 100644 --- a/src/display.c +++ b/src/display.c @@ -402,21 +402,24 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, struct nanoligh { gboolean r; int claim = 1; + int fine = event->state & GDK_SHIFT_MASK; switch ( event->keyval ) { case GDK_KEY_Left : + attr_movex(nl, -1, fine); break; case GDK_KEY_Right : + attr_movex(nl, +1, fine); break; case GDK_KEY_Up : - //change_stop_attr(nl, +1); + attr_movey(nl, +1, fine); break; case GDK_KEY_Down : - //change_stop_attr(nl, -1); + attr_movey(nl, -1, fine); break; case GDK_KEY_Return : diff --git a/src/nanolight.c b/src/nanolight.c index 7767e94..16e3ac3 100644 --- a/src/nanolight.c +++ b/src/nanolight.c @@ -73,11 +73,11 @@ static struct fixture *create_fixture(struct nanolight *nl, struct fixture_class fix->pan = 0.0; fix->tilt = 0.0; fix->gobo = 0; - fix->gobo_rotation = 0.5; + fix->gobo_rotate = 0.0; fix->gobo_spin = 0.0; fix->prism = 0; - fix->prism_rotation = 0.5; - fix->prism_spin = 0.5; + fix->prism_rotate = 0.0; + fix->prism_spin = 0.0; fix->focus = 0.5; fix->zoom = 0.5; fix->frost = 0.0; @@ -93,6 +93,99 @@ static gboolean scanout_cb(gpointer data) } +static void cap_value(float *val, float min, float max) +{ + if ( *val > max ) *val = max; + if ( *val < min ) *val = min; +} + + +void attr_movex(struct nanolight *nl, signed int d, int fine) +{ + int i; + float chg = fine ? d/60000.0 : d/10.0; + if ( nl->sel_attr != PANTILT ) return; + for ( i=0; in_sel; i++ ) { + struct fixture *fix = &nl->fixtures[nl->selection[i]]; + if ( !(fix->cls->attributes & PANTILT) ) continue; + fix->pan += chg; + cap_value(&fix->pan, -1.0, 1.0); + } +} + + +void attr_movey(struct nanolight *nl, signed int d, int fine) +{ + int i; + float chg = fine ? d/60000.0 : d/10.0; + for ( i=0; in_sel; i++ ) { + struct fixture *fix = &nl->fixtures[nl->selection[i]]; + + switch ( nl->sel_attr ) { + + case PANTILT : + fix->tilt += chg; + cap_value(&fix->tilt, -1.0, 1.0); + break; + + case FOCUS : + fix->focus += chg; + cap_value(&fix->focus, 0.0, 1.0); + break; + + case ZOOM : + fix->zoom += chg; + cap_value(&fix->zoom, 0.0, 1.0); + break; + + case FROST : + fix->frost += chg; + cap_value(&fix->frost, 0.0, 1.0); + break; + + case IRIS : + fix->iris += chg; + cap_value(&fix->iris, 0.0, 1.0); + break; + + case GOBO : + if ( (fix->gobo == 0) && (d<0) ) continue; + if ( (fix->gobo == fix->cls->n_gobos-1) && (d>0) ) continue; + fix->gobo += d; + break; + + case GOBO_ROTATE : + fix->gobo_rotate += chg; + cap_value(&fix->gobo_rotate, -1.0, 1.0); + break; + + case GOBO_SPIN : + fix->gobo_spin += chg; + cap_value(&fix->gobo_spin, -1.0, 1.0); + break; + + case PRISM : + if ( (fix->prism == 0) && (d<0) ) continue; + if ( (fix->prism == fix->cls->n_prisms-1) && (d>0) ) continue; + fix->prism += d; + break; + + case PRISM_ROTATE : + fix->prism_rotate += chg; + cap_value(&fix->prism_rotate, -1.0, 1.0); + break; + + case PRISM_SPIN : + fix->prism_spin += chg; + cap_value(&fix->prism_spin, -1.0, 1.0); + break; + + } + + } +} + + int main(int argc, char *argv[]) { struct nanolight nl; @@ -134,9 +227,9 @@ int main(int argc, char *argv[]) cls.name = "Robe Robin DL7S Profile Mode 1"; cls.properties = COL_CMY; cls.attributes = INTENSITY | COLOUR | PANTILT | FOCUS | ZOOM - | FROST | IRIS; + | FROST | IRIS | GOBO | PRISM; cls.attributes16 = INTENSITY | COLOUR | PANTILT | FOCUS | ZOOM - | FROST | IRIS; + | IRIS; cls.intensity_offset = 49; cls.pan_offset = 0; @@ -148,6 +241,10 @@ int main(int argc, char *argv[]) cls.zoom_offset = 32; cls.frost_offset = 29; /* FIXME 0..179 only */ cls.iris_offset = 30; /* FIXME: 0..179 only, but also fine @ offset 32 */ + cls.gobo_rotate_offset = 25; + cls.gobo_spin_offset = 25; + cls.prism_rotate_offset = 0; + cls.prism_spin_offset = 28; int magic_chans[] = {48}; int magic_vals[] = {32}; @@ -163,6 +260,12 @@ int main(int argc, char *argv[]) 19, 0, 24, 0, 28, 0, + 33, 0, + 38, 0, + 42, 0, + 47, 0, + 52, 0, + 57, 0, 0, 67, 0, 73, 0, 78, @@ -171,17 +274,41 @@ int main(int argc, char *argv[]) 0, 95, 0, 100, 0, 106 }; - cls.n_gobos = 15; + int gobo_flags[] = { 0, + GOBO_ROTATE, + GOBO_ROTATE, + GOBO_ROTATE, + GOBO_ROTATE, + GOBO_ROTATE, + GOBO_ROTATE, + GOBO_SPIN, + GOBO_SPIN, + GOBO_SPIN, + GOBO_SPIN, + GOBO_SPIN, + GOBO_SPIN, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 }; + cls.n_gobos = 21; cls.n_gobo_chans = 2; cls.gobo_chans = gobo_chans; cls.gobo_vals = gobo_vals; + cls.gobo_flags = gobo_flags; int prism_chans[] = {27}; int prism_vals[] = {0, 50}; - cls.n_prisms = 15; + int prism_flags [] = {0, PRISM_SPIN}; + cls.n_prisms = 2; cls.n_prism_chans = 1; cls.prism_chans = prism_chans; cls.prism_vals = prism_vals; + cls.prism_flags = prism_flags; nl.fixture_width = 80.0; nl.fixtures = NULL; diff --git a/src/nanolight.h b/src/nanolight.h index 85f1d3a..648e291 100644 --- a/src/nanolight.h +++ b/src/nanolight.h @@ -79,11 +79,17 @@ struct fixture_class int n_gobo_chans; int *gobo_chans; int *gobo_vals; + int *gobo_flags; + int gobo_rotate_offset; + int gobo_spin_offset; int n_prisms; int n_prism_chans; int *prism_chans; int *prism_vals; + int *prism_flags; + int prism_rotate_offset; + int prism_spin_offset; }; @@ -104,10 +110,10 @@ struct fixture float pan; /* -1 (fully stage left) to +1 (fully stage right) */ float tilt; /* -1 (fully downstage) to +1 (fully upstage) */ int gobo; /* Gobo number: 0 to cls->n_gobos-1 inclusive */ - float gobo_rotation; /* -1 (fully anticlockwise) to +1 (fully clockwise) */ + float gobo_rotate; /* -1 (fully anticlockwise) to +1 (fully clockwise) */ float gobo_spin; /* -1 (fastest anticlockwise) to +1 (fastest clockwise) */ int prism; /* Exactly like gobo */ - float prism_rotation; /* Exactly like gobo_rotation */ + float prism_rotate; /* Exactly like gobo_rotate */ float prism_spin; /* Exactly like gobo_spin */ float focus; /* 0 (nearest) to 1 (farthest) */ float zoom; /* 0 (narrowest) to 1 (widest) */ @@ -148,5 +154,8 @@ struct nanolight double y_orig; }; +extern void attr_movex(struct nanolight *nl, signed int d, int fine); +extern void attr_movey(struct nanolight *nl, signed int d, int fine); + #endif /* NANOLIGHT_H */ diff --git a/src/scanout.c b/src/scanout.c index f0e6de3..1b0229c 100644 --- a/src/scanout.c +++ b/src/scanout.c @@ -43,6 +43,58 @@ static void set_val(int *dmx, int base_addr, int attr_offset, float value, int s } +static void set_prism(int *dmx, struct fixture *fix, int prism) +{ + int i; + + if ( prism > fix->cls->n_prisms ) return; + + for ( i=0; icls->n_prism_chans; i++ ) { + int idx = fix->cls->n_prism_chans * prism + i; + int chan = fix->cls->prism_chans[i]; + dmx[fix->base_addr+chan-1] = fix->cls->prism_vals[idx] & 0xff; + } + + if ( fix->cls->prism_flags[prism] & PRISM_ROTATE ) { + float rotate_val; + rotate_val = (fix->prism_rotate + 1.0)/2.0; + set_val(dmx, fix->base_addr, fix->cls->prism_rotate_offset, rotate_val, 0); + } + + if ( fix->cls->prism_flags[prism] & PRISM_SPIN ) { + float rotate_val; + rotate_val = (fix->prism_spin + 1.0)/2.0; + set_val(dmx, fix->base_addr, fix->cls->prism_spin_offset, rotate_val, 0); + } +} + + +static void set_gobo(int *dmx, struct fixture *fix, int gobo) +{ + int i; + + if ( gobo > fix->cls->n_gobos ) return; + + for ( i=0; icls->n_gobo_chans; i++ ) { + int idx = fix->cls->n_gobo_chans * gobo + i; + int chan = fix->cls->gobo_chans[i]; + dmx[fix->base_addr+chan-1] = fix->cls->gobo_vals[idx] & 0xff; + } + + if ( fix->cls->gobo_flags[gobo] & GOBO_ROTATE ) { + float rotate_val; + rotate_val = (fix->gobo_rotate + 1.0)/2.0; + set_val(dmx, fix->base_addr, fix->cls->gobo_rotate_offset, rotate_val, 0); + } + + if ( fix->cls->gobo_flags[gobo] & GOBO_SPIN ) { + float rotate_val; + rotate_val = (fix->gobo_spin + 1.0)/2.0; + set_val(dmx, fix->base_addr, fix->cls->gobo_spin_offset, rotate_val, 0); + } +} + + int scanout_all(struct nanolight *nl) { SoupSession *sess; @@ -125,6 +177,13 @@ int scanout_all(struct nanolight *nl) cls->attributes16 & IRIS); } + if ( cls->attributes & GOBO ) { + set_gobo(dmx, fix, fix->gobo); + } + + if ( cls->attributes & PRISM ) { + set_prism(dmx, fix, fix->prism); + } } -- cgit v1.2.3