Fix spelling mistakes

This commit is contained in:
Mik Mueller 2022-03-12 15:32:56 +01:00
parent d8d85b3536
commit 2cc020450c
4 changed files with 10 additions and 8 deletions

View File

@ -12,9 +12,10 @@ package main
import ( import (
"fmt" "fmt"
"github.com/stianeikeland/go-rpio/v4"
"os" "os"
"time" "time"
"github.com/stianeikeland/go-rpio/v4"
) )
var ( var (

View File

@ -39,7 +39,7 @@ func main() {
fmt.Println("press a button") fmt.Println("press a button")
for i := 0; i < 2; { for i := 0; i < 2; {
if pin.EdgeDetected() { // check if event occured if pin.EdgeDetected() { // check if event occurred
fmt.Println("button pressed") fmt.Println("button pressed")
i++ i++
} }

View File

@ -8,11 +8,11 @@ Supports simple operations such as:
- Pin read (high/low) - Pin read (high/low)
- Pin edge detection (no/rise/fall/any) - Pin edge detection (no/rise/fall/any)
- Pull up/down/off - Pull up/down/off
Also clock/pwm related oparations: Also clock/pwm related operations:
- Set Clock frequency - Set Clock frequency
- Set Duty cycle - Set Duty cycle
And SPI oparations: And SPI operations:
- SPI transmit/recieve/exchange bytes - SPI transmit/receive/exchange bytes
- Set speed - Set speed
- Chip select - Chip select
@ -264,7 +264,7 @@ func (pin Pin) PullDown() {
PullMode(pin, PullDown) PullMode(pin, PullDown)
} }
// PullOff: Disable pullup/down on pin // PullOff: Disable pullup or pulldown on pin
func (pin Pin) PullOff() { func (pin Pin) PullOff() {
PullMode(pin, PullOff) PullMode(pin, PullOff)
} }

5
spi.go
View File

@ -21,6 +21,7 @@ const (
) )
var ( var (
// Will not fix this error's naming (would be a breaking change)
SpiMapError = errors.New("SPI registers not mapped correctly - are you root?") SpiMapError = errors.New("SPI registers not mapped correctly - are you root?")
) )
@ -118,7 +119,7 @@ func SpiMode(polarity uint8, phase uint8) {
// Data received from slave are ignored. // Data received from slave are ignored.
// Use spread operator to send slice of bytes. // Use spread operator to send slice of bytes.
func SpiTransmit(data ...byte) { func SpiTransmit(data ...byte) {
SpiExchange(append(data[:0:0], data...)) // clone data because it will be rewriten by received bytes SpiExchange(append(data[:0:0], data...)) // clone data because it will be rewritten by received bytes
} }
// SpiReceive receives n bytes from slave. // SpiReceive receives n bytes from slave.
@ -183,7 +184,7 @@ func getSpiPins(dev SpiDev) []Pin {
switch dev { switch dev {
case Spi0: case Spi0:
return []Pin{7, 8, 9, 10, 11} return []Pin{7, 8, 9, 10, 11}
// ommit 35, 36, 37, 38, 39 - only one set of SPI0 can be set in Spi mode at a time // omit 35, 36, 37, 38, 39 - only one set of SPI0 can be set in Spi mode at a time
case Spi1: case Spi1:
return []Pin{16, 17, 18, 19, 20, 21} return []Pin{16, 17, 18, 19, 20, 21}
case Spi2: case Spi2: