From aab533caaf968bb735981a6e5ba6a058c54742a2 Mon Sep 17 00:00:00 2001 From: Drew Bowering Date: Mon, 1 Apr 2024 02:42:09 -0600 Subject: [PATCH] factor out "normal" mode changes --- main.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index 173bbf8..e9c5c02 100644 --- a/main.go +++ b/main.go @@ -207,16 +207,16 @@ func loop(inside *lighthardware, inside2 *lighthardware, outside *lighthardware, for { select { case <-inBrightChange: - ledset(inside.rPwm, inside.rCh, brightIn) - ledset(inside.gPwm, inside.gCh, brightIn) - ledset(inside.bPwm, inside.bCh, brightIn) - ledset(inside2.rPwm, inside2.rCh, brightIn) - ledset(inside2.gPwm, inside2.gCh, brightIn) - ledset(inside2.bPwm, inside2.bCh, brightIn) + normal(inside, brightIn) + normal(inside2, brightIn) case <-outBrightChange: - ledset(outside.rPwm, outside.rCh, brightOut) - ledset(outside.gPwm, outside.gCh, brightOut) - ledset(outside.bPwm, outside.bCh, brightOut) + normal(outside, brightOut) } } } + +func normal(light *lighthardware, brightness uint32) { + ledset(light.rPwm, light.rCh, brightness) + ledset(light.gPwm, light.gCh, brightness) + ledset(light.bPwm, light.bCh, brightness) +}