Compare commits

...

9 commits

Author SHA1 Message Date
b9d8f7de92 Newer Drone requires kind: kubernetes
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Signed-off-by: Martyn Ranyard <m@rtyn.berlin>
2021-01-03 11:55:29 +01:00
5655ddd56e Trigger CI
Some checks reported errors
continuous-integration/drone/push Build was killed
Signed-off-by: Martyn Ranyard <m@rtyn.berlin>
2021-01-03 11:53:31 +01:00
b898c0c669 Merge branch 'master' of ssh://git-ssh.martyn.berlin:2222/martyn/LEDController
Some checks reported errors
continuous-integration/drone/push Build was killed
Signed-off-by: Martyn Ranyard <m@rtyn.berlin>
2021-01-03 11:48:48 +01:00
568654d88e Trigger CI
Signed-off-by: Martyn Ranyard <m@rtyn.berlin>
2021-01-03 11:48:41 +01:00
2709d98125 moarpatterns (#1)
Make the comparison work

Allow color setting

types.... yeah... I know about them.

single-colour plasma, I hope

Reviewed-on: #1
Co-Authored-By: Martyn <m@rtyn.berlin>
Co-Committed-By: Martyn <m@rtyn.berlin>
2021-01-03 10:46:39 +00:00
10cef66e13 zero-length override
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Signed-off-by: Martyn Ranyard <m@rtyn.berlin>
2020-07-13 18:35:53 +02:00
ffec6c8260 Rest of the uint64 stuff
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Signed-off-by: Martyn Ranyard <m@rtyn.berlin>
2020-07-13 18:16:50 +02:00
4d72b04cc1 Uint64 because time...
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: Martyn Ranyard <m@rtyn.berlin>
2020-07-13 18:13:44 +02:00
7a5bb1108a Ensure we have a multiple of the delay in duration, and tick by the delay
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Signed-off-by: Martyn Ranyard <m@rtyn.berlin>
2020-07-13 17:46:11 +02:00
6 changed files with 106 additions and 20 deletions

View file

@ -1,3 +1,7 @@
# LEDController # LEDController
Testing out sending e1.31 sACM packets to strings of ws2812b Testing out sending e1.31 sACM packets to strings of ws2812b
Seems to be working nicely.
Used for my streaming setup on https://twitch.tv/iMartynOnTwitch

View file

@ -1,5 +1,5 @@
kind: pipeline kind: pipeline
type: docker type: kubernetes
name: linux-amd64-taggedver name: linux-amd64-taggedver
platform: platform:
@ -39,7 +39,7 @@ trigger:
--- ---
kind: pipeline kind: pipeline
type: docker type: kubernetes
name: linux-amd64-devel-master name: linux-amd64-devel-master
platform: platform:

View file

@ -32,6 +32,11 @@ var previousEffect queue.QueueItem
var msDelay = 0 var msDelay = 0
func isColorSet(c RGBcolor) bool {
// Any color so long as it's NOT black!
return c[0] != 0 || c[1] != 0 || c[2] != 0
}
func foreverLoop() { func foreverLoop() {
for /*ever*/ { for /*ever*/ {
time.Sleep(time.Duration(msDelay) * time.Millisecond) //25fps time.Sleep(time.Duration(msDelay) * time.Millisecond) //25fps
@ -149,7 +154,10 @@ func main() {
} }
if overrideEffect.Effect == "queue" { if overrideEffect.Effect == "queue" {
if currentEffect.Duration > 0 { if currentEffect.Duration > 0 {
currentEffect.Duration -= 40 if currentEffect.Duration%uint64(msDelay) != 0 {
currentEffect.Duration = uint64(currentEffect.Duration/uint64(msDelay)) * uint64(msDelay)
}
currentEffect.Duration -= uint64(msDelay)
} else { } else {
if len(globalEffectChannel) > 0 { if len(globalEffectChannel) > 0 {
previousEffect.Effect = "queue" previousEffect.Effect = "queue"
@ -166,7 +174,11 @@ func main() {
case "line": case "line":
rearranged = remapping.SliceRearrange(PanelWidth, PanelHeight, true, remapping.XYGridToLinear(PanelWidth, PanelHeight, patterns.ZigZag(PanelWidth, PanelHeight))) rearranged = remapping.SliceRearrange(PanelWidth, PanelHeight, true, remapping.XYGridToLinear(PanelWidth, PanelHeight, patterns.ZigZag(PanelWidth, PanelHeight)))
case "plasma": case "plasma":
rearranged = remapping.SliceRearrange(PanelWidth, PanelHeight, true, remapping.XYGridToLinear(PanelWidth, PanelHeight, patterns.PlasmaPanel(PanelWidth, PanelHeight, currentEffect.Speed))) if isColorSet(currentEffect.SeedColour) {
rearranged = remapping.SliceRearrange(PanelWidth, PanelHeight, true, remapping.XYGridToLinear(PanelWidth, PanelHeight, patterns.PlasmaPanelSingleColor(PanelWidth, PanelHeight, currentEffect.Speed, currentEffect.SeedColour)))
} else {
rearranged = remapping.SliceRearrange(PanelWidth, PanelHeight, true, remapping.XYGridToLinear(PanelWidth, PanelHeight, patterns.PlasmaPanel(PanelWidth, PanelHeight, currentEffect.Speed)))
}
case "red": case "red":
rearranged = remapping.SliceRearrange(PanelWidth, PanelHeight, false, remapping.XYGridToLinear(PanelWidth, PanelHeight, patterns.RedPanel(PanelWidth, PanelHeight))) rearranged = remapping.SliceRearrange(PanelWidth, PanelHeight, false, remapping.XYGridToLinear(PanelWidth, PanelHeight, patterns.RedPanel(PanelWidth, PanelHeight)))
case "random": case "random":

View file

@ -112,3 +112,46 @@ func PlasmaPanel(w int, h int, speed uint16) [][]RGBcolor {
} }
return grid return grid
} }
func singleColorPlasmaFromFloatVal(val float64, baseColor RGBcolor) (byte, byte, byte) {
var r byte
var g byte
var b byte
val = positiveModF(val)
r = byte(math.Trunc(float64(baseColor[0]) * val))
g = byte(math.Trunc(float64(baseColor[1]) * val))
b = byte(math.Trunc(float64(baseColor[2]) * val))
return r, g, b
}
func PlasmaPanelSingleColor(w int, h int, speed uint16, baseColor RGBcolor) [][]RGBcolor {
grid := make([][]RGBcolor, w)
for i := 0; i < w; i++ {
grid[i] = make([]RGBcolor, h)
}
palletteOffset -= 0.05 / 1.0
if palletteOffset < 0 {
palletteOffset += 1.0
}
offset := 0.5 // center offset
scaleW := math.Pi * 2.0 / float64(w)
scaleH := math.Pi * 2.0 / float64(h)
for y := 0; y < h; y++ {
for x := 0; x < w; x++ {
u := math.Cos((float64(x) + offset) * scaleW)
v := math.Cos((float64(y) + offset) * scaleH)
j := math.Cos(offset * scaleW) // 2D - No Z
e := (u + v + j + 3.0) / 6.0
r, g, b := singleColorPlasmaFromFloatVal(palletteOffset+e, baseColor)
var rgb [3]byte
rgb[0] = r
rgb[1] = g
rgb[2] = b
grid[x][y] = rgb
}
}
return grid
}

View file

@ -3,9 +3,9 @@ package queue
type RGBcolor = [3]byte type RGBcolor = [3]byte
type QueueItem struct { type QueueItem struct {
Effect string Effect string
Duration uint16 Duration uint64
Speed uint16 //only used by some patterns Speed uint16 //only used by some patterns
SeedColour RGBcolor // only used by some patterns SeedColour RGBcolor // only used by some patterns
SecondColour RGBcolor // only used by some patterns SecondColour RGBcolor // only used by some patterns
} }

View file

@ -39,10 +39,14 @@ func PatternHandler(response http.ResponseWriter, request *http.Request) {
e.Effect = strings.ToLower(vars["pattern"]) e.Effect = strings.ToLower(vars["pattern"])
_, found := vars["duration"] _, found := vars["duration"]
if found { if found {
i, _ := strconv.Atoi(vars["duration"]) i, _ := strconv.ParseUint(vars["duration"], 10, 64)
e.Duration = uint16(i) e.Duration = i
} else { } else {
e.Duration = 5000 if vars["override"] == "true" {
e.Duration = 0
} else {
e.Duration = 5000
}
} }
_, found = vars["speed"] _, found = vars["speed"]
if found { if found {
@ -51,6 +55,17 @@ func PatternHandler(response http.ResponseWriter, request *http.Request) {
} else { } else {
e.Speed = 40 e.Speed = 40
} }
if vars["color"] != "" {
var c queue.RGBcolor
for cn, cv := range colornames.Map {
if cn == strings.ToLower(vars["color"]) {
c[0] = cv.R
c[1] = cv.G
c[2] = cv.B
}
}
e.SeedColour = c
}
if vars["override"] == "true" { if vars["override"] == "true" {
overrideFlag <- e overrideFlag <- e
} else { } else {
@ -67,10 +82,14 @@ func ColourHandler(response http.ResponseWriter, request *http.Request) {
e.Effect = "colour" e.Effect = "colour"
_, found := vars["duration"] _, found := vars["duration"]
if found { if found {
i, _ := strconv.Atoi(vars["duration"]) i, _ := strconv.ParseUint(vars["duration"], 10, 64)
e.Duration = uint16(i) e.Duration = i
} else { } else {
e.Duration = 5000 if vars["override"] == "true" {
e.Duration = 0
} else {
e.Duration = 5000
}
} }
var c queue.RGBcolor var c queue.RGBcolor
for cn, cv := range colornames.Map { for cn, cv := range colornames.Map {
@ -97,10 +116,14 @@ func FadeHandler(response http.ResponseWriter, request *http.Request) {
e.Effect = "fade" e.Effect = "fade"
_, found := vars["duration"] _, found := vars["duration"]
if found { if found {
i, _ := strconv.Atoi(vars["duration"]) i, _ := strconv.ParseUint(vars["duration"], 10, 64)
e.Duration = uint16(i) e.Duration = i
} else { } else {
e.Duration = 5000 if vars["override"] == "true" {
e.Duration = 0
} else {
e.Duration = 5000
}
} }
var c queue.RGBcolor var c queue.RGBcolor
for cn, cv := range colornames.Map { for cn, cv := range colornames.Map {
@ -147,6 +170,10 @@ func HandleHTTP(queueChannel chan queue.QueueItem, Port int, overrideChannel cha
r.HandleFunc("/pattern/{pattern}/", PatternHandler) r.HandleFunc("/pattern/{pattern}/", PatternHandler)
r.HandleFunc("/pattern/{pattern}/{duration}", PatternHandler) r.HandleFunc("/pattern/{pattern}/{duration}", PatternHandler)
r.HandleFunc("/pattern/{pattern}/{duration}/{speed}", PatternHandler) r.HandleFunc("/pattern/{pattern}/{duration}/{speed}", PatternHandler)
r.HandleFunc("/colorpattern/{color}/{pattern}/override={override}", PatternHandler)
r.HandleFunc("/colorpattern/{color}/{pattern}/", PatternHandler)
r.HandleFunc("/colorpattern/{color}/{pattern}/{duration}", PatternHandler)
r.HandleFunc("/colorpattern/{color}/{pattern}/{duration}/{speed}", PatternHandler)
r.HandleFunc("/colour/{name}", ColourHandler) r.HandleFunc("/colour/{name}", ColourHandler)
r.HandleFunc("/colour/{name}/override={override}", ColourHandler) r.HandleFunc("/colour/{name}/override={override}", ColourHandler)
r.HandleFunc("/colour/{name}/{duration}", ColourHandler) r.HandleFunc("/colour/{name}/{duration}", ColourHandler)