Skip to content

Commit

Permalink
fix gradient steps
Browse files Browse the repository at this point in the history
  • Loading branch information
sudermanjr committed Feb 22, 2023
1 parent 1e6690f commit e6d334b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 7 additions & 1 deletion pkg/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,15 @@ func (a *App) demoHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
steps, err := strconv.ParseInt(r.Form["gradient-steps"][0], 10, 32)
if err != nil {
a.Logger.Errorw("error processing gradient stpes", "error", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

a.Array.Brightness = utils.ScaleBrightness(int(brightness), a.Array.MinBrightness, a.Array.MaxBrightness)
a.Array.Demo(1, int(delay), 1000)
a.Array.Demo(1, int(delay), int(steps))

http.Redirect(w, r, "/", 302)
}
7 changes: 4 additions & 3 deletions pkg/dashboard/templates/dashboard.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
id="demo-delay"
type="number"
name="delay"
value="100"
value="10"
min="0"
max="10000"
/>
Expand All @@ -49,6 +49,7 @@
type="range"
min="0"
max="100"
value="100"
name="brightness"
/>

Expand All @@ -57,9 +58,9 @@
id="demo-gradient-steps"
type="number"
name="gradient-steps"
value="2048"
value="100"
min="10"
max="10000"
max="2048"
/>

<input type="submit" value="run" id="demo-submit" />
Expand Down
3 changes: 1 addition & 2 deletions pkg/neopixel/neopixel.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ func (led *LEDArray) Demo(count int, delay int, gradientLength int) {
colorList := color.GradientColorList(demoGradient, gradientLength)
for _, gradColor := range colorList {
led.Color = gradColor
_ = led.Display(0)
time.Sleep(time.Duration(delay) * time.Nanosecond)
_ = led.Display(delay / 10)
}
}
_ = led.Fade(led.MinBrightness)
Expand Down

0 comments on commit e6d334b

Please sign in to comment.