mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-07-26 10:38:41 +00:00
c7cbd7c6cd
* Basic support of SIPO shift register * typo * add example of shiftregister for arduino and nucleo * Fix build flag for nucleof103rb * Fix wrong data pin configuration * Change README.md for Shift registers * Add API for individual register's output pin * Rewrite shift register example to show ShiftPin usage * Fix target for shiftregister example smoke test * Fix type in makefile * Add shiftregister compatble IC * Edit comment and readme
5.9 KiB
5.9 KiB
TinyGo Drivers
This package provides a collection of hardware drivers for devices that can be used together with TinyGo.
Installing
go get tinygo.org/x/drivers
How to use
Here is an example in TinyGo that uses the BMP180 digital barometer:
package main
import (
"time"
"machine"
"tinygo.org/x/drivers/bmp180"
)
func main() {
machine.I2C0.Configure(machine.I2CConfig{})
sensor := bmp180.New(machine.I2C0)
sensor.Configure()
connected := sensor.Connected()
if !connected {
println("BMP180 not detected")
return
}
println("BMP180 detected")
for {
temp, _ := sensor.ReadTemperature()
println("Temperature:", float32(temp)/1000, "°C")
pressure, _ := sensor.ReadPressure()
println("Pressure", float32(pressure)/100000, "hPa")
time.Sleep(2 * time.Second)
}
}
Currently supported devices
The following 44 devices are supported.
Contributing
Your contributions are welcome!
Please take a look at our CONTRIBUTING.md document for details.
License
This project is licensed under the BSD 3-clause license, just like the Go project itself.