add vibecoded artnet lib

This commit is contained in:
2025-12-17 02:24:38 +01:00
parent 97e9a03610
commit a450f351c5
4 changed files with 201 additions and 14 deletions

View File

@@ -0,0 +1,41 @@
/* --------------------------------------------------------------------
* 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 */