Skip to content

Implementation of vialrgb #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7063b9b
implemented kbexpander
PercyJW-2 Jun 17, 2024
ff6ae1c
stuff
PercyJW-2 Jul 10, 2024
efb31c4
Merge branch 'sago35:main' into main
PercyJW-2 Jul 11, 2024
1f4c656
updated stuff
PercyJW-2 Jul 11, 2024
28d016d
more stuff
PercyJW-2 Jul 11, 2024
665cbb1
Merge branch 'main' of github.com:PercyJW-2/tinygo-keyboard
PercyJW-2 Jul 11, 2024
c84952c
Merge branch 'sago35:main' into main
PercyJW-2 Jul 25, 2024
34cba97
updated module
PercyJW-2 Jul 25, 2024
e195de3
Fixed kbexpander and reduced debounce time
PercyJW-2 Jul 28, 2024
059d332
Removed own keyboard
PercyJW-2 Jul 28, 2024
40757fc
Removed debug log prints
PercyJW-2 Jul 28, 2024
e222842
Added explicitly ignoring possible errors
PercyJW-2 Jul 28, 2024
2020ea4
Started to implement vialrgb
PercyJW-2 Jul 29, 2024
60417d3
Continued implementation, need to finish writing part
PercyJW-2 Jul 30, 2024
a8bdcd2
Finished untested vialrgb communication
PercyJW-2 Aug 1, 2024
e3941c8
Finished untested vialrgb implementation with a few animations
PercyJW-2 Aug 2, 2024
49a8c32
Made struct elements public
PercyJW-2 Aug 2, 2024
1bf0544
Fixed RGB communication
PercyJW-2 Aug 7, 2024
30bfea4
Finished RGB implementation
PercyJW-2 Aug 13, 2024
6704554
Fixed saving and loading rgb settings
PercyJW-2 Aug 15, 2024
40d471d
Implemented new rgb animation
PercyJW-2 Aug 15, 2024
567a997
Merge branch 'sago35:main' into main
PercyJW-2 Aug 15, 2024
9f797ef
Implemented gradient rgb effect
PercyJW-2 Aug 15, 2024
02dff8c
implemented Breathing effect, TODO: rework animation speed
PercyJW-2 Aug 16, 2024
d920ff4
adding comment to rgb.go to pass ci
PercyJW-2 Aug 18, 2024
094577e
reworkted animation speed for breathing animation
PercyJW-2 Oct 7, 2024
0a7da42
Merge branch 'sago35:main' into main
PercyJW-2 Oct 7, 2024
8f1eb30
Merge remote-tracking branch 'origin/main'
PercyJW-2 Oct 7, 2024
5c16bf8
implemented 4/6 Band Animations
PercyJW-2 Oct 7, 2024
f874931
implemented 6/6 Band Animations
PercyJW-2 Oct 7, 2024
ef7aafb
implemented All Cycle Animations
PercyJW-2 Oct 7, 2024
39bb188
implemented All Beacon Animations
PercyJW-2 Oct 7, 2024
381c069
implemented All Animations that are no rain or reactive effects
PercyJW-2 Oct 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
**/production/*.csv
**/production/*.ipc
**/production/
*.elf
*.uf2
.idea
.vscode
15 changes: 9 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
module github.com/sago35/tinygo-keyboard
module github.com/percyjw-2/tinygo-keyboard

go 1.19
go 1.22.0

toolchain go1.23.1

require (
github.com/itchio/lzma v0.0.0-20190703113020-d3e24e3e3d49
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b
tinygo.org/x/drivers v0.27.0
tinygo.org/x/tinydraw v0.3.0
tinygo.org/x/tinyfont v0.3.0
github.com/sago35/tinygo-keyboard v0.0.0-20240801000429-80e67ab2d444
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
tinygo.org/x/drivers v0.28.0
tinygo.org/x/tinydraw v0.4.0
tinygo.org/x/tinyfont v0.4.0
)

