Add support for inverted LEDS. See common anode RGB LED discussion in the Yahoo group

This commit is contained in:
Jeff 2017-07-27 07:43:59 -06:00 committed by Gregory Nutt
parent 598386ef90
commit 552ed255f6
2 changed files with 18 additions and 3 deletions

View File

@ -48,6 +48,15 @@ config RGBLED
This selection enables building of the "upper-half" RGB LED driver. This selection enables building of the "upper-half" RGB LED driver.
See include/nuttx/rgbled.h for further PWM driver information. See include/nuttx/rgbled.h for further PWM driver information.
config RGBLED_INVERT
bool "Invert RGB LED Output"
depends on RGBLED
default n
---help---
If the board has a common anode RGB LED (a LOW output turns ON
each LED), this selection inverts the outputs so that the
colors are displayed correctly.
config PCA9635PW config PCA9635PW
bool "PCA9635PW I2C LED Driver" bool "PCA9635PW I2C LED Driver"
default n default n

View File

@ -304,9 +304,15 @@ static ssize_t rgbled_write(FAR struct file *filep, FAR const char *buffer,
/* Convert 8bit to 16bits */ /* Convert 8bit to 16bits */
red <<= 8; red = (red << 8) | red;
green <<= 8; green = (green << 8) | green;
blue <<= 8; blue = (blue << 8) | blue;
#ifdef CONFIG_RGBLED_INVERT
red ^= 0xffff;
green ^= 0xffff;
blue ^= 0xffff;
#endif
/* Setup LED R */ /* Setup LED R */