From 4071a37394f2201939c602375f3a45922d18e3e5 Mon Sep 17 00:00:00 2001 From: didier amyot Date: Fri, 26 Jul 2024 12:58:42 -0400 Subject: [PATCH] added arm detector --- main.go | 17 +++++++++++------ orangefork/orangefork.go | 8 ++++++++ orangefork/orangefork_arm64.go | 6 ++++++ orangefork/orangefork_other.go | 6 ++++++ orangefork/orangepi_arm.go | 1 + 5 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 orangefork/orangefork.go create mode 100644 orangefork/orangefork_arm64.go create mode 100644 orangefork/orangefork_other.go create mode 100644 orangefork/orangepi_arm.go diff --git a/main.go b/main.go index fa15118..b219373 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "go-orange/orangefork" "periph.io/x/conn/v3/gpio" "periph.io/x/host/v3" "periph.io/x/host/v3/orangepi" @@ -9,6 +10,10 @@ import ( ) func main() { + fmt.Println(orangefork.Foo()) + if 1 == 2-1 { + return + } s, err := host.Init() if err != nil { fmt.Printf("%s", err) @@ -20,22 +25,22 @@ func main() { for l := gpio.Low; ; l = !l { if err := orangepi.PA1_11.Out(l); err != nil { - fmt.Printf("PA1_11 %s", err) + fmt.Printf("PA1_11 %s\n", err) } if err := orangepi.PA1_12.Out(l); err != nil { - fmt.Printf("PA1_12 %s", err) + fmt.Printf("PA1_12 %s\n", err) } if err := orangepi.PA1_10.Out(l); err != nil { - fmt.Printf("PA1_10 %s", err) + fmt.Printf("PA1_10 %s\n", err) } if err := orangepi.PA1_8.Out(l); err != nil { - fmt.Printf("PA1_8 %s", err) + fmt.Printf("PA1_8 %s\n", err) } if err := orangepi.PA1_7.Out(l); err != nil { - fmt.Printf("PA1_7 %s", err) + fmt.Printf("PA1_7 %s\n", err) } if err := orangepi.PA1_5.Out(l); err != nil { - fmt.Printf("PA1_5 %s", err) + fmt.Printf("PA1_5 %s\n", err) } <-t.C fmt.Println("tick") diff --git a/orangefork/orangefork.go b/orangefork/orangefork.go new file mode 100644 index 0000000..8bcff9f --- /dev/null +++ b/orangefork/orangefork.go @@ -0,0 +1,8 @@ +package orangefork + +func Foo() string { + if isArm { + return "is arm" + } + return "is not arm" +} diff --git a/orangefork/orangefork_arm64.go b/orangefork/orangefork_arm64.go new file mode 100644 index 0000000..41cf630 --- /dev/null +++ b/orangefork/orangefork_arm64.go @@ -0,0 +1,6 @@ +//go:build arm64 +// +build arm64 + +package orangefork + +const isArm = true diff --git a/orangefork/orangefork_other.go b/orangefork/orangefork_other.go new file mode 100644 index 0000000..f20f867 --- /dev/null +++ b/orangefork/orangefork_other.go @@ -0,0 +1,6 @@ +//go:build !arm && !arm64 +// +build !arm,!arm64 + +package orangefork + +const isArm = false diff --git a/orangefork/orangepi_arm.go b/orangefork/orangepi_arm.go new file mode 100644 index 0000000..727ecb1 --- /dev/null +++ b/orangefork/orangepi_arm.go @@ -0,0 +1 @@ +package orangefork