feat: basic H7 support (#5228)
Co-authored-by: Malte Langermann <malte@langermann.net> Co-authored-by: 3djc <3djc@gh.com> Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Co-authored-by: Richard Li <richard.li@ces.hk>
This commit is contained in:
co-authored by
Malte Langermann
3djc
raphaelcoeffic
Richard Li
parent
2110f1b938
commit
6f8a5313d5
@@ -542,11 +542,11 @@ void r_zov_color(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
const char* val, uint8_t val_len)
|
||||
{
|
||||
data += bitoffs >> 3UL;
|
||||
auto p_val = reinterpret_cast<ZoneOptionValue*>(data);
|
||||
|
||||
ZoneOptionValue zov;
|
||||
if (strncmp(val, "COLIDX", 6) == 0) {
|
||||
val += 6; val_len -= 6;
|
||||
p_val->unsignedValue = COLOR2FLAGS(yaml_str2uint(val, val_len));
|
||||
zov.unsignedValue = COLOR2FLAGS(yaml_str2uint(val, val_len));
|
||||
} else {
|
||||
if (val_len < sizeof("0xFFFFFF")-1
|
||||
|| val[0] != '0'
|
||||
@@ -556,28 +556,32 @@ void r_zov_color(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
val += 2; val_len -= 2;
|
||||
|
||||
auto rgb24 = yaml_hex2uint(val, val_len);
|
||||
p_val->unsignedValue =
|
||||
RGB2FLAGS((rgb24 & 0xFF0000) >> 16, (rgb24 & 0xFF00) >> 8, rgb24 & 0xFF);
|
||||
zov.unsignedValue = RGB2FLAGS((rgb24 & 0xFF0000) >> 16,
|
||||
(rgb24 & 0xFF00) >> 8, rgb24 & 0xFF);
|
||||
}
|
||||
|
||||
memcpy(data, &zov, sizeof(ZoneOptionValue));
|
||||
}
|
||||
|
||||
bool w_zov_color(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
yaml_writer_func wf, void* opaque)
|
||||
{
|
||||
data += bitoffs >> 3UL;
|
||||
auto p_val = (reinterpret_cast<ZoneOptionValue*>(data))->unsignedValue;
|
||||
|
||||
if (p_val & RGB_FLAG) {
|
||||
p_val = COLOR_VAL(p_val);
|
||||
uint32_t color = (uint32_t)GET_RED(p_val) << 16 |
|
||||
(uint32_t)GET_GREEN(p_val) << 8 |
|
||||
(uint32_t)GET_BLUE(p_val);
|
||||
ZoneOptionValue zov;
|
||||
memcpy(&zov, data, sizeof(ZoneOptionValue));
|
||||
|
||||
uint32_t val = zov.unsignedValue;
|
||||
if (val & RGB_FLAG) {
|
||||
val = COLOR_VAL(val);
|
||||
uint32_t color = (uint32_t)GET_RED(val) << 16 |
|
||||
(uint32_t)GET_GREEN(val) << 8 | (uint32_t)GET_BLUE(val);
|
||||
|
||||
if (!wf(opaque, "0x", 2)) return false;
|
||||
return wf(opaque, yaml_rgb2hex(color), 3 * 2);
|
||||
} else {
|
||||
if (!wf(opaque, "COLIDX", 6)) return false;
|
||||
const char* str = yaml_unsigned2str(COLOR_VAL(p_val));
|
||||
const char* str = yaml_unsigned2str(COLOR_VAL(val));
|
||||
return wf(opaque, str, strlen(str));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user