require github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
16 changes: 16 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
github.com/bgould/http v0.0.0-20190627042742-d268792bdee7/go.mod h1:BTqvVegvwifopl4KTEDth6Zezs9eR+lCWhvGKvkxJHE=
github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
github.com/frankban/quicktest v1.10.2 h1:19ARM85nVi4xH7xPXuc5eM/udya5ieh7b/Sv+d844Tk=
github.com/frankban/quicktest v1.10.2/go.mod h1:K+q6oSqb0W0Ininfk863uOk1lMy69l/P6txr3mVT54s=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/itchio/lzma v0.0.0-20190703113020-d3e24e3e3d49 h1:+YrBMf3rkLjkT10zIHyVE4S7ma4hqvfjl6XgnzZwS6o=
github.com/itchio/lzma v0.0.0-20190703113020-d3e24e3e3d49/go.mod h1:avNrevQMli1pYPsz1+HIHMvx95pk6O+6otbWqCZPeZI=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/sago35/tinygo-keyboard v0.0.0-20240718132338-1f0852885672 h1:mczTPYfh9yjoa6GO967sNW+6LhFjHn2TrTSwW9Wr108=
github.com/sago35/tinygo-keyboard v0.0.0-20240718132338-1f0852885672/go.mod h1:jFhDDtRipnSbvhoqlGrR2M7IInnjcMUzuSWznF6obqM=
github.com/sago35/tinygo-keyboard v0.0.0-20240801000429-80e67ab2d444 h1:upA/EBMxms0PV6Lr8Rz27nBSlAvFJkMU9q8AUceya2g=
github.com/sago35/tinygo-keyboard v0.0.0-20240801000429-80e67ab2d444/go.mod h1:jFhDDtRipnSbvhoqlGrR2M7IInnjcMUzuSWznF6obqM=
github.com/valyala/fastjson v1.6.3/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b h1:kLiC65FbiHWFAOu+lxwNPujcsl8VYyTYYEZnsOO1WK4=
golang.org/x/exp v0.0.0-20231226003508-02704c960a9b/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -25,10 +35,16 @@ tinygo.org/x/drivers v0.16.0/go.mod h1:uT2svMq3EpBZpKkGO+NQHjxjGf1f42ra4OnMMwQL2
tinygo.org/x/drivers v0.19.0/go.mod h1:uJD/l1qWzxzLx+vcxaW0eY464N5RAgFi1zTVzASFdqI=
tinygo.org/x/drivers v0.27.0 h1:TEGk1lQvEhXxfvpEhUu+pwmCnhtldPI+hpHlO9VYixI=
tinygo.org/x/drivers v0.27.0/go.mod h1:q/mU8G/wz821p8xXqbkBACOlmZFDHXd//DnYnCW+dDQ=
tinygo.org/x/drivers v0.28.0 h1:ROVrGGXddmpn2+oV/Bu3LceYbtPCJckmgIqvPcN/L0k=
tinygo.org/x/drivers v0.28.0/go.mod h1:T6snsUqS0RAxOANxiV81fQwLxDDNmprxTAYzmxoA7J0=
tinygo.org/x/tinydraw v0.3.0 h1:OjsdMcES5+7IIs/4diFpq/pWFsa0VKtbi1mURuj2q64=
tinygo.org/x/tinydraw v0.3.0/go.mod h1:Yz0vLSP2rHsIKpLYkEmLnE+2zyhhITu2LxiVtLRiW6I=
tinygo.org/x/tinydraw v0.4.0 h1:U9V0mHz8/jPShKjlh199vCfq1ARFyUOD1b+FfqIwV8c=
tinygo.org/x/tinydraw v0.4.0/go.mod h1:WCV/EMljTv8w04iAxjv+fRD6/4ffx0afATYeJlN90Yo=
tinygo.org/x/tinyfont v0.2.1/go.mod h1:eLqnYSrFRjt5STxWaMeOWJTzrKhXqpWw7nU3bPfKOAM=
tinygo.org/x/tinyfont v0.3.0 h1:HIRLQoI3oc+2CMhPcfv+Ig88EcTImE/5npjqOnMD4lM=
tinygo.org/x/tinyfont v0.3.0/go.mod h1:+TV5q0KpwSGRWnN+ITijsIhrWYJkoUCp9MYELjKpAXk=
tinygo.org/x/tinyfont v0.4.0 h1:XexPKEKiHInf6p4CMCJwsIheVPY0T46HUs6ictYyZfE=
tinygo.org/x/tinyfont v0.4.0/go.mod h1:7nVj3j3geqBoPDzpFukAhF1C8AP9YocMsZy0HSAcGCA=
tinygo.org/x/tinyfs v0.1.0/go.mod h1:ysc8Y92iHfhTXeyEM9+c7zviUQ4fN9UCFgSOFfMWv20=
tinygo.org/x/tinyterm v0.1.0/go.mod h1:/DDhNnGwNF2/tNgHywvyZuCGnbH3ov49Z/6e8LPLRR4=
2 changes: 1 addition & 1 deletion kbmatrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (d *Device) AddMatrixKeyboard(colPins, rowPins []machine.Pin, keys [][]Keyc
options: o,
callback: func(layer, index int, state State) {},
cycleCounter: cycleCnt,
debounce: 8,
debounce: 2,
}

