mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 16:38:16 +01:00
Inverted output in neopixelbus (#895)
* Added inverted output * Added support for inverted output in neopixelbus * Update esphome/components/neopixelbus/light.py Co-Authored-By: Otto Winter <otto@otto-winter.com> * Update light.py * corrected lint errors Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
parent
8a754421fe
commit
e21dbc4b60
1 changed files with 9 additions and 1 deletions
|
@ -3,7 +3,7 @@ import esphome.config_validation as cv
|
||||||
from esphome import pins
|
from esphome import pins
|
||||||
from esphome.components import light
|
from esphome.components import light
|
||||||
from esphome.const import CONF_CLOCK_PIN, CONF_DATA_PIN, CONF_METHOD, CONF_NUM_LEDS, CONF_PIN, \
|
from esphome.const import CONF_CLOCK_PIN, CONF_DATA_PIN, CONF_METHOD, CONF_NUM_LEDS, CONF_PIN, \
|
||||||
CONF_TYPE, CONF_VARIANT, CONF_OUTPUT_ID
|
CONF_TYPE, CONF_VARIANT, CONF_OUTPUT_ID, CONF_INVERT
|
||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
|
|
||||||
neopixelbus_ns = cg.esphome_ns.namespace('neopixelbus')
|
neopixelbus_ns = cg.esphome_ns.namespace('neopixelbus')
|
||||||
|
@ -120,6 +120,13 @@ ESP32_METHODS = {
|
||||||
def format_method(config):
|
def format_method(config):
|
||||||
variant = VARIANTS[config[CONF_VARIANT]]
|
variant = VARIANTS[config[CONF_VARIANT]]
|
||||||
method = config[CONF_METHOD]
|
method = config[CONF_METHOD]
|
||||||
|
|
||||||
|
if config[CONF_INVERT]:
|
||||||
|
if method == 'ESP8266_DMA':
|
||||||
|
variant = 'Inverted' + variant
|
||||||
|
else:
|
||||||
|
variant += 'Inverted'
|
||||||
|
|
||||||
if CORE.is_esp8266:
|
if CORE.is_esp8266:
|
||||||
return ESP8266_METHODS[method].format(variant)
|
return ESP8266_METHODS[method].format(variant)
|
||||||
if CORE.is_esp32:
|
if CORE.is_esp32:
|
||||||
|
@ -145,6 +152,7 @@ CONFIG_SCHEMA = cv.All(light.ADDRESSABLE_LIGHT_SCHEMA.extend({
|
||||||
cv.Optional(CONF_TYPE, default='GRB'): validate_type,
|
cv.Optional(CONF_TYPE, default='GRB'): validate_type,
|
||||||
cv.Optional(CONF_VARIANT, default='800KBPS'): validate_variant,
|
cv.Optional(CONF_VARIANT, default='800KBPS'): validate_variant,
|
||||||
cv.Optional(CONF_METHOD, default=None): validate_method,
|
cv.Optional(CONF_METHOD, default=None): validate_method,
|
||||||
|
cv.Optional(CONF_INVERT, default='no'): cv.boolean,
|
||||||
cv.Optional(CONF_PIN): pins.output_pin,
|
cv.Optional(CONF_PIN): pins.output_pin,
|
||||||
cv.Optional(CONF_CLOCK_PIN): pins.output_pin,
|
cv.Optional(CONF_CLOCK_PIN): pins.output_pin,
|
||||||
cv.Optional(CONF_DATA_PIN): pins.output_pin,
|
cv.Optional(CONF_DATA_PIN): pins.output_pin,
|
||||||
|
|
Loading…
Reference in a new issue