wavesharecloud

package module
v0.0.0-...-0729862 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

README

wavesharecloud

A Go Package to control the waveshareCloud 4.2 inch e-paper cloud module

Get Started

First thing you need to do is install the package.

go get github.com/headblockhead/wavesharecloud

Now, try running one of the examples.


Examples

Create your own

Premade Examples

Device documentation

This is the offical waveshare documentation, however it does not cover everything about the device and is translated from Chineese. I have made an attempt at making my own documentation, but it is not complete. If you would like to help out, it would be great if you could contribute!

You can find my version of the documentation here

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Display

type Display struct {
	Connection io.ReadWriteCloser

	Width  int
	Height int
	// contains filtered or unexported fields
}

Display represents the physical display.

func NewDisplay

func NewDisplay(conn io.ReadWriteCloser, password string) *Display

NewDisplay returns a new display, using a width of 400 and a height of 300. If the password is left empty, it is assumed that the display if unlocked.

func (*Display) Disconnect

func (display *Display) Disconnect()

Disconnect closes the connection to the display

func (*Display) GetBatteryLevel

func (display *Display) GetBatteryLevel() (batteryLevel int, err error)

GetBatteryLevel sends a command to the display to get its battery level. This requires the device to be unlocked.

func (*Display) GetID

func (display *Display) GetID() (ID string, err error)

GetID gets the ID of the display

func (*Display) GetLocked

func (display *Display) GetLocked() (unlocked bool, err error)

GetLocked gets whether the display is locked with a password

func (*Display) ReadBlindly

func (display *Display) ReadBlindly() (data string, err error)

ReadBlindly reads any avalible data from the display and returns it (after formatting).

func (*Display) ReadBlindlyAndIgnore

func (display *Display) ReadBlindlyAndIgnore() (err error)

ReadBlindlyAndIgnore mindlessly reads data from the display and does not do anything wth it.

func (*Display) ReceiveCommandOutput

func (display *Display) ReceiveCommandOutput(sentCommand string) (data string, err error)

ReceiveCommandOutput receives a previously sent command's output from the display.

func (*Display) Restart

func (display *Display) Restart() (err error)

Restart sends a command to the display to restart it. This requires the device to be unlocked.

func (*Display) SendCloseFrame

func (display *Display) SendCloseFrame() (err error)

SendCloseFrame sends the last frame to the display

func (*Display) SendCommand

func (display *Display) SendCommand(command string) (err error)

SendCommand sends a command to the display.

func (*Display) SendFrame

func (display *Display) SendFrame(addr uint32, num uint8, data []byte) (err error)

SendFrame sends a frame of image data to the display. This requires the display to be in data mode.

func (*Display) SendImage

func (display *Display) SendImage(img image.Image) (err error)

SendImage converts an image into bytes, then sends it to the display. If the image is not 400x300, it will crop it from the top left. This requires the display to be unlocked.

func (*Display) SendImageBytes

func (display *Display) SendImageBytes(data []byte) (err error)

SendImageBytes displays an array of bytes on the screen.

func (*Display) SendImageScaled

func (display *Display) SendImageScaled(img image.Image) (err error)

SendImageScaled converts an image into bytes, then sends it to the display. If the image is not 400x300, it will resize it. This requires the display to be unlocked.

func (*Display) Shutdown

func (display *Display) Shutdown() (err error)

Shutdown sends a command to the display to shut it down. This requires the device to be unlocked.

func (*Display) Unlock

func (display *Display) Unlock(password string) (err error)

Unlock unlocks the display with a password. It will error if the display is already unlocked.

type LoggingConn

type LoggingConn struct {
	Connection net.Conn
	Debug      bool
}

LoggingConn is a connection that will optionally log all traffic.

func NewLoggingConn

func NewLoggingConn(conn net.Conn, debug bool) *LoggingConn

NewLoggingConn returns a new connection that will optionally log all traffic.

func (*LoggingConn) Close

func (lc *LoggingConn) Close() error

Close closes the connection.

func (*LoggingConn) Read

func (lc *LoggingConn) Read(b []byte) (n int, err error)

Read reads raw data from the connection.

func (*LoggingConn) Write

func (lc *LoggingConn) Write(b []byte) (n int, err error)

Write writes raw data to the connection.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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