From bbd231b2eb8a829f79a0af149a5675ae891202de Mon Sep 17 00:00:00 2001 From: Drew Bowering Date: Mon, 1 Apr 2024 06:25:20 -0600 Subject: [PATCH] change ledset to a receiver on led --- main.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 2aae9c7..718915f 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,10 @@ type led struct { channel uint8 } +func (l *led) set(brightness uint32) { + l.pwm.Set(l.channel, (l.pwm.Top()/brightnesspeak)*brightness) +} + type lighthardware struct { red led green led @@ -210,10 +214,6 @@ func cycleBrightness(pushchan <-chan bool, brightnesschan chan<- uint32) { } } -func ledset(lpwm pwm, ledch uint8, brightness uint32) { - lpwm.Set(ledch, (lpwm.Top()/brightnesspeak)*brightness) -} - func loop(lights lightSet, insidebrightness <-chan uint32, outsidebrightness <-chan uint32, partypushed <-chan bool) { inBrightChange := make(chan uint32) outBrightChange := make(chan uint32) @@ -276,7 +276,7 @@ func normal(lights lightSet, inBrightChange <-chan uint32, outBrightChange <-cha } func setNormal(light *lighthardware, brightness uint32) { - ledset(light.red.pwm, light.red.channel, brightness) - ledset(light.green.pwm, light.green.channel, brightness) - ledset(light.blue.pwm, light.blue.channel, brightness) + light.red.set(brightness) + light.green.set(brightness) + light.blue.set(brightness) }