Prune out pure software pwm && custom driver && remove wrapping BACKLIGHT_PIN (#8041)

This commit is contained in:
Joel Challis 2020-03-01 20:22:13 +00:00 committed by GitHub
parent 3dc061ac78
commit 88356c85c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,7 +2,9 @@
#include "backlight.h"
#include "debug.h"
#if defined(BACKLIGHT_ENABLE) && (defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS))
#if !defined(BACKLIGHT_PIN) && !defined(BACKLIGHT_PINS)
# error "Backlight pin/pins not defined. Please configure."
#endif
// This logic is a bit complex, we support 3 setups:
//
@ -122,9 +124,7 @@
# define COMxx1 COM1B1
# define OCRxx OCR1B
# endif
# else
# if !defined(BACKLIGHT_CUSTOM_DRIVER)
# if !defined(B5_AUDIO) && !defined(B6_AUDIO) && !defined(B7_AUDIO)
#elif !defined(B5_AUDIO) && !defined(B6_AUDIO) && !defined(B7_AUDIO)
// Timer 1 is not in use by Audio feature, Backlight can use it
# pragma message "Using hardware timer 1 with software PWM"
# define HARDWARE_PWM
@ -158,14 +158,10 @@
# define OCIExA OCIE3A
# define OCRxx OCR3A
#elif defined(BACKLIGHT_CUSTOM_DRIVER)
error("Please set 'BACKLIGHT_DRIVER = custom' within rules.mk")
#else
# pragma message "Audio in use - using pure software PWM"
# define NO_HARDWARE_PWM
# endif
# else
# pragma message "Custom driver defined - using pure software PWM"
# define NO_HARDWARE_PWM
# endif
error("Please set 'BACKLIGHT_DRIVER = software' within rules.mk")
#endif
#ifndef BACKLIGHT_ON_STATE
@ -188,7 +184,7 @@ void backlight_off(pin_t backlight_pin) {
#endif
}
# if defined(NO_HARDWARE_PWM) || defined(BACKLIGHT_PWM_TIMER) // pwm through software
#ifdef BACKLIGHT_PWM_TIMER // pwm through software
// we support multiple backlight pins
# ifndef BACKLIGHT_LED_COUNT
@ -234,39 +230,6 @@ static const pin_t backlight_pin = BACKLIGHT_PIN;
#endif
# ifdef NO_HARDWARE_PWM
void backlight_init_ports(void) {
// Setup backlight pin as output and output to on state.
FOR_EACH_LED(setPinOutput(backlight_pin); backlight_on(backlight_pin);)
# ifdef BACKLIGHT_BREATHING
if (is_backlight_breathing()) {
breathing_enable();
}
# endif
}
uint8_t backlight_tick = 0;
# ifndef BACKLIGHT_CUSTOM_DRIVER
void backlight_task(void) {
if ((0xFFFF >> ((BACKLIGHT_LEVELS - get_backlight_level()) * ((BACKLIGHT_LEVELS + 1) / 2))) & (1 << backlight_tick)) {
FOR_EACH_LED(backlight_on(backlight_pin);)
} else {
FOR_EACH_LED(backlight_off(backlight_pin);)
}
backlight_tick = (backlight_tick + 1) % 16;
}
# endif
# ifdef BACKLIGHT_BREATHING
# ifndef BACKLIGHT_CUSTOM_DRIVER
# error "Backlight breathing only available with hardware PWM. Please disable."
# endif
# endif
# else // hardware pwm through timer
#ifdef BACKLIGHT_PWM_TIMER
// The idea of software PWM assisted by hardware timers is the following
@ -329,7 +292,6 @@ static uint16_t cie_lightness(uint16_t v) {
// range for val is [0..TIMER_TOP]. PWM pin is high while the timer count is below val.
static inline void set_pwm(uint16_t val) { OCRxx = val; }
# ifndef BACKLIGHT_CUSTOM_DRIVER
void backlight_set(uint8_t level) {
if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS;
@ -360,7 +322,6 @@ void backlight_set(uint8_t level) {
}
void backlight_task(void) {}
# endif // BACKLIGHT_CUSTOM_DRIVER
#ifdef BACKLIGHT_BREATHING
@ -518,7 +479,3 @@ void backlight_init_ports(void) {
}
#endif
}
# endif // hardware backlight
#endif // backlight