2022-12-30 17:42:48 +00:00
|
|
|
//go:build !arm && !arm64
|
|
|
|
|
|
|
|
package PinControlService
|
|
|
|
|
|
|
|
type PinEmu struct {
|
2023-01-08 10:09:25 +00:00
|
|
|
state State
|
|
|
|
number int
|
2022-12-30 17:42:48 +00:00
|
|
|
}
|
|
|
|
|
2023-01-08 10:09:25 +00:00
|
|
|
func (p *PinEmu) Toggle() {
|
|
|
|
if p.state == LowState {
|
|
|
|
p.state = HighState
|
|
|
|
} else {
|
|
|
|
p.state = LowState
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
func (p *PinEmu) High() { p.state = HighState }
|
|
|
|
func (p *PinEmu) Low() { p.state = LowState }
|
2022-12-30 17:42:48 +00:00
|
|
|
func (*PinEmu) Input() {}
|
|
|
|
func (*PinEmu) Output() {}
|
|
|
|
func (*PinEmu) Detect(Edge) {}
|
|
|
|
func (*PinEmu) PullUp() {}
|
|
|
|
func (*PinEmu) PullDown() {}
|
|
|
|
func (*PinEmu) PullOff() {}
|
2023-01-08 10:09:25 +00:00
|
|
|
func (p *PinEmu) Read() State { return p.state }
|
2022-12-30 17:42:48 +00:00
|
|
|
func (*PinEmu) EdgeDetected() bool { return false }
|
|
|
|
|
|
|
|
type HardwarePin struct {
|
|
|
|
Pin PinEmu
|
|
|
|
}
|
|
|
|
|
2023-01-08 10:09:25 +00:00
|
|
|
func NewHardwarePin(num int) HardwarePinInterface {
|
|
|
|
return &PinEmu{state: LowState, number: num}
|
2022-12-30 17:42:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func HardwarePinOpen() error {
|
|
|
|
return nil
|
|
|
|
}
|