Skip to content

Commit

Permalink
Merge pull request #42 from reef-pi/cross_arch
Browse files Browse the repository at this point in the history
(chore)allow compilation on non-linux setup
  • Loading branch information
ranjib authored Jan 30, 2025
2 parents b3fbba7 + 47fda5a commit c04fb01
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.PHONY: test
test:
GOOS=linux GOARCH=arm64 go test -cover ./...
go test -cover ./...

.PHONY:build
build:
GOOS=linux GOARCH=arm64 go build ./...
go build ./...

.PHONY: imports
imports:
Expand Down
10 changes: 1 addition & 9 deletions hal/digital_pin.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build !windows
// +build !windows
//go:build !darwin

package hal

Expand All @@ -11,13 +10,6 @@ const (
rpiGpioChip = "gpiochip0"
)

type DigitalPin interface {
SetDirection(bool) error
Read() (int, error)
Write(int) error
Close() error
}

func newDigitalPin(i int) (DigitalPin, error) {
return &digitalPin{pin: i}, nil
}
Expand Down
31 changes: 31 additions & 0 deletions hal/digital_pin_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//go:build !linux

package hal

const (
rpiGpioChip = "gpiochip0"
)

func newDigitalPin(i int) (DigitalPin, error) {
return &digitalPin{pin: i}, nil
}

type digitalPin struct {
pin int
}

func (p *digitalPin) SetDirection(dir bool) error {
return nil
}

func (p *digitalPin) Read() (int, error) {
return 0, nil
}

func (p *digitalPin) Write(value int) error {
return nil
}

func (p *digitalPin) Close() error {
return nil
}
7 changes: 7 additions & 0 deletions hal/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ package hal

import "fmt"

type DigitalPin interface {
SetDirection(bool) error
Read() (int, error)
Write(int) error
Close() error
}

type pin struct {
number int
name string
Expand Down

0 comments on commit c04fb01

Please sign in to comment.