Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ smoke-test:
@md5sum ./build/test.hex
tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hub75/main.go
@md5sum ./build/test.hex
tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/basic/main.go
tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/basic
@md5sum ./build/test.hex
tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/scroll/main.go
tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/pyportal_boing
@md5sum ./build/test.hex
tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/scroll
@md5sum ./build/test.hex
tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis3dh/main.go
@md5sum ./build/test.hex
Expand Down
13 changes: 2 additions & 11 deletions examples/ili9341/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ import (
)

var (
display = ili9341.NewParallel(
machine.LCD_DATA0,
machine.TFT_WR,
machine.TFT_DC,
machine.TFT_CS,
machine.TFT_RESET,
machine.TFT_RD,
)

black = color.RGBA{0, 0, 0, 255}
white = color.RGBA{255, 255, 255, 255}
red = color.RGBA{255, 0, 0, 255}
Expand All @@ -27,13 +18,13 @@ var (

func main() {

machine.TFT_BACKLIGHT.Configure(machine.PinConfig{machine.PinOutput})
backlight.Configure(machine.PinConfig{machine.PinOutput})

display.Configure(ili9341.Config{})
width, height := display.Size()

display.FillScreen(black)
machine.TFT_BACKLIGHT.High()
backlight.High()

display.FillRectangle(0, 0, width/2, height/2, white)
display.FillRectangle(width/2, 0, width/2, height/2, red)
Expand Down
22 changes: 22 additions & 0 deletions examples/ili9341/basic/pyportal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// +build pyportal

package main

import (
"machine"

"tinygo.org/x/drivers/ili9341"
)

var (
display = ili9341.NewParallel(
machine.LCD_DATA0,
machine.TFT_WR,
machine.TFT_DC,
machine.TFT_CS,
machine.TFT_RESET,
machine.TFT_RD,
)

backlight = machine.TFT_BACKLIGHT
)
29 changes: 29 additions & 0 deletions examples/ili9341/basic/wioterminal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// +build wioterminal

package main

import (
"machine"

"tinygo.org/x/drivers/ili9341"
)

var (
display = ili9341.NewSpi(
machine.SPI3,
machine.LCD_DC,
machine.LCD_SS_PIN,
machine.LCD_RESET,
)

backlight = machine.LCD_BACKLIGHT
)

func init() {
machine.SPI3.Configure(machine.SPIConfig{
SCK: machine.LCD_SCK_PIN,
MOSI: machine.LCD_MOSI_PIN,
MISO: machine.LCD_MISO_PIN,
Frequency: 40000000,
})
}
13 changes: 2 additions & 11 deletions examples/ili9341/pyportal_boing/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ const (
)

var (
display = ili9341.NewParallel(
machine.LCD_DATA0,
machine.TFT_WR,
machine.TFT_DC,
machine.TFT_CS,
machine.TFT_RESET,
machine.TFT_RD,
)

frameBuffer = [(graphics.BALLHEIGHT + 8) * (graphics.BALLWIDTH + 8)]uint16{}

startTime int64
Expand All @@ -56,15 +47,15 @@ var (
func main() {

// configure backlight
machine.TFT_BACKLIGHT.Configure(machine.PinConfig{machine.PinOutput})
backlight.Configure(machine.PinConfig{machine.PinOutput})

// configure display
display.Configure(ili9341.Config{})
print("width, height == ")
width, height := display.Size()
println(width, height)

machine.TFT_BACKLIGHT.High()
backlight.High()

display.SetRotation(ili9341.Rotation270)
DrawBackground()
Expand Down
22 changes: 22 additions & 0 deletions examples/ili9341/pyportal_boing/pyportal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// +build pyportal

package main

import (
"machine"

"tinygo.org/x/drivers/ili9341"
)

var (
display = ili9341.NewParallel(
machine.LCD_DATA0,
machine.TFT_WR,
machine.TFT_DC,
machine.TFT_CS,
machine.TFT_RESET,
machine.TFT_RD,
)

backlight = machine.TFT_BACKLIGHT
)
29 changes: 29 additions & 0 deletions examples/ili9341/pyportal_boing/wioterminal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// +build wioterminal

package main

import (
"machine"

"tinygo.org/x/drivers/ili9341"
)

var (
display = ili9341.NewSpi(
machine.SPI3,
machine.LCD_DC,
machine.LCD_SS_PIN,
machine.LCD_RESET,
)

backlight = machine.LCD_BACKLIGHT
)

func init() {
machine.SPI3.Configure(machine.SPIConfig{
SCK: machine.LCD_SCK_PIN,
MOSI: machine.LCD_MOSI_PIN,
MISO: machine.LCD_MISO_PIN,
Frequency: 40000000,
})
}
13 changes: 2 additions & 11 deletions examples/ili9341/scroll/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ import (
)

var (
display = ili9341.NewParallel(
machine.LCD_DATA0,
machine.TFT_WR,
machine.TFT_DC,
machine.TFT_CS,
machine.TFT_RESET,
machine.TFT_RD,
)

red = color.RGBA{255, 0, 0, 255}
blue = color.RGBA{0, 0, 255, 255}
green = color.RGBA{0, 255, 0, 255}
Expand All @@ -27,13 +18,13 @@ var (

func main() {

machine.TFT_BACKLIGHT.Configure(machine.PinConfig{machine.PinOutput})
backlight.Configure(machine.PinConfig{machine.PinOutput})

display.Configure(ili9341.Config{})
width, height := display.Size()

display.FillScreen(black)
machine.TFT_BACKLIGHT.High()
backlight.High()

display.FillRectangle(0, 0, width/2, height/2, white)
display.FillRectangle(width/2, 0, width/2, height/2, red)
Expand Down
22 changes: 22 additions & 0 deletions examples/ili9341/scroll/pyportal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// +build pyportal

package main

import (
"machine"

"tinygo.org/x/drivers/ili9341"
)

var (
display = ili9341.NewParallel(
machine.LCD_DATA0,
machine.TFT_WR,
machine.TFT_DC,
machine.TFT_CS,
machine.TFT_RESET,
machine.TFT_RD,
)

backlight = machine.TFT_BACKLIGHT
)
29 changes: 29 additions & 0 deletions examples/ili9341/scroll/wioterminal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// +build wioterminal

package main

import (
"machine"

"tinygo.org/x/drivers/ili9341"
)

var (
display = ili9341.NewSpi(
machine.SPI3,
machine.LCD_DC,
machine.LCD_SS_PIN,
machine.LCD_RESET,
)

backlight = machine.LCD_BACKLIGHT
)

func init() {
machine.SPI3.Configure(machine.SPIConfig{
SCK: machine.LCD_SCK_PIN,
MOSI: machine.LCD_MOSI_PIN,
MISO: machine.LCD_MISO_PIN,
Frequency: 40000000,
})
}
6 changes: 3 additions & 3 deletions ili9341/ili9341.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,15 @@ func (d *Device) sendCommand(cmd byte, data []byte) {
d.dc.Low()
d.driver.write8(cmd)
d.dc.High()
for _, b := range data {
d.driver.write8(b)
}
d.driver.write8sl(data)
d.endWrite()
}

type driver interface {
configure(config *Config)
write8(b byte)
write8n(b byte, n int)
write8sl(b []byte)
write16(data uint16)
write16n(data uint16, n int)
write16sl(data []uint16)
Expand Down
14 changes: 14 additions & 0 deletions ili9341/parallel_atsamd51.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ func (pd *parallelDriver) wrx() {
volatile.StoreUint32(pd.wrPortSet, pd.wrMaskSet)
}

//go:inline
func (pd *parallelDriver) write8n(b byte, n int) {
for i := 0; i < n; i++ {
pd.write8(b)
}
}

//go:inline
func (pd *parallelDriver) write8sl(b []byte) {
for i := 0; i < len(b); i++ {
pd.write8(b[i])
}
}

//go:inline
func (pd *parallelDriver) write16(data uint16) {
pd.write8(byte(data >> 8))
Expand Down
Loading