From 26058b69e8dfb2d2e64f91dce886f2f0d90b23b3 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 9 Jun 2019 23:02:46 +0200 Subject: Basic selection and level setting --- src/command.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'src/command.c') diff --git a/src/command.c b/src/command.c index c6b64e7..62c047b 100644 --- a/src/command.c +++ b/src/command.c @@ -205,16 +205,56 @@ 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) +{ + 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; + } + } + } +} + + int command_run(const char *cmd, struct nanolight *nl) { struct token tokens[1024]; - int n; + int i, n; n = find_tokens(cmd, tokens, nl); if ( n == 0 ) return 1; show_tokens(tokens, n, nl); + i = 0; + if ( tokens[i].type == TK_FIXTURE ) { + nl->n_sel = 0; + for ( i=0; iselection[nl->n_sel++] = tokens[i].fixture_index; + } else { + break; + } + } + } + + if ( tokens[i].type == TK_AT ) { + if ( tokens[i+1].type == TK_LEVEL ) { + set_level(nl, tokens[i+1].val, ATT_INTENSITY); + } + } + return 0; } -- cgit v1.2.3