mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-04 23:17:47 +00:00
9c29529cbbd2e68d8d7414d0e9298a2131273566
The rotation as configured using st7789.Config was rotated 180°: 0° was configured as 180°, 90° was configured as 270°, etc. Presumably with the original test display, the ribbon cable was seen as the top of the screen while if you look at product photos it is usually at the bottom. Example: https://www.buydisplay.com/wide-angle-1-3-inch-240x240-color-ips-tft-display-st7789-controller Only Adafruit seems to sell these displays upside down: https://www.adafruit.com/product/3787 This patch fixes this mistake. It should be noted that this is backwards incompatible: all code that uses a st7789 will have to be modified to use the correct rotation instead of the previous incorrect rotation. If this is too big of a change, we could just keep things as-is and pretend that all displays are upside down.
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)
}
}
Supported devices
There are currently 96 devices supported. For the complete list, please see: https://tinygo.org/docs/reference/devices/
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%