Skip to content

Commit

Permalink
Set default button press color
Browse files Browse the repository at this point in the history
  • Loading branch information
sudermanjr committed Feb 22, 2023
1 parent aae9087 commit c027c25
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
19 changes: 10 additions & 9 deletions pkg/color/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ import (

// ColorMap is a map of named colors to hex values
var ColorMap = map[string]string{
"blue": "#0000ff",
"green": "#00ff00",
"yellow": "#ffaf33",
"purple": "#af33ff",
"red": "#ff0000",
"teal": "#33ffd1",
"pink": "#ff08c7",
"white": "#ffffff",
"black": "#000000", // This basically equates to off.
"warmwhite": "#ffe9c2",
"blue": "#0000ff",
"green": "#00ff00",
"yellow": "#ffaf33",
"purple": "#af33ff",
"red": "#ff0000",
"teal": "#33ffd1",
"pink": "#ff08c7",
"white": "#ffffff",
"black": "#000000", // This basically equates to off.
}

// GradientTable contains the "keypoints" of the colorgradient you want to generate.
Expand Down
11 changes: 5 additions & 6 deletions pkg/neopixel/neopixel.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ func NewLEDArray(minBrightness int, maxBrightness, ledCount int, fadeDuration in
return nil, err
}

whiteColor := color.HexToColor(color.ColorMap["white"])

led := &LEDArray{
WS: dev,
Brightness: minBrightness,
MinBrightness: minBrightness,
MaxBrightness: maxBrightness,
FadeDuration: fadeDuration,
Color: whiteColor,
Color: color.HexToColor(color.ColorMap["warmwhite"]),
Logger: logger,
}

Expand All @@ -78,7 +76,7 @@ func NewLEDArray(minBrightness int, maxBrightness, ledCount int, fadeDuration in
}

// Display changes all of the LEDs one at a time
// delay: sets the time between each LED coming on
// delay: sets the time between each LED changing in milliseconds
// brightness: sets the brightness for the entire thing
func (led *LEDArray) Display(delay int) error {
led.Logger.Debugw("setting led array to color",
Expand Down Expand Up @@ -225,12 +223,13 @@ func (led *LEDArray) FadeToggleOnOff() {

func (led *LEDArray) ToggleOnOff() {
var err error
led.Color = color.HexToColor(color.ColorMap["warmwhite"])
if led.Brightness == led.MinBrightness {
led.Brightness = led.MaxBrightness
err = led.SetBrightness()
err = led.Display(1)
} else {
led.Brightness = led.MinBrightness
err = led.SetBrightness()
err = led.Display(1)
}
if err != nil {
led.Logger.Errorw("could not change brightness from button press", "error", err)
Expand Down

0 comments on commit c027c25

Please sign in to comment.