sk6812: send END_OF_UPDATE in the last packet

This commit is contained in:
Thomas Kolb 2020-06-23 21:30:11 +02:00
parent f0afdcfa01
commit d7c5070bb9

View file

@ -22,6 +22,7 @@
#define FADE_COLOR 1
#define ADD_COLOR 2
#define SET_FADESTEP 3
#define END_OF_UPDATE 254
// creates the socket needed for steering the LED strip
int sk6812_init(struct sk6812_ctx *ctx, const char *host, unsigned short port) {
@ -102,6 +103,10 @@ void sk6812_set_fadestep(struct sk6812_ctx *ctx, uint8_t fadestep) {
}
int sk6812_commit(struct sk6812_ctx *ctx) {
// send end-of-update packet in the end
ctx->packetQueue[ctx->queueIndex].action = END_OF_UPDATE;
ctx->queueIndex++;
if(send(ctx->socket, ctx->packetQueue, ctx->queueIndex * sizeof(struct SK6812Packet), 0) == -1) {
return 1;
}