more commands
This commit is contained in:
parent
2165629bef
commit
4f0eca3ea0
9 changed files with 489 additions and 78 deletions
|
@ -1,30 +1,44 @@
|
|||
#include "servicepoint.h"
|
||||
|
||||
int main(void) {
|
||||
UdpSocket *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342);
|
||||
//UdpSocket *connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342);
|
||||
if (connection == NULL)
|
||||
return -1;
|
||||
static UdpSocket *connection = NULL;
|
||||
|
||||
void enable_all_pixels(void) {
|
||||
Bitmap *all_on = sp_bitmap_new_max_sized();
|
||||
sp_bitmap_fill(all_on, true);
|
||||
|
||||
Packet *packet = sp_bitmap_into_packet(all_on, 0, 0, COMPRESSION_CODE_UNCOMPRESSED);
|
||||
if (packet == NULL)
|
||||
return -1;
|
||||
|
||||
sp_udp_send_packet(connection, packet);
|
||||
|
||||
BrightnessGrid *grid = sp_brightness_grid_new(TILE_WIDTH, TILE_HEIGHT);
|
||||
BitmapCommand *bitmapCommand = sp_cmd_bitmap_from_bitmap(all_on);
|
||||
Packet *packet = sp_cmd_bitmap_into_packet(bitmapCommand);
|
||||
if (packet != NULL)
|
||||
sp_udp_send_packet(connection, packet);
|
||||
}
|
||||
|
||||
void make_brightness_pattern(BrightnessGrid *grid) {
|
||||
ByteSlice slice = sp_brightness_grid_unsafe_data_ref(grid);
|
||||
for (size_t index = 0; index < slice.length; index++) {
|
||||
slice.start[index] = (uint8_t) (index % ((size_t) Brightness_MAX));
|
||||
}
|
||||
}
|
||||
|
||||
packet = sp_brightness_grid_into_packet(grid, 0, 0);
|
||||
sp_udp_send_packet(connection, packet);
|
||||
|
||||
void run_at_exit() {
|
||||
sp_udp_free(connection);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
//UdpSocket *connection = sp_udp_open_ipv4(172, 23, 42, 29, 2342);
|
||||
connection = sp_udp_open_ipv4(127, 0, 0, 1, 2342);
|
||||
if (connection == NULL)
|
||||
return -1;
|
||||
atexit(run_at_exit);
|
||||
|
||||
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(connection, packet);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue