Skip to content

Commit

Permalink
implemented All Cycle Animations
Browse files Browse the repository at this point in the history
  • Loading branch information
PercyJW-2 committed Oct 7, 2024
1 parent f874931 commit ef7aafb
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 0 deletions.
18 changes: 18 additions & 0 deletions rgbanimations/vialrgbCycleAll.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package rgbanimations

import keyboard "github.com/percyjw-2/tinygo-keyboard"

func GetCycleAllAnim() keyboard.RgbAnimation {
return keyboard.RgbAnimation{
AnimationFunc: vialRGBCycleAll,
AnimationType: keyboard.VIALRGB_EFFECT_CYCLE_ALL,
}
}

func cycleAllMath(matrix *keyboard.RGBMatrix, i int, time uint16) (uint8, uint8, uint8) {
return uint8(time), matrix.CurrentSaturation, matrix.CurrentValue
}

func vialRGBCycleAll(matrix *keyboard.RGBMatrix) {
effectRunnerI(matrix, cycleAllMath)
}
19 changes: 19 additions & 0 deletions rgbanimations/vialrgbCycleLeftRight.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package rgbanimations

import keyboard "github.com/percyjw-2/tinygo-keyboard"

func GetCycleLeftRightAnim() keyboard.RgbAnimation {
return keyboard.RgbAnimation{
AnimationFunc: vialRGBCycleLeftRight,
AnimationType: keyboard.VIALRGB_EFFECT_CYCLE_LEFT_RIGHT,
}
}

func cycleLeftRightMath(matrix *keyboard.RGBMatrix, i int, time uint16) (uint8, uint8, uint8) {
h := matrix.LedMatrixMapping[i].PhysicalX - uint8(time)
return h, matrix.CurrentSaturation, matrix.CurrentValue
}

func vialRGBCycleLeftRight(matrix *keyboard.RGBMatrix) {
effectRunnerI(matrix, cycleLeftRightMath)
}
19 changes: 19 additions & 0 deletions rgbanimations/vialrgbCycleOutIn.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package rgbanimations

import keyboard "github.com/percyjw-2/tinygo-keyboard"

func GetCycleOutInAnim() keyboard.RgbAnimation {
return keyboard.RgbAnimation{
AnimationFunc: vialRGBCycleOutIn,
AnimationType: keyboard.VIALRGB_EFFECT_CYCLE_OUT_IN,
}
}

func cycleOutInMath(matrix *keyboard.RGBMatrix, _ int16, _ int16, dist uint8, time uint16) (uint8, uint8, uint8) {
h := 3*dist/2 + uint8(time)
return h, matrix.CurrentSaturation, matrix.CurrentValue
}

func vialRGBCycleOutIn(matrix *keyboard.RGBMatrix) {
effectRunnerDXDYDist(matrix, cycleOutInMath)
}
21 changes: 21 additions & 0 deletions rgbanimations/vialrgbCycleOutInDual.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package rgbanimations

import keyboard "github.com/percyjw-2/tinygo-keyboard"

func GetCycleOutInDualAnim() keyboard.RgbAnimation {
return keyboard.RgbAnimation{
AnimationFunc: vialRGBCycleOutInDual,
AnimationType: keyboard.VIALRGB_EFFECT_CYCLE_OUT_IN_DUAL,
}
}

func cycleOutInDualMath(matrix *keyboard.RGBMatrix, dx int16, dy int16, time uint16) (uint8, uint8, uint8) {
dx = int16(matrix.CenterXPhysical/2) - Abs16(dx)
dist := Sqrt16(uint16(dx*dx) + uint16(dy*dy))
h := 3*dist + uint8(time)
return h, matrix.CurrentSaturation, matrix.CurrentValue
}

func vialRGBCycleOutInDual(matrix *keyboard.RGBMatrix) {
effectRunnerDXDY(matrix, cycleOutInDualMath)
}
19 changes: 19 additions & 0 deletions rgbanimations/vialrgbCyclePinwheel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package rgbanimations

import keyboard "github.com/percyjw-2/tinygo-keyboard"

func GetCyclePinwheelAnim() keyboard.RgbAnimation {
return keyboard.RgbAnimation{
AnimationFunc: vialRGBCyclePinwheel,
AnimationType: keyboard.VIALRGB_EFFECT_CYCLE_PINWHEEL,
}
}

func cyclePinwheelMath(matrix *keyboard.RGBMatrix, dx int16, dy int16, time uint16) (uint8, uint8, uint8) {
h := Atan28(dy, dx) + uint8(time)
return h, matrix.CurrentSaturation, matrix.CurrentValue
}

func vialRGBCyclePinwheel(matrix *keyboard.RGBMatrix) {
effectRunnerDXDY(matrix, cyclePinwheelMath)
}
19 changes: 19 additions & 0 deletions rgbanimations/vialrgbCycleSpiral.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package rgbanimations

import keyboard "github.com/percyjw-2/tinygo-keyboard"

func GetCycleSpiralAnim() keyboard.RgbAnimation {
return keyboard.RgbAnimation{
AnimationFunc: vialRGBCycleSpiral,
AnimationType: keyboard.VIALRGB_EFFECT_CYCLE_SPIRAL,
}
}

func cycleSpiralMath(matrix *keyboard.RGBMatrix, dx int16, dy int16, dist uint8, time uint16) (uint8, uint8, uint8) {
h := dist - uint8(time) - Atan28(dy, dx)
return h, matrix.CurrentSaturation, matrix.CurrentValue
}

func vialRGBCycleSpiral(matrix *keyboard.RGBMatrix) {
effectRunnerDXDYDist(matrix, cycleSpiralMath)
}
19 changes: 19 additions & 0 deletions rgbanimations/vialrgbCycleUpDown.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package rgbanimations

import keyboard "github.com/percyjw-2/tinygo-keyboard"

func GetCycleUpDownAnim() keyboard.RgbAnimation {
return keyboard.RgbAnimation{
AnimationFunc: vialRGBCycleUpDown,
AnimationType: keyboard.VIALRGB_EFFECT_CYCLE_UP_DOWN,
}
}

func cycleUpDownMath(matrix *keyboard.RGBMatrix, i int, time uint16) (uint8, uint8, uint8) {
h := matrix.LedMatrixMapping[i].PhysicalY - uint8(time)
return h, matrix.CurrentSaturation, matrix.CurrentValue
}

func vialRGBCycleUpDown(matrix *keyboard.RGBMatrix) {
effectRunnerI(matrix, cycleUpDownMath)
}
19 changes: 19 additions & 0 deletions rgbanimations/vialrgbRainbowMovingChevron.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package rgbanimations

import keyboard "github.com/percyjw-2/tinygo-keyboard"

func GetRainbowMovingChevronAnim() keyboard.RgbAnimation {
return keyboard.RgbAnimation{
AnimationFunc: vialRGBRainbowMovingChevron,
AnimationType: keyboard.VIALRGB_EFFECT_RAINBOW_MOVING_CHEVRON,
}
}

func rainbowMovingChevronMath(matrix *keyboard.RGBMatrix, i int, time uint16) (uint8, uint8, uint8) {
h := matrix.CurrentHue + Abs8(int8(matrix.LedMatrixMapping[i].PhysicalY-matrix.CenterYPhysical)+int8(matrix.CenterXPhysical-uint8(time)))
return h, matrix.CurrentSaturation, matrix.CurrentValue
}

func vialRGBRainbowMovingChevron(matrix *keyboard.RGBMatrix) {
effectRunnerI(matrix, rainbowMovingChevronMath)
}

0 comments on commit ef7aafb

Please sign in to comment.