Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
process the message once received
// Example = 001#aa00ff
// Split message at '#' into pixel_number and hex_colour
const auto pixel_end = framedata.indexOf('#', 0);
const auto pixel_number_str = framedata.substring(0, pixel_end);
const auto hex_colour_str = framedata.substring(pixel_end + 1);
auto pixel_number = pixel_number_str.toInt();
char hex_code[7];
int r, g, b = 0;
// Convert hex value to RGB
hex_colour_str.toCharArray(hex_code, 7);
sscanf(hex_code, "%02x%02x%02x", &r, &g, &b);
// Update the lights on the display with the pixel number and rgb values
lights::update_pixel(pixel_number, r, g, b);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment