/* * nanolight.c * * Copyright © 2019 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 . * */ #include #include #include #include #include #include #include #include #define _(x) gettext(x) #include "nanolight.h" #include "scanout.h" #include "display.h" static void show_help(const char *s) { printf(_("Syntax: %s [options]\n\n"), s); printf(_("Theatrical lighting control program.\n\n" " -h, --help Display this help message.\n")); } static struct fixture *create_fixture(struct nanolight *nl, struct fixture_class *cls, const char *label, int universe, int base_addr) { struct fixture *fix; int i; if ( nl->n_fixtures == nl->max_fixtures ) { struct fixture *fixtures_new; fixtures_new = realloc(nl->fixtures, (64+nl->max_fixtures)*sizeof(struct fixture)); if ( fixtures_new == NULL ) return NULL; nl->fixtures = fixtures_new; nl->max_fixtures += 64; } fix = &nl->fixtures[nl->n_fixtures++]; fix->label = strdup(label); fix->universe = universe; fix->base_addr = base_addr; fix->cls = cls; fix->attr_vals = calloc(cls->n_attrs, sizeof(int)); fix->attr_vals_start = calloc(cls->n_attrs, sizeof(int)); if ( (fix->attr_vals == NULL) || (fix->attr_vals_start == NULL) ) { nl->n_fixtures--; return NULL; } for ( i=0; in_attrs; i++ ) { fix->attr_vals[i] = cls->attrs[i].home; } return fix; } static gboolean scanout_cb(gpointer data) { scanout_all((struct nanolight *)data); return G_SOURCE_CONTINUE; } int main(int argc, char *argv[]) { struct nanolight nl; struct fixture_class cls; struct attribute attrs[128]; int c; gtk_init(&argc, &argv); const struct option longopts[] = { {"help", 0, NULL, 'h'}, {0, 0, NULL, 0} }; while ((c = getopt_long(argc, argv, "h", longopts, NULL)) != -1) { switch (c) { case 'h' : show_help(argv[0]); return 0; case 0 : break; default : return 1; } } #if !GLIB_CHECK_VERSION(2,36,0) g_type_init(); #endif bindtextdomain("nanolight", LOCALEDIR); textdomain("nanolight"); /* Set up data structures */ cls.name = "Dummy fixture"; cls.n_attrs = 12; cls.attrs = attrs; cls.attrs[0].cls = ATT_INTENSITY; cls.attrs[0].props = 0; cls.attrs[0].addr_offset = 49; cls.attrs[0].home = 0; cls.attrs[1].cls = ATT_PAN; cls.attrs[1].props = ATTR_16BIT; cls.attrs[1].addr_offset = 0; cls.attrs[1].home = 32768; cls.attrs[2].cls = ATT_TILT; cls.attrs[2].props = ATTR_16BIT; cls.attrs[2].addr_offset = 2; cls.attrs[2].home = 32768; cls.attrs[3].cls = ATT_STROBE; cls.attrs[3].props = 0; cls.attrs[3].addr_offset = 48; cls.attrs[3].home = 32; cls.attrs[4].cls = ATT_CYAN; cls.attrs[4].props = ATTR_16BIT; cls.attrs[4].addr_offset = 8; cls.attrs[4].home = 0; cls.attrs[5].cls = ATT_MAGENTA; cls.attrs[5].props = ATTR_16BIT; cls.attrs[5].addr_offset = 10; cls.attrs[5].home = 0; cls.attrs[6].cls = ATT_YELLOW; cls.attrs[6].props = ATTR_16BIT; cls.attrs[6].addr_offset = 12; cls.attrs[6].home = 0; int rgobo_stops[] = {0, 6, 10, 15, 19, 24, 28}; cls.attrs[7].cls = ATT_RGOBO; cls.attrs[7].props = ATTR_STOP; cls.attrs[7].addr_offset = 24; cls.attrs[7].home = 0; cls.attrs[7].stops = rgobo_stops; cls.attrs[7].n_stops = 7; cls.attrs[8].cls = ATT_ZOOM; cls.attrs[8].props = ATTR_16BIT; cls.attrs[8].addr_offset = 32; cls.attrs[8].home = 0; cls.attrs[9].cls = ATT_FOCUS; cls.attrs[9].props = ATTR_16BIT; cls.attrs[9].addr_offset = 34; cls.attrs[9].home = 0; int gobo_stops[] = {0, 67, 73, 78, 84, 89, 95, 100, 106}; cls.attrs[10].cls = ATT_GOBO; cls.attrs[10].props = ATTR_STOP; cls.attrs[10].addr_offset = 22; cls.attrs[10].home = 0; cls.attrs[10].stops = gobo_stops; cls.attrs[10].n_stops = 9; int prism_stops[] = {0, 50}; cls.attrs[11].cls = ATT_PRISM; cls.attrs[11].props = ATTR_STOP; cls.attrs[11].addr_offset = 27; cls.attrs[11].home = 0; cls.attrs[11].stops = prism_stops; cls.attrs[11].n_stops = 2; nl.fixture_width = 80.0; nl.fixtures = NULL; nl.n_fixtures = 0; nl.max_fixtures = 0; nl.cmdline[0] = '\0'; nl.cursor_idx = 0; nl.n_sel = 0; nl.sel_attr = ATT_INTENSITY; nl.dragging = 0; create_fixture(&nl, &cls, "mh1", 0, 1); create_fixture(&nl, &cls, "mh2", 0, 52); create_fixture(&nl, &cls, "mh3", 0, 103); create_fixture(&nl, &cls, "mh4", 0, 154); /* Set up output */ g_timeout_add(100, scanout_cb, &nl); create_main_window(&nl); gtk_main(); return 0; }