d.kb = append(d.kb, k)
Expand Down
24 changes: 19 additions & 5 deletions keyboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type Device struct {
flashCh chan bool
flashCnt int

rgbMat *RGBMatrix

kb []KBer

layer int
Expand Down Expand Up @@ -84,7 +86,7 @@ func (d *Device) OverrideCtrlH() {
}
}

func (d *Device) Init() error {
func (d *Device) Init(ctx context.Context) error {
for _, k := range d.kb {
err := k.Init()
if err != nil {
Expand All @@ -100,7 +102,8 @@ func (d *Device) Init() error {
keys := d.GetMaxKeyCount()

// TODO: refactor
rbuf := make([]byte, 4+layers*keyboards*keys*2+len(device.Macros))
rgbStorageSize := 2 + 1 + 3 // currentEffect + speed + HSV
rbuf := make([]byte, 4+layers*keyboards*keys*2+len(device.Macros)+rgbStorageSize)
_, err := machine.Flash.ReadAt(rbuf, 0)
if err != nil {
return err
Expand All @@ -123,6 +126,12 @@ func (d *Device) Init() error {
}
}

modeID := uint16(rbuf[offset]) | (uint16(rbuf[offset+1]) >> 8)
device.SetCurrentRGBMode(modeID)
device.SetCurrentSpeed(rbuf[offset+2])
device.SetCurrentHSV(rbuf[offset+3], rbuf[offset+4], rbuf[offset+5])
offset += 6

for i, b := range rbuf[offset:] {
if b == 0xFF {
b = 0
Expand All @@ -131,6 +140,11 @@ func (d *Device) Init() error {
}
//copy(device.Macros[:], rbuf[offset:])

// Start RGB task
go func() {
_ = d.updateRGBTask(ctx)
}()

return nil
}

Expand Down Expand Up @@ -347,7 +361,7 @@ func decKey(k uint32) (int, int, int) {
}

func (d *Device) Loop(ctx context.Context) error {
err := d.Init()
err := d.Init(ctx)
if err != nil {
return err
}
Expand Down Expand Up @@ -379,7 +393,7 @@ func (d *Device) Key(layer, kbIndex, index int) Keycode {
}

func (d *Device) KeyVia(layer, kbIndex, index int) Keycode {
//fmt.Printf(" KeyVia(%d, %d, %d)\n", layer, kbIndex, index)
//fmt.Printf(" KeyVia(%d, %d, %d)\n", layer, KbIndex, index)
if kbIndex >= len(d.kb) {
return 0
}
Expand Down Expand Up @@ -437,7 +451,7 @@ func (d *Device) SetKeycodeVia(layer, kbIndex, index int, key Keycode) {
if kbIndex >= len(d.kb) {
return
}
//fmt.Printf("SetKeycodeVia(%d, %d, %d, %04X)\n", layer, kbIndex, index, key)
//fmt.Printf("SetKeycodeVia(%d, %d, %d, %04X)\n", layer, KbIndex, index, key)
kc := keycodeViaToTGK(key)

d.kb[kbIndex].SetKeycode(layer, index, kc)
Expand Down
Loading