/* * test_changing_digismoke_map: test, if the map in digismoke can be * changed * If compiled with -Drestore the original map is restored. * If compiled with -Dcostom a new map is installed. It consists only of two * phases: <50% off, >=50% on. * This code was written to demonstrate how to change the map. It depends on * one a DMX512 Interface like USB2DMX-primo, LPR2DMX2 or LPR2DMX. * * Be sure to switch to address 555 befor expecting results. */ #include #include #include #include #include #include #define DEVICE "/dev/usb/usblp0" /* which device? for LPR2DMX or LPR2DMX2 use /dev/lp? where '?' is the number of the parallel port the device is connected to */ void main() { int f = open(DEVICE, O_WRONLY); /* open device to write to */ int i; unsigned char buf[2+1+64+4]; if (f == -1) { fprintf(stderr, "Error: can't open device\n"); exit(0); } buf[0] = (sizeof(buf)-4) >>8; /* prepare writting to USB2DMX-primo or */ buf[1] = (sizeof(buf)-4) & 0xff; /* LPR2DMX, LPR2DMX2 */ #ifdef restore buf[2] = 80; /* start-code to restore */ buf[3+0] = 0x55; /* spezial bytes to start the writting */ buf[3+1] = 0xaa; buf[3+2] = 0x55; buf[3+3] = 0xaa; #endif #ifdef costom buf[2] = 90; /* start-code to costomize the map */ for(i=0; i<64; ++i) /* create new map */ buf[i+3]=(i/32)*0xff; buf[3+64+0] = 0x55; /* spezial bytes to start the writting */ buf[3+64+1] = 0xaa; buf[3+64+2] = 0x55; buf[3+64+3] = 0xaa; #endif while(1) /* write the buffer continuosly */ write(f, buf, sizeof(buf)); }