mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-16 04:43:25 +00:00
clean commit, added smoke tests
This commit is contained in:
committed by
Ron Evans
parent
de22b8839e
commit
35a7590c2d
@@ -0,0 +1,49 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
"machine"
|
||||
"time"
|
||||
|
||||
"github.com/tinygo-org/drivers/pcd8544"
|
||||
)
|
||||
|
||||
func main() {
|
||||
dcPin := machine.GPIO{machine.P3}
|
||||
dcPin.Configure(machine.GPIOConfig{Mode: machine.GPIO_OUTPUT})
|
||||
rstPin := machine.GPIO{machine.P4}
|
||||
rstPin.Configure(machine.GPIOConfig{Mode: machine.GPIO_OUTPUT})
|
||||
scePin := machine.GPIO{machine.P5}
|
||||
scePin.Configure(machine.GPIOConfig{Mode: machine.GPIO_OUTPUT})
|
||||
|
||||
machine.SPI0.Configure(machine.SPIConfig{})
|
||||
|
||||
lcd := pcd8544.New(machine.SPI0, dcPin, rstPin, scePin)
|
||||
lcd.Configure(pcd8544.Config{})
|
||||
|
||||
var x int16
|
||||
var y int16
|
||||
deltaX := int16(1)
|
||||
deltaY := int16(1)
|
||||
for {
|
||||
pixel := lcd.GetPixel(x, y)
|
||||
c := color.RGBA{255, 255, 255, 255}
|
||||
if pixel {
|
||||
c = color.RGBA{0, 0, 0, 255}
|
||||
}
|
||||
lcd.SetPixel(x, y, c)
|
||||
lcd.Display()
|
||||
|
||||
x += deltaX
|
||||
y += deltaY
|
||||
|
||||
if x == 0 || x == 83 {
|
||||
deltaX = -deltaX
|
||||
}
|
||||
|
||||
if y == 0 || y == 47 {
|
||||
deltaY = -deltaY
|
||||
}
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user