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

@@ -23,6 +23,8 @@
#include <arpa/inet.h>
#include <sys/socket.h>
#include "artnet_receiver.h"
#define FB_W 800 /* framebuffer width */
#define FB_H 600 /* framebuffer height */
#define BPP 4 /* bytes per pixel (A,R,G,B) */
@@ -35,9 +37,9 @@
#define LINE_THICKNESS 4 /* thickness of outline (pixels) */
#define NUM_RECTS 12
/*---------------------------------------------------------------*/
/* 1. Perrectangle tilt angles (in degrees). Edit as you wish. */
static int16_t rotAnglesDeg[NUM_RECTS] = {
///*---------------------------------------------------------------*/
///* 1. Perrectangle tilt angles (in degrees). Edit as you wish. */
int16_t rotAnglesDeg[NUM_RECTS] = {
0, 5, 10, 15, 20, 25,
30, 35, 40, 45, 50, 55
};
@@ -205,6 +207,15 @@ static int send_framebuffer(const uint8_t *fb, size_t len,
/*---------------------------------------------------------------*/
int main(void)
{
/* ---------------------------------------------------------------
* 1⃣ Start ArtNet receiver it will fill the globals
* --------------------------------------------------------------- */
if (!artnet_init()) {
fprintf(stderr, "Failed to start ArtNet receiver\n");
return EXIT_FAILURE;
}
uint8_t *framebuf = malloc(FRAMEBUF_SIZE);
if (!framebuf) {
fprintf(stderr, "Failed to allocate framebuffer (%zu bytes)\n",
@@ -213,17 +224,17 @@ int main(void)
}
while(1){
for(uint8_t i=0; i<sizeof(rotAnglesDeg)/sizeof(rotAnglesDeg[0]); i++)
rotAnglesDeg[i]=(rotAnglesDeg[i]+3)%180;
//for(uint8_t i=0; i<sizeof(rotAnglesDeg)/sizeof(rotAnglesDeg[0]); i++)
// rotAnglesDeg[i]=(rotAnglesDeg[i]+3)%180;
build_framebuffer(framebuf);
if (send_framebuffer(framebuf, FRAMEBUF_SIZE, "127.0.0.1", 12345) != 0) {
fprintf(stderr, "Failed to send framebuffer\n");
free(framebuf);
return EXIT_FAILURE;
}
build_framebuffer(framebuf);
if (send_framebuffer(framebuf, FRAMEBUF_SIZE, "127.0.0.1", 12345) != 0) {
fprintf(stderr, "Failed to send framebuffer\n");
free(framebuf);
return EXIT_FAILURE;
}
usleep(100000);
usleep(100000);
}
printf("Framebuffer (%zu bytes) sent successfully.\n", (size_t)FRAMEBUF_SIZE);