fix readme

This commit is contained in:
Vinzenz Schroeter 2025-06-28 20:23:23 +02:00
parent ff9b0a9dc8
commit 0344c0bdcf
3 changed files with 46 additions and 9 deletions

View file

@ -96,7 +96,7 @@ endif
# ADD NEW EXAMPLES HERE
_c_src := src/announce.c src/brightness_tester.c src/header_logger.c \
src/moving_line.c src/random_stuff.c src/wiping_clear.c src/undefined.c
src/moving_line.c src/random_stuff.c src/wiping_clear.c src/undefined.c src/flut.c
_programs := $(basename $(notdir $(_c_src)))
_bins := $(_programs)
_unstripped_bins := $(addsuffix _unstripped, $(_bins))

33
example/src/flut.c Normal file
View file

@ -0,0 +1,33 @@
#include <stdio.h>
#include <signal.h>
#include "servicepoint.h"
volatile bool aborted = false;
void handle_sigint(int sig) {
(void)sig; // suppress unused warning
aborted = true;
}
int main(void) {
UdpSocket *connection = sp_udp_socket_open("172.23.42.29:2342");
if (connection == NULL)
return 1;
Bitmap *pixels = sp_bitmap_new(PIXEL_WIDTH, PIXEL_HEIGHT);
sp_bitmap_fill(pixels, true);
BitmapCommand *command = sp_bitmap_command_new(pixels, 0, 0, COMPRESSION_CODE_LZMA);
Packet *packet = sp_bitmap_command_try_into_packet(command);
signal(SIGINT, handle_sigint);
size_t packets_sent = 0;
while (!aborted && sp_udp_socket_send_packet(connection, sp_packet_clone(packet))) {
++packets_sent;
}
printf("packets sent: %zu\n", packets_sent);
sp_packet_free(packet);
sp_udp_socket_free(connection);
return 0;
}