diff --git a/Makefile b/Makefile index f46ba1b..40f575d 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ smoketest: FORCE tinygo build -o ./out/gopher-badge.uf2 --target gopher-badge --size short ./targets/gopher-badge/ tinygo build -o ./out/macropad-rp2040.uf2 --target macropad-rp2040 --size short ./targets/macropad-rp2040/ tinygo build -o ./out/sg48key.uf2 --target xiao --size short ./targets/sg48key/ + tinygo build -o ./out/sg48key-rp2040.uf2 --target xiao-rp2040 --size short ./targets/sg48key/ tinygo build -o ./out/sgh60.uf2 --target waveshare-rp2040-zero --size short ./targets/sgh60/ tinygo build -o ./out/sgkb-left.uf2 --target xiao-rp2040 --size short ./targets/sgkb/left/ tinygo build -o ./out/sgkb-left-0.3.0.uf2 --target xiao-rp2040 --size short ./targets/sgkb/left-0.3.0/ diff --git a/targets/sg48key/adcdevice.go b/targets/sg48key/adcdevice.go index f40b3d2..073b9bf 100644 --- a/targets/sg48key/adcdevice.go +++ b/targets/sg48key/adcdevice.go @@ -48,7 +48,7 @@ func (a *ADCDevice) Get() int16 { var mapx = map[int]int16{ 0: 0, 1: 0, - 2: 10, + 2: 0, 3: 10, 4: 20, 5: 30, diff --git a/targets/sg48key/main.go b/targets/sg48key/main.go index 1c7036f..a238757 100644 --- a/targets/sg48key/main.go +++ b/targets/sg48key/main.go @@ -42,39 +42,30 @@ func run() error { machine.D4, // not connected } - led1 := machine.LED - led1.Configure(machine.PinConfig{Mode: machine.PinOutput}) - led2 := machine.LED2 - led2.Configure(machine.PinConfig{Mode: machine.PinOutput}) - led3 := machine.LED3 - led3.Configure(machine.PinConfig{Mode: machine.PinOutput}) - sm := d.AddSquaredMatrixKeyboard(colPins, [][]keyboard.Keycode{ { jp.KeyTab, jp.KeyQ, jp.KeyW, jp.KeyE, jp.KeyR, jp.KeyT, jp.KeyY, jp.KeyU, jp.KeyI, jp.KeyO, jp.KeyP, jp.KeyAt, jp.KeyLeftCtrl, jp.KeyA, jp.KeyS, jp.KeyD, jp.KeyF, jp.KeyG, jp.KeyH, jp.KeyJ, jp.KeyK, jp.KeyL, jp.KeySemicolon, jp.KeyColon, jp.KeyLeftShift, jp.KeyZ, jp.KeyX, jp.KeyC, jp.KeyV, jp.KeyB, jp.KeyN, jp.KeyM, jp.KeyComma, jp.KeyPeriod, jp.KeySlash, jp.KeyBackslash, - jp.KeyEsc, jp.KeyWindows, jp.KeyLeftAlt, jp.KeyMod1, jp.KeySpace, jp.KeyTo1, jp.KeySpace, jp.KeyMod2, jp.KeyHiragana, jp.KeyLeftAlt, jp.KeyPrintscreen, jp.KeyDelete, + jp.KeyEsc, jp.KeyWindows, jp.KeyLeftAlt, jp.KeyMod1, jp.KeySpace, jp.KeySpace, jp.KeySpace, jp.KeyMod2, jp.KeyHiragana, jp.KeyTo1, jp.KeyPrintscreen, jp.KeyDelete, }, { jp.KeyTab, jp.KeyQ, jp.KeyF15, jp.KeyEnd, jp.KeyF17, jp.KeyF18, jp.KeyY, jp.KeyU, jp.KeyTab, jp.KeyO, jp.WheelUp, jp.KeyAt, jp.KeyLeftCtrl, jp.KeyHome, jp.KeyS, jp.MouseRight, jp.MouseLeft, jp.MouseBack, jp.KeyLeft, jp.KeyDown, jp.KeyUp, jp.KeyRight, jp.KeyEnter, jp.KeyEsc, jp.KeyLeftShift, jp.KeyF13, jp.KeyF14, jp.MouseMiddle, jp.KeyF16, jp.MouseForward, jp.WheelDown, jp.KeyM, jp.KeyComma, jp.KeyPeriod, jp.KeySlash, jp.KeyBackslash, - jp.KeyEsc, jp.KeyWindows, jp.KeyLeftAlt, jp.KeyMod1, jp.KeySpace, jp.KeyTo2, jp.KeySpace, jp.KeyMod2, jp.KeyHiragana, jp.KeyLeftAlt, jp.KeyPrintscreen, jp.KeyDelete, + jp.KeyEsc, jp.KeyWindows, jp.KeyLeftAlt, jp.KeyMod1, jp.KeySpace, jp.KeySpace, jp.KeySpace, jp.KeyMod2, jp.KeyHiragana, jp.KeyTo2, jp.KeyPrintscreen, jp.KeyDelete, }, { jp.KeyTab, jp.Key1, jp.Key2, jp.Key3, jp.Key4, jp.Key5, jp.Key6, jp.Key7, jp.Key8, jp.Key9, jp.Key0, jp.KeyBackspace, jp.KeyLeftCtrl, jp.KeyMinus, jp.KeyHat, jp.KeyBackslash2, jp.KeyLeftBrace, jp.KeyRightBrace, jp.KeyHome, jp.KeyPageDown, jp.KeyPageUp, jp.KeyEnd, jp.KeyEnter, jp.KeyEsc, jp.KeyLeftShift, jp.KeyF1, jp.KeyF2, jp.KeyF3, jp.KeyF4, jp.KeyF5, jp.KeyF6, jp.KeyF7, jp.KeyF8, jp.KeyF9, jp.KeyF10, jp.KeyF11, - jp.KeyEsc, jp.KeyWindows, jp.KeyLeftAlt, jp.KeyMod1, jp.KeySpace, jp.KeyTo0, jp.KeySpace, jp.KeyMod2, jp.KeyHiragana, jp.KeyLeftAlt, jp.KeyPrintscreen, jp.KeyF12, + jp.KeyEsc, jp.KeyWindows, jp.KeyLeftAlt, jp.KeyMod1, jp.KeySpace, jp.KeySpace, jp.KeySpace, jp.KeyMod2, jp.KeyHiragana, jp.KeyTo0, jp.KeyPrintscreen, jp.KeyF12, }, }) sm.SetCallback(func(layer, index int, state keyboard.State) { layer = d.Layer() fmt.Printf("sm: %d %d %d\n", layer, index, state) - led1.Set(layer != 0) - led2.Set(layer == 0) - led3.Set(layer == 0) + callback(layer) }) // override ctrl-h to BackSpace diff --git a/targets/sg48key/xiao-rp2040.go b/targets/sg48key/xiao-rp2040.go new file mode 100644 index 0000000..63a097d --- /dev/null +++ b/targets/sg48key/xiao-rp2040.go @@ -0,0 +1,29 @@ +//go:build xiao_rp2040 + +package main + +import ( + "machine" +) + +var ( + led1 = machine.LED_RED + led2 = machine.LED_GREEN + led3 = machine.LED_BLUE +) + +func init() { + led1.Configure(machine.PinConfig{Mode: machine.PinOutput}) + led2.Configure(machine.PinConfig{Mode: machine.PinOutput}) + led3.Configure(machine.PinConfig{Mode: machine.PinOutput}) + + led1.Low() + led2.Low() + led3.High() +} + +func callback(layer int) { + led1.Set(layer != 0) + led2.Set(layer != 0) + led3.Set(layer == 0) +} diff --git a/targets/sg48key/xiao.go b/targets/sg48key/xiao.go new file mode 100644 index 0000000..954db2d --- /dev/null +++ b/targets/sg48key/xiao.go @@ -0,0 +1,25 @@ +//go:build xiao + +package main + +import ( + "machine" +) + +var ( + led1 = machine.LED + led2 = machine.LED2 + led3 = machine.LED3 +) + +func init() { + led1.Configure(machine.PinConfig{Mode: machine.PinOutput}) + led2.Configure(machine.PinConfig{Mode: machine.PinOutput}) + led3.Configure(machine.PinConfig{Mode: machine.PinOutput}) +} + +func callback(layer int) { + led1.Set(layer != 0) + led2.Set(layer == 0) + led3.Set(layer == 0) +}