From b624f32f944acdc59dcb130674c09090c5c404cb Mon Sep 17 00:00:00 2001 From: skullY Date: Fri, 30 Aug 2019 11:19:03 -0700 Subject: clang-format changes --- quantum/visualizer/lcd_backlight.c | 50 ++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'quantum/visualizer/lcd_backlight.c') diff --git a/quantum/visualizer/lcd_backlight.c b/quantum/visualizer/lcd_backlight.c index 6cd996f75e..23978974e3 100644 --- a/quantum/visualizer/lcd_backlight.c +++ b/quantum/visualizer/lcd_backlight.c @@ -25,9 +25,9 @@ SOFTWARE. #include "lcd_backlight.h" #include -static uint8_t current_hue = 0; +static uint8_t current_hue = 0; static uint8_t current_saturation = 0; -static uint8_t current_intensity = 0; +static uint8_t current_intensity = 0; static uint8_t current_brightness = 0; void lcd_backlight_init(void) { @@ -40,26 +40,26 @@ void lcd_backlight_init(void) { // http://blog.saikoled.com/post/43693602826/why-every-led-light-should-be-using-hsi static void hsi_to_rgb(float h, float s, float i, uint16_t* r_out, uint16_t* g_out, uint16_t* b_out) { unsigned int r, g, b; - h = fmodf(h, 360.0f); // cycle h around to 0-360 degrees - h = 3.14159f * h / 180.0f; // Convert to radians. - s = s > 0.0f ? (s < 1.0f ? s : 1.0f) : 0.0f; // clamp s and i to interval [0,1] + h = fmodf(h, 360.0f); // cycle h around to 0-360 degrees + h = 3.14159f * h / 180.0f; // Convert to radians. + s = s > 0.0f ? (s < 1.0f ? s : 1.0f) : 0.0f; // clamp s and i to interval [0,1] i = i > 0.0f ? (i < 1.0f ? i : 1.0f) : 0.0f; // Math! Thanks in part to Kyle Miller. - if(h < 2.09439f) { - r = 65535.0f * i/3.0f *(1.0f + s * cos(h) / cosf(1.047196667f - h)); - g = 65535.0f * i/3.0f *(1.0f + s *(1.0f - cosf(h) / cos(1.047196667f - h))); - b = 65535.0f * i/3.0f *(1.0f - s); - } else if(h < 4.188787) { + if (h < 2.09439f) { + r = 65535.0f * i / 3.0f * (1.0f + s * cos(h) / cosf(1.047196667f - h)); + g = 65535.0f * i / 3.0f * (1.0f + s * (1.0f - cosf(h) / cos(1.047196667f - h))); + b = 65535.0f * i / 3.0f * (1.0f - s); + } else if (h < 4.188787) { h = h - 2.09439; - g = 65535.0f * i/3.0f *(1.0f + s * cosf(h) / cosf(1.047196667f - h)); - b = 65535.0f * i/3.0f *(1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h))); - r = 65535.0f * i/3.0f *(1.0f - s); + g = 65535.0f * i / 3.0f * (1.0f + s * cosf(h) / cosf(1.047196667f - h)); + b = 65535.0f * i / 3.0f * (1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h))); + r = 65535.0f * i / 3.0f * (1.0f - s); } else { h = h - 4.188787; - b = 65535.0f*i/3.0f * (1.0f + s * cosf(h) / cosf(1.047196667f - h)); - r = 65535.0f*i/3.0f * (1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h))); - g = 65535.0f*i/3.0f * (1.0f - s); + b = 65535.0f * i / 3.0f * (1.0f + s * cosf(h) / cosf(1.047196667f - h)); + r = 65535.0f * i / 3.0f * (1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h))); + g = 65535.0f * i / 3.0f * (1.0f - s); } *r_out = r > 65535 ? 65535 : r; *g_out = g > 65535 ? 65535 : g; @@ -68,15 +68,15 @@ static void hsi_to_rgb(float h, float s, float i, uint16_t* r_out, uint16_t* g_o void lcd_backlight_color(uint8_t hue, uint8_t saturation, uint8_t intensity) { uint16_t r, g, b; - float hue_f = 360.0f * (float)hue / 255.0f; - float saturation_f = (float)saturation / 255.0f; - float intensity_f = (float)intensity / 255.0f; + float hue_f = 360.0f * (float)hue / 255.0f; + float saturation_f = (float)saturation / 255.0f; + float intensity_f = (float)intensity / 255.0f; intensity_f *= (float)current_brightness / 255.0f; hsi_to_rgb(hue_f, saturation_f, intensity_f, &r, &g, &b); - current_hue = hue; - current_saturation = saturation; - current_intensity = intensity; - lcd_backlight_hal_color(r, g, b); + current_hue = hue; + current_saturation = saturation; + current_intensity = intensity; + lcd_backlight_hal_color(r, g, b); } void lcd_backlight_brightness(uint8_t b) { @@ -84,6 +84,4 @@ void lcd_backlight_brightness(uint8_t b) { lcd_backlight_color(current_hue, current_saturation, current_intensity); } -uint8_t lcd_get_backlight_brightness(void) { - return current_brightness; -} +uint8_t lcd_get_backlight_brightness(void) { return current_brightness; } -- cgit v1.2.3