Format code according to conventions (#15196)

master
QMK Bot 2021-11-17 13:07:45 -08:00 committed by GitHub
parent e0a5056963
commit cc7600cf0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 29 deletions

View File

@ -237,8 +237,8 @@ static uint16_t cie_lightness(uint16_t v) {
return v / 9; // Same as dividing by 900% return v / 9; // Same as dividing by 900%
} else { } else {
// In the next two lines values are bit-shifted. This is to avoid loosing decimals in integer math. // In the next two lines values are bit-shifted. This is to avoid loosing decimals in integer math.
uint32_t y = (((uint32_t)v + ICRx / 6) << 5) / (ICRx / 6 + ICRx); // If above 8%, add ~16% of max, and normalize with (max + ~16% max) uint32_t y = (((uint32_t)v + ICRx / 6) << 5) / (ICRx / 6 + ICRx); // If above 8%, add ~16% of max, and normalize with (max + ~16% max)
uint32_t out = (y * y * y * ICRx) >> 15; // Cube it and undo the bit-shifting. (which is now three times as much due to the cubing) uint32_t out = (y * y * y * ICRx) >> 15; // Cube it and undo the bit-shifting. (which is now three times as much due to the cubing)
if (out > ICRx) // Avoid overflows if (out > ICRx) // Avoid overflows
{ {
@ -297,7 +297,7 @@ static uint16_t breathing_counter = 0;
static uint8_t breath_scale_counter = 1; static uint8_t breath_scale_counter = 1;
/* Run the breathing loop at ~120Hz*/ /* Run the breathing loop at ~120Hz*/
const uint8_t breathing_ISR_frequency = 120; const uint8_t breathing_ISR_frequency = 120;
static uint16_t breathing_freq_scale_factor = 2; static uint16_t breathing_freq_scale_factor = 2;
# ifdef BACKLIGHT_PWM_TIMER # ifdef BACKLIGHT_PWM_TIMER
@ -327,14 +327,14 @@ bool is_breathing(void) { return !!(TIMSKx & _BV(TOIEx)); }
} while (0) } while (0)
# endif # endif
# define breathing_min() \ # define breathing_min() \
do { \ do { \
breathing_counter = 0; \ breathing_counter = 0; \
} while (0) } while (0)
# define breathing_max() \ # define breathing_max() \
do { \ do { \
breathing_counter = breathing_period * breathing_ISR_frequency / 2; \ breathing_counter = breathing_period * breathing_ISR_frequency / 2; \
} while (0) } while (0)
void breathing_enable(void) { void breathing_enable(void) {
breathing_counter = 0; breathing_counter = 0;
@ -385,18 +385,15 @@ ISR(TIMERx_OVF_vect)
{ {
// Only run this ISR at ~120 Hz // Only run this ISR at ~120 Hz
if(breath_scale_counter++ == breathing_freq_scale_factor) if (breath_scale_counter++ == breathing_freq_scale_factor) {
{
breath_scale_counter = 1; breath_scale_counter = 1;
} } else {
else
{
return; return;
} }
uint16_t interval = (uint16_t)breathing_period * breathing_ISR_frequency / BREATHING_STEPS; uint16_t interval = (uint16_t)breathing_period * breathing_ISR_frequency / BREATHING_STEPS;
// resetting after one period to prevent ugly reset at overflow. // resetting after one period to prevent ugly reset at overflow.
breathing_counter = (breathing_counter + 1) % (breathing_period * breathing_ISR_frequency); breathing_counter = (breathing_counter + 1) % (breathing_period * breathing_ISR_frequency);
uint8_t index = breathing_counter / interval % BREATHING_STEPS; uint8_t index = breathing_counter / interval % BREATHING_STEPS;
if (((breathing_halt == BREATHING_HALT_ON) && (index == BREATHING_STEPS / 2)) || ((breathing_halt == BREATHING_HALT_OFF) && (index == BREATHING_STEPS - 1))) { if (((breathing_halt == BREATHING_HALT_ON) && (index == BREATHING_STEPS / 2)) || ((breathing_halt == BREATHING_HALT_OFF) && (index == BREATHING_STEPS - 1))) {
breathing_interrupt_disable(); breathing_interrupt_disable();
@ -435,21 +432,21 @@ void backlight_init_ports(void) {
*/ */
TCCRxA = _BV(COMxx1) | _BV(WGM11); // = 0b00001010; TCCRxA = _BV(COMxx1) | _BV(WGM11); // = 0b00001010;
TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; TCCRxB = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
# endif #endif
# ifdef BACKLIGHT_CUSTOM_RESOLUTION #ifdef BACKLIGHT_CUSTOM_RESOLUTION
# if (BACKLIGHT_CUSTOM_RESOLUTION > 0xFFFF || BACKLIGHT_CUSTOM_RESOLUTION < 1) # if (BACKLIGHT_CUSTOM_RESOLUTION > 0xFFFF || BACKLIGHT_CUSTOM_RESOLUTION < 1)
# error "This out of range of the timer capabilities" # error "This out of range of the timer capabilities"
# elif (BACKLIGHT_CUSTOM_RESOLUTION < 0xFF) # elif (BACKLIGHT_CUSTOM_RESOLUTION < 0xFF)
# warning "Resolution lower than 0xFF isn't recommended" # warning "Resolution lower than 0xFF isn't recommended"
# endif # endif
# ifdef BACKLIGHT_BREATHING # ifdef BACKLIGHT_BREATHING
breathing_freq_scale_factor = F_CPU / BACKLIGHT_CUSTOM_RESOLUTION / 120; breathing_freq_scale_factor = F_CPU / BACKLIGHT_CUSTOM_RESOLUTION / 120;
# endif # endif
ICRx = BACKLIGHT_CUSTOM_RESOLUTION; ICRx = BACKLIGHT_CUSTOM_RESOLUTION;
# else #else
ICRx = TIMER_TOP; ICRx = TIMER_TOP;
# endif #endif
backlight_init(); backlight_init();
#ifdef BACKLIGHT_BREATHING #ifdef BACKLIGHT_BREATHING