turing-smart-screen-golang

module
v0.0.0-...-3750853 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2024 License: MIT

README

turing-smart-screen-golang

Turing Smart Screen library for Golang.

Usage

With gg (https://github.com/fogleman/gg)

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

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.

Directories

Path Synopsis
examples
chromedp command
simple command
pkg
lcd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL