Add original Pico support

This commit is contained in:
2025-09-06 12:11:49 -04:00
parent cc57b02d8c
commit f72f505026
4 changed files with 50 additions and 16 deletions
+23 -1
View File
@@ -30,6 +30,8 @@ static void send_color(uint8_t dev_addr);
static void send_initial(uint8_t dev_addr);
static struct key * find_key(char * name);
static void set_color(char * name, uint8_t red, uint8_t green, uint8_t blue, uint8_t mode);
static uint8_t hexint (const char c);
static uint8_t hexbyte (const char * s);
static struct key key_list[NUM_KEYS] =
{
@@ -326,7 +328,9 @@ void parse_colors(char * data, uint16_t len) {
if (token != NULL) {
// first string is the RGB color code
uint8_t red, green, blue;
sscanf(token, "%2x%2x%2x", &red, &green, &blue);
red = hexbyte(token);
green = hexbyte(token+2);
blue = hexbyte(token+4);
token = strtok(NULL, ",");
if (token != NULL) {
@@ -432,3 +436,21 @@ bool load_rgb_config(void) {
tud_cdc_write_str("Configuration failed to load\n");
return false;
}
// simple helper to convert hex char to uint8_t value
static uint8_t hexint (const char c) {
if (c >= '0' && c <= '9') {
return c - '0';
} else if ( c >= 'a' && c <= 'f') {
return c - 'a' + 10;
} else if (c >= 'A' && c <= 'F') {
return c- 'A' + 10;
} else {
return 0;
}
}
// simple helper to convert 2 hex characters into a byte (uint8_t)
static uint8_t hexbyte (const char * s) {
return (hexint(s[0]) << 4) | (hexint(s[1]));
}