shifter: simplify API surface for PyBadge (#137)

* shifter: simplify API surface and use build directive to directly match the PyBadge

Signed-off-by: Ron Evans <ron@hybridgroup.com>

* shifter: further simplify API for PyBadge

Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
Ron Evans
2020-03-06 06:29:30 +00:00
committed by GitHub
parent 583e80026a
commit 41c6e3be0b
3 changed files with 44 additions and 23 deletions
+32
View File
@@ -0,0 +1,32 @@
// +build pybadge
package shifter
import "machine"
const (
BUTTON_LEFT = 0
BUTTON_UP = 1
BUTTON_DOWN = 2
BUTTON_RIGHT = 3
BUTTON_SELECT = 4
BUTTON_START = 5
BUTTON_A = 6
BUTTON_B = 7
)
// NewButtons returns a new shifter device for the buttons on an AdaFruit PyBadge
func NewButtons() Device {
return Device{
latch: machine.BUTTON_LATCH,
clk: machine.BUTTON_CLK,
out: machine.BUTTON_OUT,
Pins: make([]ShiftPin, int(EIGHT_BITS)),
bits: EIGHT_BITS,
}
}
// ReadInput returns the latest input readings from the PyBadge.
func (d *Device) ReadInput() (uint8, error) {
return d.Read8Input()
}
+1 -1
View File
@@ -30,7 +30,7 @@ type ShiftPin struct {
pressed bool
}
// New returns a new thermistor driver given an ADC pin.
// New returns a new shifter driver given the correct pins.
func New(numBits NumberBit, latch, clk, out machine.Pin) Device {
return Device{
latch: latch,