https://github.com/zcube/turing-smart-screen-golang
Turing Smart Screen library for Golang.
https://github.com/zcube/turing-smart-screen-golang
Last synced: 12 months ago
JSON representation
Turing Smart Screen library for Golang.
- Host: GitHub
- URL: https://github.com/zcube/turing-smart-screen-golang
- Owner: ZCube
- License: mit
- Created: 2024-05-05T06:56:34.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-05T10:56:05.000Z (about 2 years ago)
- Last Synced: 2024-05-06T07:39:03.969Z (about 2 years ago)
- Language: Go
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# turing-smart-screen-golang
Turing Smart Screen library for Golang.
## Usage
With gg (https://github.com/fogleman/gg)
```go
import (
"github.com/zcube/turing-smart-screen-golang/pkg/common"
"github.com/zcube/turing-smart-screen-golang/pkg/lcd"
)
// open the device
lcdInfo, err := lcd.New(dev, common.RevisionA)
if err != nil {
log.Fatalf("Error: %v", err)
}
defer lcdInfo.Close()
// create a new context for drawing
dc := gg.NewContext(lcdInfo.Width(), lcdInfo.Height())
// clear the screen
lcdInfo.Clear()
for {
// draw a random line
x1 := rand.Float64() * float64(lcdInfo.Width())
y1 := rand.Float64() * float64(lcdInfo.Height())
x2 := rand.Float64() * float64(lcdInfo.Width())
y2 := rand.Float64() * float64(lcdInfo.Height())
r := rand.Float64()
g := rand.Float64()
b := rand.Float64()
a := rand.Float64()*0.5 + 0.5
w := rand.Float64()*4 + 1
dc.SetRGBA(r, g, b, a)
dc.SetLineWidth(w)
dc.DrawLine(x1, y1, x2, y2)
dc.Stroke()
// display the image
lcd.DisplayImage(lcdInfo, dc.Image(), 0, 0, 320, 480)
}
```
## Example
```bash
go run examples/simple/main.go
```
## Warning
* MacOS is not supported. There are some problems with serial communication. Maybe it's a problem with the driver.