Files
waveform-draw/draw_parra/artnet_receiver.h
2025-12-17 02:24:38 +01:00

42 lines
1.8 KiB
C
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* --------------------------------------------------------------------
* artnet_receiver.c tiny ArtNet 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 ArtNet thread will write to.
* They are declared `extern` here and defined in the main file.
* --------------------------------------------------------------- */
extern int16_t rotAnglesDeg[12]; /* 0 … 180° (mapped from 0255) */
extern int LINE_THICKNESS; /* 1 … 10 (clamped) */
extern int MARGIN_TOP; /* 0 … 200px (scaled) */
extern int MARGIN_BOTTOM; /* 0 … 200px (scaled) */
#endif /* ARTNET_RECEIVER_H */