mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-04 15:07:46 +00:00
7d983647ad1444074a071837fb7bc1710bcc449a
For bigger images, the pixel index might not fit in a int16. Therefore, int is needed during the calculation. While fixing this bug, I've added a few tests that verify the Image implementation by creating images, filling them with random data, and then checking whether they still contain the same data. This test failed before the patch.
netlink, examples: use 'ninafw' tag instead of individual board tags to simplify maintenence. Also see PR #4085 in the main TinyGo repo
TinyGo Drivers
This package provides a collection of 102 different hardware drivers for devices such as sensors and displays that can be used together with TinyGo.
For the complete list, please see: https://tinygo.org/docs/reference/devices/
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)
}
}
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.
Releases
10
Languages
Go
99.1%
Shell
0.7%