add functions to convert containers directly into packet
This commit is contained in:
parent
1e442012be
commit
baa450b2f7
10 changed files with 178 additions and 20 deletions
|
@ -23,8 +23,10 @@ int main(void) {
|
|||
sp_char_grid_set(grid, 3, 1, 'l');
|
||||
sp_char_grid_set(grid, 4, 1, 'd');
|
||||
|
||||
TypedCommand *command = sp_command_char_grid(0, 0, grid);
|
||||
sp_udp_send_command(connection, command);
|
||||
Packet *packet = sp_char_grid_into_packet(grid, 0, 0);
|
||||
if (packet == NULL)
|
||||
return 1;
|
||||
sp_udp_send_packet(connection, packet);
|
||||
|
||||
sp_udp_free(connection);
|
||||
return 0;
|
||||
|
|
|
@ -8,11 +8,12 @@ int main(void) {
|
|||
|
||||
Bitmap *all_on = sp_bitmap_new_max_sized();
|
||||
sp_bitmap_fill(all_on, true);
|
||||
TypedCommand *cmd = sp_command_bitmap(0, 0, all_on, COMPRESSION_CODE_UNCOMPRESSED);
|
||||
if (cmd == NULL)
|
||||
|
||||
Packet *packet = sp_bitmap_into_packet(all_on, 0, 0, COMPRESSION_CODE_UNCOMPRESSED);
|
||||
if (packet == NULL)
|
||||
return -1;
|
||||
|
||||
sp_udp_send_command(connection, cmd);
|
||||
sp_udp_send_packet(connection, packet);
|
||||
|
||||
BrightnessGrid *grid = sp_brightness_grid_new(TILE_WIDTH, TILE_HEIGHT);
|
||||
|
||||
|
@ -21,8 +22,8 @@ int main(void) {
|
|||
slice.start[index] = (uint8_t) (index % ((size_t) Brightness_MAX));
|
||||
}
|
||||
|
||||
TypedCommand *command = sp_command_brightness_grid(0, 0, grid);
|
||||
sp_udp_send_command(connection, command);
|
||||
packet = sp_brightness_grid_into_packet(grid, 0, 0);
|
||||
sp_udp_send_packet(connection, packet);
|
||||
|
||||
sp_udp_free(connection);
|
||||
return 0;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <stdio.h>
|
||||
#include "servicepoint.h"
|
||||
|
||||
int main(void) {
|
||||
|
@ -11,14 +12,12 @@ int main(void) {
|
|||
|
||||
sp_bitmap_fill(pixels, true);
|
||||
|
||||
TypedCommand *command = sp_command_bitmap(0, 0, pixels, COMPRESSION_CODE_UNCOMPRESSED);
|
||||
if (command == NULL)
|
||||
Packet *packet = sp_bitmap_into_packet(pixels, 0, 0, COMPRESSION_CODE_UNCOMPRESSED);
|
||||
if (packet == NULL)
|
||||
return 1;
|
||||
|
||||
Packet *packet = sp_packet_from_command(command);
|
||||
|
||||
Header *header = sp_packet_get_header(packet);
|
||||
//printf("[%d, %d, %d, %d, %d]\n", header->command_code, header->a, header->b, header->c, header->d);
|
||||
printf("[%d, %d, %d, %d, %d]\n", header->command_code, header->a, header->b, header->c, header->d);
|
||||
|
||||
sp_udp_send_packet(connection, packet);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue