mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-06 07:53:41 +00:00
7a2b1b8c90d093af0cf75a24b7a6247f95a18742
The WS2811 has a slightly slower data rate, but it is close enough that a single library can support both LEDs at the same time. In my testing, this package was already compatible with WS2811 LEDs before this change when running at 4-5V, but when the voltage dropped to 3V or so the LEDs started misbehaving. With these improved timings, the LEDs remained of the correct color even at very low voltages (although blue was starting to fade due to lack of voltage - that's not a software/protocol issue).
TinyGo Drivers
This package provides a collection of hardware drivers for devices such as sensors and displays 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 67 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.
Releases
10
Languages
Go
99.1%
Shell
0.7%