Last active
April 17, 2020 12:26
-
-
Save sago35/7e992534be5ba34b5cba9cfba5ca0e28 to your computer and use it in GitHub Desktop.
ili9341 improve test code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"image/color" | |
"machine" | |
"time" | |
"tinygo.org/x/drivers/ili9341" | |
"tinygo.org/x/tinyfont" | |
"tinygo.org/x/tinyfont/notosans" | |
) | |
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} | |
blue = color.RGBA{0, 0, 255, 255} | |
green = color.RGBA{0, 255, 0, 255} | |
) | |
func main() { | |
machine.TFT_BACKLIGHT.Configure(machine.PinConfig{machine.PinOutput}) | |
display.Configure(ili9341.Config{}) | |
width, height := display.Size() | |
display.FillScreen(black) | |
machine.TFT_BACKLIGHT.High() | |
buf := [320 * 240]uint16{} | |
for { | |
s1 := time.Now() | |
//display.FillRectangle(0, 0, width, height, white) | |
display.DrawRGBBitmap(0, 0, buf[:], width, height) | |
e1 := time.Now() | |
s2 := time.Now() | |
display.FillRectangle(0, 0, width, height, white) | |
e2 := time.Now() | |
tinyfont.WriteLine(display, ¬osans.Notosans12pt, 10, 10, fmt.Sprintf("%6d ms %6d ms\n", | |
(e1.UnixNano()-s1.UnixNano())/1000, | |
(e2.UnixNano()-s2.UnixNano())/1000, | |
), color.RGBA{255, 0, 0, 255}) | |
time.Sleep(100 * time.Millisecond) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment