Skip to content

Commit aa5ba1e

Browse files
committed
update demo
1 parent 40f3d7e commit aa5ba1e

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

_demo/esp/main.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,30 @@ package main
22

33
import (
44
"unsafe"
5+
_ "unsafe"
6+
7+
"github.com/goplus/lib/emb/machine"
58
)
69

710
//go:linkname StoreUint32 llgo.atomicStore
811
func StoreUint32(addr *uint32, val uint32)
912

1013
//go:linkname sleep sleep
11-
func sleep(tm int)
14+
func sleep(n int)
1215

1316
func main() {
1417
StoreUint32((*uint32)(unsafe.Pointer(uintptr(0x3ff480A4))), 0x50D83AA1)
1518
StoreUint32((*uint32)(unsafe.Pointer(uintptr(0x3ff4808C))), 0)
1619
StoreUint32((*uint32)(unsafe.Pointer(uintptr(0x3ff5f048))), 0)
1720
buttonPin := machine.GPIO34
1821
buttonPin.Configure(machine.PinConfig{Mode: machine.PinInput})
19-
println(buttonPin.Get())
20-
sleep(2)
21-
println(buttonPin.Get())
22-
println(buttonState)
23-
// time.Sleep(200 * time.Millisecond)
22+
23+
for i := 0; i < 10; i++ {
24+
if buttonPin.Get() {
25+
println("yes")
26+
} else {
27+
println("no")
28+
}
29+
sleep(1)
30+
}
2431
}

0 commit comments

Comments
 (0)