1
0
mirror of https://github.com/kidoman/embd synced 2024-12-22 12:50:19 +01:00

doc: use ``` for embedded code

This commit is contained in:
Karan Misra 2014-05-19 11:27:57 +05:30
parent b0f00069b5
commit 5e17d3721c

View File

@ -100,6 +100,7 @@ we will show a few choice examples here.
Use the **LED** driver to toggle LEDs on the BBB:
```go
import "github.com/kidoman/embd"
...
embd.InitLED()
@ -108,20 +109,24 @@ Use the **LED** driver to toggle LEDs on the BBB:
led, err := embd.NewLED(3)
...
led.Toggle()
```
Even shorter when quickly trying things out:
```go
import "github.com/kidoman/embd"
...
embd.InitLED()
defer embd.CloseLED()
...
embd.ToggleLED(3)
```
**3** is the same as **USR3** for all intents and purposes. The driver is smart enough to figure all this out.
BBB + **PWM**:
```go
import "github.com/kidoman/embd"
...
embd.InitGPIO()
@ -131,9 +136,11 @@ BBB + **PWM**:
defer pwm.Close()
...
pwm.SetDuty(1000)
```
Control **GPIO** pins on the RaspberryPi / BeagleBone Black:
```go
import "github.com/kidoman/embd"
...
embd.InitGPIO()
@ -141,9 +148,11 @@ Control **GPIO** pins on the RaspberryPi / BeagleBone Black:
...
embd.SetDirection(10, embd.Out)
embd.DigitalWrite(10, embd.High)
```
Could also do:
```go
import "github.com/kidoman/embd"
...
embd.InitGPIO()
@ -153,9 +162,11 @@ Could also do:
...
pin.SetDirection(embd.Out)
pin.Write(embd.High)
```
Or read data from the **Bosch BMP085** barometric sensor:
```go
import "github.com/kidoman/embd"
import "github.com/kidoman/embd/sensor/bmp085"
...
@ -165,9 +176,11 @@ Or read data from the **Bosch BMP085** barometric sensor:
...
temp, err := baro.Temperature()
altitude, err := baro.Altitude()
```
Even find out the heading from the **LSM303** magnetometer:
```go
import "github.com/kidoman/embd"
import "github.com/kidoman/embd/sensor/lsm303"
...
@ -176,6 +189,7 @@ Even find out the heading from the **LSM303** magnetometer:
mag := lsm303.New(bus)
...
heading, err := mag.Heading()
```
The above two examples depend on **I2C** and therefore will work without change on almost all
platforms.