gobot.io/x/gobot@v1.16.0/examples/gopigo3_grove_lcd.go (about)

     1  // +build example
     2  //
     3  // Do not build by default.
     4  
     5  package main
     6  
     7  import (
     8  	"gobot.io/x/gobot"
     9  	"gobot.io/x/gobot/drivers/i2c"
    10  	"gobot.io/x/gobot/platforms/dexter/gopigo3"
    11  	"gobot.io/x/gobot/platforms/raspi"
    12  )
    13  
    14  func main() {
    15  	raspiAdaptor := raspi.NewAdaptor()
    16  	gpg3 := gopigo3.NewDriver(raspiAdaptor)
    17  	screen := i2c.NewGroveLcdDriver(raspiAdaptor)
    18  
    19  	work := func() {
    20  		manufacturerName := ""
    21  		boardName := ""
    22  		hardwareVersion := ""
    23  		manufacturerName, _ = gpg3.GetManufacturerName()
    24  		boardName, _ = gpg3.GetBoardName()
    25  		hardwareVersion, _ = gpg3.GetHardwareVersion()
    26  		screen.Write(manufacturerName[0:15])
    27  		screen.SetPosition(16)
    28  		screen.Write(boardName + " " + hardwareVersion)
    29  		screen.SetRGB(0, 0, 255)
    30  		screen.Home()
    31  	}
    32  
    33  	robot := gobot.NewRobot("gopigo3lcd",
    34  		[]gobot.Connection{raspiAdaptor},
    35  		[]gobot.Device{gpg3, screen},
    36  		work,
    37  	)
    38  
    39  	robot.Start()
    40  }