fix readme
This commit is contained in:
parent
ff9b0a9dc8
commit
0344c0bdcf
20
README.md
20
README.md
|
@ -1,11 +1,11 @@
|
|||
# servicepoint_binding_c
|
||||
|
||||
[](https://git.berlin.ccc.de/servicepoint/servicepoint_binding_c/releases)
|
||||
[](https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c/releases)
|
||||
[](https://crates.io/crates/servicepoint)
|
||||
[](https://crates.io/crates/servicepoint)
|
||||
[](https://docs.rs/servicepoint/latest/servicepoint/)
|
||||
[](./LICENSE)
|
||||
[](https://git.berlin.ccc.de/servicepoint/servicepoint_binding_c)
|
||||
[](https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c)
|
||||
|
||||
In [CCCB](https://berlin.ccc.de/), there is a big pixel matrix hanging on the wall.
|
||||
It is called "Service Point Display" or "Airport Display".
|
||||
|
@ -19,18 +19,22 @@ This crate contains C bindings for the [servicepoint](https://git.berlin.ccc.de/
|
|||
#include "servicepoint.h"
|
||||
|
||||
int main(void) {
|
||||
SPConnection *connection = sp_connection_open("172.23.42.29:2342");
|
||||
UdpSocket *connection = sp_udp_socket_open("172.23.42.29:2342");
|
||||
if (connection == NULL)
|
||||
return 1;
|
||||
|
||||
SPBitmap *pixels = sp_bitmap_new(SP_PIXEL_WIDTH, SP_PIXEL_HEIGHT);
|
||||
Bitmap *pixels = sp_bitmap_new(PIXEL_WIDTH, PIXEL_HEIGHT);
|
||||
sp_bitmap_fill(pixels, true);
|
||||
|
||||
SPCommand *command = sp_command_bitmap_linear_win(0, 0, pixels, Uncompressed);
|
||||
while (sp_connection_send_command(connection, sp_command_clone(command)));
|
||||
BitmapCommand *command = sp_bitmap_command_new(pixels, 0, 0, COMPRESSION_CODE_LZMA);
|
||||
Packet *packet = sp_bitmap_command_try_into_packet(command);
|
||||
if (packet == NULL)
|
||||
return 1;
|
||||
|
||||
if (!sp_udp_socket_send_packet(connection, packet))
|
||||
return 1;
|
||||
|
||||
sp_command_free(command);
|
||||
sp_connection_free(connection);
|
||||
sp_udp_socket_free(connection);
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
|
|
@ -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
33
example/src/flut.c
Normal 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;
|
||||
}
|
Loading…
Reference in a new issue