change ledset to a receiver on led
This commit is contained in:
14
main.go
14
main.go
@ -17,6 +17,10 @@ type led struct {
|
|||||||
channel uint8
|
channel uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *led) set(brightness uint32) {
|
||||||
|
l.pwm.Set(l.channel, (l.pwm.Top()/brightnesspeak)*brightness)
|
||||||
|
}
|
||||||
|
|
||||||
type lighthardware struct {
|
type lighthardware struct {
|
||||||
red led
|
red led
|
||||||
green 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) {
|
func loop(lights lightSet, insidebrightness <-chan uint32, outsidebrightness <-chan uint32, partypushed <-chan bool) {
|
||||||
inBrightChange := make(chan uint32)
|
inBrightChange := make(chan uint32)
|
||||||
outBrightChange := 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) {
|
func setNormal(light *lighthardware, brightness uint32) {
|
||||||
ledset(light.red.pwm, light.red.channel, brightness)
|
light.red.set(brightness)
|
||||||
ledset(light.green.pwm, light.green.channel, brightness)
|
light.green.set(brightness)
|
||||||
ledset(light.blue.pwm, light.blue.channel, brightness)
|
light.blue.set(brightness)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user