From e07e0540e7b599e09fa009a4e2c165b01a7a34e3 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 26 Jun 2019 09:18:22 +0200 Subject: 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. --- src/command.c | 44 +++++++++----------------------------------- 1 file changed, 9 insertions(+), 35 deletions(-) (limited to 'src/command.c') diff --git a/src/command.c b/src/command.c index 53d9d9c..e60a75a 100644 --- a/src/command.c +++ b/src/command.c @@ -45,7 +45,7 @@ struct token { enum token_type type; int fixture_index; - enum attr_class attribute; + int attribute; int val; }; @@ -54,17 +54,13 @@ struct token const char *attr_class_names[] = { "int", - "pan", - "tilt" }; -enum attr_class attr_classes[] = { - ATT_INTENSITY, - ATT_PAN, - ATT_TILT +int attr_classes[] = { + INTENSITY, }; -int n_attr_classes = 3; +int n_attr_classes = 1; /* (end of attribute tables) */ @@ -156,21 +152,10 @@ static int find_tokens(const char *cmd, struct token *tokens, struct nanolight * } -static const char *str_attr(enum attr_class att) +static const char *str_attr(int att) { switch ( att ) { - case ATT_INTENSITY : return "intensity"; - case ATT_PAN : return "pan"; - case ATT_TILT : return "tilt"; - case ATT_STROBE : return "strobe"; - case ATT_CYAN : return "cyan"; - case ATT_MAGENTA : return "magenta"; - case ATT_YELLOW : return "yellow"; - case ATT_RGOBO : return "rgobo"; - case ATT_GOBO : return "gobo"; - case ATT_PRISM : return "prism"; - case ATT_FOCUS : return "focus"; - case ATT_ZOOM : return "zoom"; + case INTENSITY : return "intensity"; } return "???"; } @@ -214,24 +199,13 @@ static void show_tokens(struct token *tokens, int n, struct nanolight *nl) } -static void set_level(struct nanolight *nl, int val, enum attr_class cls) +static void set_level(struct nanolight *nl, int val) { int i; - if ( cls == ATT_INTENSITY ) { - val *= 255; - val /= 100; - } - for ( i=0; in_sel; i++ ) { - int j; struct fixture *fix = &nl->fixtures[nl->selection[i]]; - for ( j=0; jcls->n_attrs; j++ ) { - if ( fix->cls->attrs[j].cls == cls ) { - fix->attr_vals[j] = val; - break; - } - } + fix->intensity = (float)val/100.0; } } @@ -260,7 +234,7 @@ int command_run(const char *cmd, struct nanolight *nl) if ( tokens[i].type == TK_AT ) { if ( tokens[i+1].type == TK_LEVEL ) { - set_level(nl, tokens[i+1].val, ATT_INTENSITY); + set_level(nl, tokens[i+1].val); } } -- cgit v1.2.3