change ledset to a receiver on led

This commit is contained in:
Drew Bowering 2024-04-01 06:25:20 -06:00
parent 856a6e2d88
commit bbd231b2eb
Signed by: drew
GPG Key ID: DC9462335BDDAC6B

14
main.go
View File

@ -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)
}