Skip to content

Commit c6699ae

Browse files
committed
Introduce data structures for channel remapping
1 parent feff240 commit c6699ae

File tree

6 files changed

+39
-14
lines changed

6 files changed

+39
-14
lines changed

TODO

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ Fix pixmap clearing when moving from big to small gobo
66
Mask-repeat for prism?
77
Manpage
88
Fail from config / sanity check config!
9+
10+
Aggregate data events for vsync
11+
Preprocess DMX data with fix/min/max/inverted

artnet.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ int artnet_output_handler(CONFIG* config, ArtNetPacket* packet) {
184184
return -1;
185185
}
186186

187-
memcpy(config->dmx_channels, dmx_packet->data + config->dmx_address - 1, DMX_CHANNELS);
188-
print_dmx_output(config->dmx_channels, DMX_CHANNELS);
187+
memcpy(config->dmx_data, dmx_packet->data + config->dmx_address - 1, DMX_CHANNELS);
188+
print_dmx_output(config->dmx_data, DMX_CHANNELS);
189189

190190
return 0;
191191
}

coreloop.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ int xlaser(XRESOURCES* xres, CONFIG* config){
7373
}
7474
}
7575

76-
if(exposed || config->dmx_channels[SHUTTER] != 0){
76+
if(exposed || config->dmx_data[SHUTTER] != 0){
7777
fprintf(stderr, "Window exposed, drawing\n");
7878
//FIXME this might loop
79-
if(xlaser_render(xres, config->dmx_channels) < 0){
79+
if(xlaser_render(xres, config->dmx_data) < 0){
8080
fprintf(stderr, "Render procedure failed\n");
8181
}
8282
//set the last render timer
@@ -96,8 +96,8 @@ int xlaser(XRESOURCES* xres, CONFIG* config){
9696
FD_ZERO(&readfds);
9797
maxfd = -1;
9898
//when using the shutter feature, cycle faster
99-
tv.tv_sec = (config->dmx_channels[SHUTTER] == 0) ? 1:0;
100-
tv.tv_usec = (config->dmx_channels[SHUTTER] == 0) ? 0:1000;
99+
tv.tv_sec = (config->dmx_data[SHUTTER] == 0) ? 1:0;
100+
tv.tv_usec = (config->dmx_data[SHUTTER] == 0) ? 0:1000;
101101

102102
for(i = 0; i < xres->xfds.size; i++){
103103
FD_SET(xres->xfds.fds[i], &readfds);

sample.conf

+7
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ address = 1
1515
[artnet]
1616
net = 0
1717
subuni = 0
18+
19+
[remap]
20+
pan = fixed 128
21+
panfine = fixed 0
22+
tilt = fixed 128
23+
tiltfine = fixed 0
24+
dimmer = 0

xlaser.c

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ int getHelp() {
1414
}
1515

1616
int main(int argc, char** argv){
17+
unsigned u;
1718
CONFIG config = {
1819
.dmx_address = 0,
1920
.windowed = false,
@@ -25,6 +26,13 @@ int main(int argc, char** argv){
2526
XRESOURCES xres = {};
2627
printf("%s starting up\n", XLASER_VERSION);
2728

29+
//initialize channel mapping configuration
30+
for(u = 0; u < DMX_CHANNELS; u++){
31+
config.dmx_config[u].source = u;
32+
config.dmx_config[u].min = 0;
33+
config.dmx_config[u].max = 255;
34+
}
35+
2836
char* invalid_arguments[argc];
2937
int invalid_arguments_len = parse_args(&config, argc, argv, invalid_arguments);
3038

xlaser.h

+15-8
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@
1010

1111
#define XLASER_VERSION "XLaser v1.1"
1212
#define SHORTNAME "XLaser"
13+
#define DMX_CHANNELS 16
1314

1415
#include <X11/Xlib.h>
1516
#include <X11/Xatom.h>
1617
#include <X11/Xutil.h>
1718

18-
#ifndef OPENGL
19+
#ifdef OPENGL
20+
#include <GL/glew.h>
21+
#include <GL/gl.h>
22+
#include <GL/glx.h>
23+
#else
1924
#include <X11/extensions/Xdbe.h>
2025
#include <X11/extensions/Xrender.h>
2126
#define BLUR_KERNEL_DIM 3
2227
#define BLUR_SIGMA 20.0
2328
#define BLUR_CONSTANT 4
24-
#else
25-
#include <GL/glew.h>
26-
#include <GL/gl.h>
27-
#include <GL/glx.h>
2829
#endif
2930

3031
#include "xfds.h"
3132

3233
volatile sig_atomic_t abort_signaled = 0;
3334

34-
3535
typedef struct /*_GOBO*/ {
3636
int width;
3737
int height;
@@ -84,10 +84,17 @@ typedef struct /*_XDATA*/ {
8484
#endif
8585
} XRESOURCES;
8686

87-
#define DMX_CHANNELS 16
87+
typedef struct /*_CHANNEL_CFG*/ {
88+
bool fixed;
89+
uint16_t source;
90+
uint8_t min;
91+
uint8_t max;
92+
} CHANNEL_CONFIG;
93+
8894
typedef struct /*XLASER_CFG*/ {
8995
uint16_t dmx_address;
90-
uint8_t dmx_channels[DMX_CHANNELS];
96+
uint8_t dmx_data[DMX_CHANNELS];
97+
CHANNEL_CONFIG dmx_config[DMX_CHANNELS];
9198
uint8_t art_net;
9299
uint8_t art_subUni;
93100
uint8_t art_universe;

0 commit comments

Comments
 (0)