42 lines
1.8 KiB
C
42 lines
1.8 KiB
C
/* --------------------------------------------------------------------
|
||
* artnet_receiver.c – tiny Art‑Net DMX receiver
|
||
*
|
||
* This file contains only the pieces you need to:
|
||
* * open a UDP socket on port 6454,
|
||
* * receive ArtDMX packets,
|
||
* * extract the DMX data (up to 512 bytes),
|
||
* * copy the first N bytes into the variables of the main program.
|
||
*
|
||
* The code is deliberately simple – it ignores ArtPoll, ArtSync,
|
||
* multiple universes, etc. If you need those features you can replace
|
||
* the receive loop with libartnet or another full implementation.
|
||
* -------------------------------------------------------------------- */
|
||
|
||
#ifndef ARTNET_RECEIVER_H
|
||
#define ARTNET_RECEIVER_H
|
||
|
||
#include <stddef.h>
|
||
#include <stdint.h>
|
||
#include <stdbool.h>
|
||
#include <pthread.h>
|
||
|
||
/* ---------------------------------------------------------------
|
||
* Public API – call from the main program
|
||
*
|
||
* artnet_init() : creates the receiving thread.
|
||
* artnet_stop() : asks the thread to terminate and joins it.
|
||
* --------------------------------------------------------------- */
|
||
bool artnet_init(void); /* returns true on success */
|
||
void artnet_stop(void);
|
||
|
||
/* ---------------------------------------------------------------
|
||
* The variables that the Art‑Net thread will write to.
|
||
* They are declared `extern` here and defined in the main file.
|
||
* --------------------------------------------------------------- */
|
||
extern int16_t rotAnglesDeg[12]; /* 0 … 180° (mapped from 0‑255) */
|
||
extern int LINE_THICKNESS; /* 1 … 10 (clamped) */
|
||
extern int MARGIN_TOP; /* 0 … 200 px (scaled) */
|
||
extern int MARGIN_BOTTOM; /* 0 … 200 px (scaled) */
|
||
|
||
#endif /* ARTNET_RECEIVER_H */
|