Skip to content

Commit

Permalink
ssd1306: added example
Browse files Browse the repository at this point in the history
Signed-off-by: Jordi Llonch <[email protected]>
  • Loading branch information
llonchj committed Mar 31, 2017
1 parent a66cfb1 commit 6ea0383
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions examples/raspi_ssd1306.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package main

import (
"time"

"gobot.io/x/gobot"
"gobot.io/x/gobot/drivers/i2c"
"gobot.io/x/gobot/platforms/raspi"
)

func main() {

r := raspi.NewAdaptor()
oled := i2c.NewSSD1306Driver(r)

stage := false

work := func() {

gobot.Every(1*time.Second, func() {
oled.Clear()
if stage {
for x := 0; x < oled.Buffer.Width; x += 5 {
for y := 0; y < oled.Buffer.Height; y++ {
oled.Set(x, y, 1)
}
}
}
stage = !stage
oled.Display()
})
}

robot := gobot.NewRobot("ssd1306Robot",
[]gobot.Connection{r},
[]gobot.Device{oled},
work,
)

robot.Start()
}

0 comments on commit 6ea0383

Please sign in to comment.