servicepoint-binding-c/example/src/brightness_tester.c
2025-06-17 22:21:11 +02:00

36 lines
994 B
C

#include "servicepoint.h"
#include "helpers.h"
void enable_all_pixels(void) {
Bitmap *all_on = sp_bitmap_new_max_sized();
sp_bitmap_fill(all_on, true);
BitmapCommand *bitmapCommand = sp_cmd_bitmap_from_bitmap(all_on);
Packet *packet = sp_cmd_bitmap_try_into_packet(bitmapCommand);
if (packet != NULL)
sp_udp_send_packet(sock, packet);
}
void make_brightness_pattern(BrightnessGrid *grid) {
ByteSlice slice = sp_brightness_grid_data_ref_mut(grid);
for (size_t index = 0; index < slice.length; index++) {
slice.start[index] = (uint8_t)(index % ((size_t) Brightness_MAX));
}
}
int main(void) {
sock_init();
enable_all_pixels();
BrightnessGrid *grid = sp_brightness_grid_new(TILE_WIDTH, TILE_HEIGHT);
make_brightness_pattern(grid);
Packet *packet = sp_cmd_brightness_grid_into_packet(sp_cmd_brightness_grid_from_grid(grid));
if (packet == NULL)
return -2;
sp_udp_send_packet(sock, packet);
return 0;
}