Skip to content

Commit 07e26b4

Browse files
authored
Rework components, fully modularize music leds pipeline. Completely removed dependency on fastled library. (#112)
* MusicLeds: Rework component, fully modularize music leds pipeline * Add PITCH_HPF and rework * Effects rework * Completely removed dependency on fastled library
1 parent 9d1e1bc commit 07e26b4

36 files changed

Lines changed: 6799 additions & 2754 deletions

.ruff.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ select = [
1111
ignore = [
1212
"ANN001", # Missing type annotation for function argument
1313
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
14+
"CPY001", # Missing copyright notice at top of file
1415
"D203", # no-blank-line-before-class (incompatible with formatter)
1516
"D212", # multi-line-summary-first-line (incompatible with formatter)
1617
"FIX002", # Line contains TODO, consider resolving an issue

components/fastled_helper/__init__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
import esphome.codegen as cg
66
import esphome.config_validation as cv
7-
from esphome.const import CONF_ID
7+
from esphome.const import CONF_ID, CONF_LIGHT
8+
from esphome.core import CORE
89

910
CONF_PALETTES = "palettes"
1011
CONF_MUSIC_LEDS = "music_leds"
@@ -36,11 +37,17 @@ async def to_code(config) -> None:
3637
"""Code generation entry point."""
3738
var = cg.new_Pvariable(config[CONF_ID])
3839

39-
cg.add_library("fastled/FastLED", "3.10.3")
40-
4140
if config[CONF_PALETTES]:
42-
cg.add_define("PALETTES")
41+
cg.add_define("USE_PALETTES")
4342
if config[CONF_MUSIC_LEDS]:
44-
cg.add_define("MUSIC_LEDS")
43+
cg.add_define("USE_MUSIC_LEDS")
44+
45+
gamma_value = 2.8
46+
if CONF_LIGHT in CORE.config:
47+
first_light = CORE.config[CONF_LIGHT][0]
48+
gamma_value = first_light.get("gamma_correct", 2.8)
49+
logging.info("Gamma value: %s", gamma_value)
50+
51+
cg.add_define("GAMMA_CORRECT", cg.RawExpression(f"{float(gamma_value):.2f}f"))
4552

4653
await cg.register_component(var, config)

0 commit comments

Comments
 (0)