13
0

changed parantheses and lines

This commit is contained in:
alex 2023-03-06 00:43:34 +01:00
parent 777c7c6c03
commit 4ca947f078
2 changed files with 29 additions and 18 deletions

View File

@ -1663,6 +1663,7 @@ Surface::display_colors_on_xtouch(const XTouchColors color_values[]) const
uint8_t uint8_t
Surface::convert_color_to_xtouch_value (uint32_t color) const Surface::convert_color_to_xtouch_value (uint32_t color) const
{ {
uint8_t red = color >> 24; uint8_t red = color >> 24;
uint8_t green = (color >> 16) & 0xff; uint8_t green = (color >> 16) & 0xff;
uint8_t blue = (color >> 8) & 0xff; uint8_t blue = (color >> 8) & 0xff;
@ -1676,6 +1677,7 @@ Surface::convert_color_to_xtouch_value(uint32_t color) const
} }
if (max != 0) { if (max != 0) {
//set the highest value to 0xFF to be brightness independent //set the highest value to 0xFF to be brightness independent
float norm = 255.0/max; float norm = 255.0/max;
@ -1685,17 +1687,26 @@ Surface::convert_color_to_xtouch_value(uint32_t color) const
uint8_t xcolor = 0; uint8_t xcolor = 0;
if (red > 0x7f) { if (red > 0x7f) {
xcolor = xcolor | 0b001; //lowest bit is red xcolor = xcolor | 0b001; //lowest bit is red
} }
if (green > 0x7f) { if (green > 0x7f) {
xcolor = xcolor | 0b010; //second bit is green xcolor = xcolor | 0b010; //second bit is green
} }
if (blue > 0x7f) { if (blue > 0x7f) {
xcolor = xcolor | 0b100; //third bit is blue xcolor = xcolor | 0b100; //third bit is blue
} }
return xcolor; return xcolor;
}
else{ } else {
return White; //if it would be black (color = 0x000000) return white, because black means off return White; //if it would be black (color = 0x000000) return white, because black means off
} }
} }