EasyLaseDriver: easylase.2.h
| File easylase.2.h, 10.0 kB (added by cweider2, 2 years ago) |
|---|
| Line | |
|---|---|
| 1 | /* Library Interface for EasyLase USB |
| 2 | * (C) 2005,2006 Mueller Elektronik |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | */ |
| 6 | |
| 7 | /** -- Introduction -- |
| 8 | * Only 2 functions have to be called and affect all connected devices. These are: |
| 9 | * EasyLaseGetCardNum |
| 10 | * Must be called befor using any other function. Can also be called to |
| 11 | * try to reopen the connection when an error occurred. |
| 12 | * and EasyLaseClose |
| 13 | * Closes all devices. Should be called at the end of the application |
| 14 | * program. |
| 15 | * All other functions are optional and can be used independently from each |
| 16 | * other by the application. |
| 17 | * |
| 18 | * -- Lasershow output -- |
| 19 | * EasyLase outputs the data frame based. This means, always a complete show frame |
| 20 | * will be transmitted via USB. When the frame is received by the device, |
| 21 | * EasyLase will display it. A frame will always be displayed completely without |
| 22 | * any interruptions. A running frame will not be interrupted by a new incoming frame. |
| 23 | * The system is double buffered. A new frame can be received via USB, while another |
| 24 | * frame is being output to the D/A-converters. |
| 25 | * Important: |
| 26 | * Frames need time to be output. The time is the result of number of points |
| 27 | * multiplicated with the output time for each point (points per second). |
| 28 | * Example: |
| 29 | * At an output speed of 10000 pps and 1000 points, the frame needs 1000 / 10000 = 0.1 |
| 30 | * seconds or 100 milliseconds for display. |
| 31 | * When more frames are transmitted via USB as can be displayed in the same time, |
| 32 | * they will be discarded. This costs transmission bandwith and can lower the |
| 33 | * communication speed. To avoid such data jam, a handshake can be implemented. |
| 34 | * Using the function EasyLaseGetStatus, the application can check if the device is |
| 35 | * ready to receive a new frame. This handshake should be used, but doesn't have to |
| 36 | * be used. The application can send frames using EasyLaseWriteFrame every time, |
| 37 | * without checking the status. |
| 38 | * Frames will be repeated when no new frame is available. To avoid repetition, |
| 39 | * use the EasyLaseWriteFrameNR function. Whenever a new frame is ready for |
| 40 | * display, it will be output next. |
| 41 | * To stop output the Function EasyLaseStop is implemented. |
| 42 | */ |
| 43 | |
| 44 | /** Data Format Frame |
| 45 | * A laser frame for output is an array of the following 8 byte structure: |
| 46 | */ |
| 47 | typedef struct { |
| 48 | unsigned short x; // 2 Bytes Value 0 - 4095 X-Coordinate |
| 49 | unsigned short y; // 2 Bytes Value 0 - 4095 Y-coordinate |
| 50 | unsigned char r; // 1 Byte Value 0 - 255 Red |
| 51 | unsigned char g; // 1 Byte Value 0 - 255 Green |
| 52 | unsigned char b; // 1 Byte Value 0 - 255 Blue |
| 53 | unsigned char i; // 1 Byte Value 0 - 255 Intensity |
| 54 | } __attribute__((packed)) *EasyLasePoint; |
| 55 | |
| 56 | /** Data Format DMX |
| 57 | * There are 2 basic functions available for reading or writing DMX-data. |
| 58 | * All 512 channels can be accessed or only a selected number of channels. |
| 59 | * The functions for accessing a limited number of channels are newly |
| 60 | * implemented. The 2 other functions for accessing all 512 channels will |
| 61 | * be available for compatibility. For lowering the data traffic, it is |
| 62 | * recommended to use as few channels as possible. For both functions, |
| 63 | * data will be accessed via a data array, where the lowest address |
| 64 | * represents the lowest DMX-channel. |
| 65 | * EasyLase USB generally reads all DMX-channels available on the DMX-line. |
| 66 | * The application must decide what channels have to be transferred via USB. |
| 67 | * For DMX-out, EasyLase USB outputs all channels beginning from channel 0 |
| 68 | * up to the highest channel written via USB. When the highest channel used |
| 69 | * is significantly lower than 512, the repetition rate of the generated |
| 70 | * DMX-signal can be increased, giving a higher refresh rate for DMX-devices. |
| 71 | */ |
| 72 | |
| 73 | /** Data Format TTL |
| 74 | * TTL-values are for output only. 16 Bits can be transferred via USB, |
| 75 | * but EasyLase will support the lower 8 bits only. |
| 76 | */ |
| 77 | |
| 78 | /** Functions |
| 79 | * Important: All functions, except EasyLaseGetCardNum and EasyLaseClose |
| 80 | * refer to a selected device, which is addressed by the card number. |
| 81 | * While the number of all cards can be 0 (no card) to 16, the selection |
| 82 | * is 0 (first card) to 15. So when using 1 card, the number of cards is |
| 83 | * 1, but the cardNumber is 0. |
| 84 | */ |
| 85 | |
| 86 | |
| 87 | int easyLaseGetCardNum(); |
| 88 | /** int easyLaseGetCardNum(); //must be used before all other functions |
| 89 | * Will return the number of connected cards and opens the devices. |
| 90 | * Return value: 0 = no cards, 1-20 number of cards connected. |
| 91 | */ |
| 92 | |
| 93 | |
| 94 | #define EASYLASE_MIN_SPEED 500 |
| 95 | #define EASYLASE_MAX_SPEED 65000 |
| 96 | #define EASYLASE_SPEED_STEP 500 |
| 97 | |
| 98 | int easyLaseWriteFrame(int cardNumber, unsigned char *dataBuffer, unsigned int dataCounter, unsigned int speed); |
| 99 | /** int easyLaseWriteFrame(int cardNumber, unsigned char *dataBuffer, unsigned int dataCounter, unsigned int speed); |
| 100 | * Send a frame from dataBuffer to card number cardNumber. Maxmimum framesize |
| 101 | * is 16.000 points or 128 Kbytes. |
| 102 | * cardNumber: selected device, 0 .. number of cards - 1 |
| 103 | * dataBuffer: pointer to a frame, i.e. an array of EasyLasePoint s |
| 104 | * dataCounter: number of bytes in dataBuffer = number of points in frame |
| 105 | * multiplied by 8 |
| 106 | * speed: output speed in points per second, 500 .. 65000 |
| 107 | * Return value: 0 = success, < 0 = error. |
| 108 | */ |
| 109 | |
| 110 | int easyLaseWriteFrameNR(int cardNumber, unsigned char *dataBuffer, unsigned int dataCounter, unsigned int speed, unsigned int repeat); |
| 111 | /** int easyLaseWriteFrameNR(int cardNumber, unsigned char *dataBuffer, unsigned int dataCounter, unsigned int speed, unsigned int repeat); |
| 112 | * Send a frame like EasyLaseWriteFrame, but without automatic frame repeat, if |
| 113 | * there is no new frame following the actual one. Output stops at the last |
| 114 | * point until new frame comes in. |
| 115 | * cardNumber: selected device, 0 .. number of cards - 1 |
| 116 | * dataBuffer: pointer to a frame, i.e. an array of EasyLasePoint s |
| 117 | * dataCounter: number of bytes in dataBuffer = number of points in frame * 8 |
| 118 | * speed: output speed in points per second, 500 .. 65000 |
| 119 | * repeat: number of repetitions |
| 120 | * Return value: 0 = success, <0 = error. |
| 121 | */ |
| 122 | |
| 123 | int easyLaseStop(int cardNumber); |
| 124 | /** int easyLaseStop(int cardNumber); |
| 125 | * Output is stopped. USB connection will be left open. |
| 126 | * Return value: 0 = success, <0 = error. |
| 127 | */ |
| 128 | |
| 129 | int easyLaseWriteDMX(int cardNumber, unsigned char * dmxBuffer); |
| 130 | /** int easyLaseWriteDMX(int cardNumber, unsigned char * dmxBuffer); |
| 131 | * (old) Send of 512 bytes DMX-data from dmxBuffer to card number cardNumber. |
| 132 | * The byte array dmxBuffer contains exactly 512 bytes. |
| 133 | * It is recommended not to use this function, when significantly |
| 134 | * less than 512 channels are used! |
| 135 | * Return value: 0 = success, <0 = error. |
| 136 | */ |
| 137 | |
| 138 | int easyLaseDMXOut(int cardNumber, unsigned char * dmxBuffer, unsigned int baseAddress, unsigned int channelCount); |
| 139 | /** int easyLaseDMXOut(int cardNumber, unsigned char * dmxBuffer, unsigned int baseAddress, unsigned int channelCount); |
| 140 | * (new) Output of n-DMX-databytes (ChannelCount) starting at dmxBuffer |
| 141 | * from card number cardNumber. The card outputs these DMX-channels starting |
| 142 | * from base address baseAddress. |
| 143 | * The length of the byte array dmxBuffer is the number of channels channelCount. |
| 144 | * Example: Writing 4 channels from baseaddress 16, the array contains 4 bytes |
| 145 | * (not 20). |
| 146 | * cardNumber: selected device, 0 .. number of cards - 1 |
| 147 | * baseAddress: start address, value 0 ..â 511 (note that Baseaddress starts from 0) |
| 148 | * channelCount: number of channels to transfer, value 1 .. 512 |
| 149 | * Return value: 0 = success, <0 = error or invalid parameters. |
| 150 | * A value of baseAddress > 511 or channelCount = 0 or the sum of baseAddress and |
| 151 | * channelCount >512 will return -1. |
| 152 | * It is recommended to use this function, when significantly less than 512 |
| 153 | * DMX-channels are used. |
| 154 | */ |
| 155 | |
| 156 | int easyLaseGetDMX(int cardNumber, unsigned char * dmxBuffer); |
| 157 | /** (old) Read 512 bytes DMX data from card number cardNumber to buffer dmxBuffer. |
| 158 | * The dataarray dmxBuffer exactly contains 512 bytes. |
| 159 | * Return value: 0 = success, <0 = error. |
| 160 | * It is recommended not to use this function, when significantly less than 512 |
| 161 | * channels are used! |
| 162 | */ |
| 163 | |
| 164 | |
| 165 | int easyLaseDMXIn(int cardNumber, unsigned char * dmxBuffer, unsigned int baseAddress, unsigned int channelCount); |
| 166 | /** (new) Reading of n-DMX-databytes channelCount starting at dmxBuffer from card |
| 167 | * number cardNumber. The card sends these DMX-channels via USB starting from base |
| 168 | * address baseAddress. |
| 169 | * The length of the byte array @dmxbuffer is the number of channels channelCount. |
| 170 | * Example: Writing 4 channels from baseaddress 16, the array contains 4 bytes |
| 171 | * (not 20). |
| 172 | * cardNumber: selected device, 0 .. number of cards - 1 |
| 173 | * baseAddress: start address, value 0 ..â 511 (note that Baseaddress starts from 0) |
| 174 | * channelCount: number of channels to transfer, value 1 .. 512 |
| 175 | * Return value: 0 = success, <0 = error or invalid parameters. |
| 176 | * A value of baseAddress > 511 or channelCount = 0 or the sum of baseAddress and |
| 177 | * channelCount >512 will return -1. |
| 178 | * It is recommended to use this function, when significantly less than 512 |
| 179 | * DMX-channels are used. |
| 180 | */ |
| 181 | |
| 182 | int easyLaseWriteTTL(int cardNumber, unsigned int ttl); |
| 183 | /** int easyLaseWriteTTL(int cardNumber, unsigned int ttl); |
| 184 | * Send 16 Bit TTL-value ttl to card number cardNumber. |
| 185 | */ |
| 186 | |
| 187 | int easyLaseGetLastError(int cardNumber); |
| 188 | /** int easyLaseGetLastError(int cardNumber); |
| 189 | * returns the last status of the USB driver (0= okay, !=0 = error). |
| 190 | */ |
| 191 | |
| 192 | #define EASYLASE_GET_STATUS_READY 0x01 |
| 193 | #define EASYLASE_GET_STATUS_BUSY 0x02 |
| 194 | |
| 195 | int easyLaseGetStatus(int cardNumber); |
| 196 | /** int easyLaseGetStatus(int cardNumber); |
| 197 | * Returns the status of the on board framebuffers. |
| 198 | * Return Value: 0 = USB error |
| 199 | * 1 = Ready (a new frame can be received) |
| 200 | * 2 = Busy (all buffers full, incoming frames will be discarded) |
| 201 | */ |
| 202 | |
| 203 | |
| 204 | int easyLaseClose(); |
| 205 | /** int easyLaseClose(); //Call this when closing the application! |
| 206 | * Close all USB connections to EasyLase cards. |
| 207 | * Return value: 0 = success, <0 = error. |
| 208 | */ |
