From 2c002914db373c72fa68ac0707d507ba7598ce50 Mon Sep 17 00:00:00 2001 From: sago35 Date: Tue, 30 Jan 2024 21:56:39 +0900 Subject: [PATCH] Update ./targets --- targets/macropad-rp2040/main.go | 2 +- targets/sg48key/main.go | 16 ++++++++++------ targets/sgh60/main.go | 17 ++++++++++------- targets/xiao-kb01/main.go | 12 ++++++++---- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/targets/macropad-rp2040/main.go b/targets/macropad-rp2040/main.go index 0a72f53..cd4b41e 100644 --- a/targets/macropad-rp2040/main.go +++ b/targets/macropad-rp2040/main.go @@ -126,7 +126,7 @@ func run() error { return err } ws.WriteColors(wsLeds[:]) - time.Sleep(10 * time.Millisecond) + time.Sleep(1 * time.Millisecond) } return nil diff --git a/targets/sg48key/main.go b/targets/sg48key/main.go index 6d6cf15..c709335 100644 --- a/targets/sg48key/main.go +++ b/targets/sg48key/main.go @@ -90,18 +90,22 @@ func run() error { cont := true x := NewADCDevice(ax, 0x2000, 0xDC00, true) y := NewADCDevice(ay, 0x2400, 0xD400, true) + ticker := time.Tick(1 * time.Millisecond) + cnt := 0 for cont { + <-ticker err := d.Tick() if err != nil { return err } - xx := x.Get2() - yy := y.Get2() - //fmt.Printf("%04X %04X %4d %4d %4d %4d\n", x.RawValue, y.RawValue, xx, yy, x.Get(), y.Get()) - m.Move(int(xx), int(yy)) - - time.Sleep(10 * time.Millisecond) + if cnt%10 == 0 { + xx := x.Get2() + yy := y.Get2() + //fmt.Printf("%04X %04X %4d %4d %4d %4d\n", x.RawValue, y.RawValue, xx, yy, x.Get(), y.Get()) + m.Move(int(xx), int(yy)) + } + cnt++ } return nil diff --git a/targets/sgh60/main.go b/targets/sgh60/main.go index 2ffc558..d746f85 100644 --- a/targets/sgh60/main.go +++ b/targets/sgh60/main.go @@ -83,19 +83,22 @@ func run() error { cont := true x := NewADCDevice(ax, 0x3400, 0xD400, true) y := NewADCDevice(ay, 0x3800, 0xE990, true) + ticker := time.Tick(1 * time.Millisecond) + cnt := 0 for cont { + <-ticker err := d.Tick() if err != nil { return err } - xx := x.Get2() - yy := y.Get2() - - fmt.Printf("%04X %04X %4d %4d %4d %4d\n", x.RawValue, y.RawValue, xx, yy, x.Get(), y.Get()) - m.Move(int(xx), int(yy)) - - time.Sleep(10 * time.Millisecond) + if cnt%10 == 0 { + xx := x.Get2() + yy := y.Get2() + //fmt.Printf("%04X %04X %4d %4d %4d %4d\n", x.RawValue, y.RawValue, xx, yy, x.Get(), y.Get()) + m.Move(int(xx), int(yy)) + } + cnt++ } return nil diff --git a/targets/xiao-kb01/main.go b/targets/xiao-kb01/main.go index f2e25d9..7f16239 100644 --- a/targets/xiao-kb01/main.go +++ b/targets/xiao-kb01/main.go @@ -111,17 +111,21 @@ func run() error { } cont := true - ticker := time.Tick(4 * time.Millisecond) + ticker := time.Tick(1 * time.Millisecond) + cnt := 0 for cont { <-ticker err := d.Tick() if err != nil { return err } - if changed.Get() != 0 { - ws.WriteColors(wsLeds[:]) - changed.Set(0) + if cnt%4 == 0 { + if changed.Get() != 0 { + ws.WriteColors(wsLeds[:]) + changed.Set(0) + } } + cnt++ } return nil