From deb42462483b16799b40d8a49ad2d8327e1a0e28 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 23 Feb 2020 15:09:11 +0100 Subject: Put fixture library into headers and static structures --- fixtures/fixture_library.h | 26 +++++++++ fixtures/generic/dimmer.h | 48 +++++++++++++++ fixtures/robe/dl7s.h | 112 +++++++++++++++++++++++++++++++++++ meson.build | 2 + src/init.scm | 2 +- src/scheme.c | 143 +++------------------------------------------ 6 files changed, 198 insertions(+), 135 deletions(-) create mode 100644 fixtures/fixture_library.h create mode 100644 fixtures/generic/dimmer.h create mode 100644 fixtures/robe/dl7s.h diff --git a/fixtures/fixture_library.h b/fixtures/fixture_library.h new file mode 100644 index 0000000..404f7d2 --- /dev/null +++ b/fixtures/fixture_library.h @@ -0,0 +1,26 @@ +/* + * fixture_library.h + * + * Copyright © 2020 Thomas White + * + * This file is part of NanoLight. + * + * NanoLight is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/* FIXME: Scheme-ify the whole idea of fixture classes */ + +#include "generic/dimmer.h" +#include "robe/dl7s.h" diff --git a/fixtures/generic/dimmer.h b/fixtures/generic/dimmer.h new file mode 100644 index 0000000..a08d293 --- /dev/null +++ b/fixtures/generic/dimmer.h @@ -0,0 +1,48 @@ +/* + * dimmer.h + * + * Copyright © 2019-2020 Thomas White + * + * This file is part of NanoLight. + * + * NanoLight is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +struct fixture_class generic_dimmer_class = { + + .name = "Generic dimmer", + + .properties = 0, + .attributes = INTENSITY, + .attributes16 = 0, + + .intensity_offset = 0, + + .n_magic = 0, + .magic_chans = NULL, + .magic_vals = NULL, + + .n_gobos = 0, + .n_gobo_chans = 0, + .gobo_chans = NULL, + .gobo_vals = NULL, + .gobo_flags = NULL, + + .n_prisms = 0, + .n_prism_chans = 0, + .prism_chans = NULL, + .prism_vals = NULL, + .prism_flags = NULL, +}; diff --git a/fixtures/robe/dl7s.h b/fixtures/robe/dl7s.h new file mode 100644 index 0000000..e826d04 --- /dev/null +++ b/fixtures/robe/dl7s.h @@ -0,0 +1,112 @@ +/* + * robe_dl7s.h + * + * Copyright © 2019-2020 Thomas White + * + * This file is part of NanoLight. + * + * NanoLight is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +static int dl7s_magic_chans[] = {48}; +static int dl7s_magic_vals[] = {32}; +static int dl7s_gobo_chans[] = {24, 22}; +static int dl7s_gobo_vals[] = { 0, 0, + 6, 0, + 10, 0, + 15, 0, + 19, 0, + 24, 0, + 28, 0, + 33, 0, + 38, 0, + 42, 0, + 47, 0, + 52, 0, + 57, 0, + 0, 67, + 0, 73, + 0, 78, + 0, 84, + 0, 89, + 0, 95, + 0, 100, + 0, 106 }; +static int dl7s_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 }; +static int dl7s_prism_chans[] = {27}; +static int dl7s_prism_vals[] = {0, 50}; +static int dl7s_prism_flags [] = {0, PRISM_SPIN}; + +struct fixture_class dl7s_class = { + + .name = "Robe Robin DL7S Profile Mode 1", + + .properties = COL_CMY, + .attributes = INTENSITY | COLOUR | PANTILT | FOCUS | ZOOM + | FROST | IRIS | GOBO | PRISM, + .attributes16 = INTENSITY | COLOUR | PANTILT | FOCUS | ZOOM + | IRIS, + + .intensity_offset = 49, + .pan_offset = 0, + .tilt_offset = 2, + .cyan_offset = 8, + .magenta_offset = 10, + .yellow_offset = 12, + .focus_offset = 34, + .zoom_offset = 32, + .frost_offset = 29, /* FIXME 0..179 only */ + .iris_offset = 30, /* FIXME: 0..179 only, but also fine @ offset 32 */ + .gobo_rotate_offset = 25, + .gobo_spin_offset = 25, + .prism_rotate_offset = 0, + .prism_spin_offset = 28, + + .n_magic = 1, + .magic_chans = dl7s_magic_chans, + .magic_vals = dl7s_magic_vals, + + .n_gobos = 21, + .n_gobo_chans = 2, + .gobo_chans = dl7s_gobo_chans, + .gobo_vals = dl7s_gobo_vals, + .gobo_flags = dl7s_gobo_flags, + + .n_prisms = 2, + .n_prism_chans = 1, + .prism_chans = dl7s_prism_chans, + .prism_vals = dl7s_prism_vals, + .prism_flags = dl7s_prism_flags, +}; diff --git a/meson.build b/meson.build index 802b7e2..0862bcd 100644 --- a/meson.build +++ b/meson.build @@ -28,6 +28,7 @@ gresources = gnome.compile_resources('nanolight-resources', source_dir: 'data', c_name: 'nanolight') +fixture_inc = include_directories('fixtures') # Main program executable('nanolight', ['src/nanolight.c', @@ -39,5 +40,6 @@ executable('nanolight', 'src/scheme.c', ], gresources, + include_directories: fixture_inc, dependencies : [gtk_dep, mdep, soup_dep, guile_dep, thread_dep], install : true) diff --git a/src/init.scm b/src/init.scm index 58d6bd6..e2be7a2 100644 --- a/src/init.scm +++ b/src/init.scm @@ -34,4 +34,4 @@ (patch-many (find-fixture-class fixture-class-library "Generic dimmer") 'dim 48 0 1) -;(patch-many (find-fixture-class fixture-class-library "Robe Robin DL7S Profile Mode 1") 'mh 4 0 51) +(patch-many (find-fixture-class fixture-class-library "Robe Robin DL7S Profile Mode 1") 'mh 4 0 51) diff --git a/src/scheme.c b/src/scheme.c index e13d7d3..ad7ee6a 100644 --- a/src/scheme.c +++ b/src/scheme.c @@ -24,6 +24,7 @@ #include #include "lightctx.h" +#include "fixture_library.h" static SCM fixture_type; @@ -63,127 +64,6 @@ static SCM fixture_class_name(SCM fixture_class_scm) } -static struct fixture_class *make_generic_dimmer() -{ - struct fixture_class *cls; - - cls = malloc(sizeof(struct fixture_class)); - if ( cls == NULL ) return NULL; - - /* Set up data structures */ - cls->name = "Generic dimmer"; - cls->properties = 0; - cls->attributes = INTENSITY; - cls->attributes16 = 0; - cls->intensity_offset = 0; - cls->n_magic = 0; - cls->n_gobos = 0; - cls->n_gobo_chans = 0; - cls->n_prisms = 0; - cls->n_prism_chans = 0; - - return cls; -} - - -static struct fixture_class *make_dl7s() -{ - struct fixture_class *cls; - - cls = malloc(sizeof(struct fixture_class)); - if ( cls == NULL ) return NULL; - - /* Set up data structures */ - cls->name = "Robe Robin DL7S Profile Mode 1"; - cls->properties = COL_CMY; - cls->attributes = INTENSITY | COLOUR | PANTILT | FOCUS | ZOOM - | FROST | IRIS | GOBO | PRISM; - cls->attributes16 = INTENSITY | COLOUR | PANTILT | FOCUS | ZOOM - | IRIS; - - cls->intensity_offset = 49; - cls->pan_offset = 0; - cls->tilt_offset = 2; - cls->cyan_offset = 8; - cls->magenta_offset = 10; - cls->yellow_offset = 12; - cls->focus_offset = 34; - 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}; - cls->magic_chans = magic_chans; - cls->magic_vals = magic_vals; - cls->n_magic = 1; - - int gobo_chans[] = {24, 22}; - int gobo_vals[] = { 0, 0, - 6, 0, - 10, 0, - 15, 0, - 19, 0, - 24, 0, - 28, 0, - 33, 0, - 38, 0, - 42, 0, - 47, 0, - 52, 0, - 57, 0, - 0, 67, - 0, 73, - 0, 78, - 0, 84, - 0, 89, - 0, 95, - 0, 100, - 0, 106 }; - 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}; - 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; - - return cls; -} - - static SCM patch_fixture(SCM fixture_name_scm, SCM fixture_class_scm, SCM universe_scm, SCM addr_scm) { @@ -228,8 +108,8 @@ static void finalize_fixture_class(SCM fixture) void *register_scheme_funcs(void *data) { SCM name, slots; + SCM obj; SCM fixture_class_list; - struct fixture_class *cls; nl = data; @@ -245,18 +125,13 @@ void *register_scheme_funcs(void *data) /* Expose the list of fixture classes */ fixture_class_list = SCM_EOL; - cls = make_dl7s(); - if ( cls != NULL ) { - SCM obj = scm_make_foreign_object_1(fixture_class_type, cls); - SCM obj_list = scm_list_1(obj); - fixture_class_list = scm_append(scm_list_2(fixture_class_list, obj_list)); - } - cls = make_generic_dimmer(); - if ( cls != NULL ) { - SCM obj = scm_make_foreign_object_1(fixture_class_type, cls); - SCM obj_list = scm_list_1(obj); - fixture_class_list = scm_append(scm_list_2(fixture_class_list, obj_list)); - } + + obj = scm_make_foreign_object_1(fixture_class_type, &dl7s_class); + fixture_class_list = scm_append(scm_list_2(fixture_class_list, scm_list_1(obj))); + + obj = scm_make_foreign_object_1(fixture_class_type, &generic_dimmer_class); + fixture_class_list = scm_append(scm_list_2(fixture_class_list, scm_list_1(obj))); + scm_define(scm_from_utf8_symbol("fixture-class-library"), fixture_class_list); /* Expose the list of fixtures (starts empty) */ -- cgit v1.2.3