summaryrefslogtreecommitdiff
path: root/src/command.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-06-26 09:18:22 +0200
committerThomas White <taw@physics.org>2019-06-27 23:02:59 +0200
commite07e0540e7b599e09fa009a4e2c165b01a7a34e3 (patch)
treeb1d2f1e3d4ce812a4eac4493f051eae09c16a465 /src/command.c
parentc269b1fa9eaa247ef2b863367c249b996b4a01be (diff)
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.
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c44
1 files changed, 9 insertions, 35 deletions
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; i<nl->n_sel; i++ ) {
- int j;
struct fixture *fix = &nl->fixtures[nl->selection[i]];
- for ( j=0; j<fix->cls->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);
}
}