tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/drivers.go (about)

     1  // Package drivers provides a collection of hardware drivers for TinyGo (https://tinygo.org)
     2  // for devices such as sensors and displays.
     3  //
     4  // Here is an example in TinyGo that uses the BMP180 digital barometer:
     5  //
     6  //	package main
     7  //
     8  //	import (
     9  //		"time"
    10  //		"machine"
    11  //
    12  //		"tinygo.org/x/drivers/bmp180"
    13  //	)
    14  //
    15  //	func main() {
    16  //		machine.I2C0.Configure(machine.I2CConfig{})
    17  //		sensor := bmp180.New(machine.I2C0)
    18  //		sensor.Configure()
    19  //
    20  //		connected := sensor.Connected()
    21  //		if !connected {
    22  //			println("BMP180 not detected")
    23  //			return
    24  //		}
    25  //		println("BMP180 detected")
    26  //
    27  //		for {
    28  //			temp, _ := sensor.ReadTemperature()
    29  //			println("Temperature:", float32(temp)/1000, "°C")
    30  //
    31  //			pressure, _ := sensor.ReadPressure()
    32  //			println("Pressure", float32(pressure)/100000, "hPa")
    33  //
    34  //			time.Sleep(2 * time.Second)
    35  //		}
    36  //	}
    37  //
    38  // Each individual driver is contained within its own sub-package within this package and
    39  // there are no interdependencies in order to minimize the final size of compiled code that
    40  // uses any of these drivers.
    41  package drivers // import "tinygo.org/x/drivers"