Documentation ¶
Overview ¶
Package microview is used to remote control a MicroView - OLED Arduino Module
Installation
go get -u github.com/peterhellberg/microview
Example
package main import ( "flag" "log" "time" . "github.com/peterhellberg/microview" ) func main() { name := flag.String("name", "/dev/cu.usbserial-DA00SSM3", "name of the serial port") flag.Parse() mv, err := OpenMicroView(*name, Delay(90*time.Millisecond)) if err != nil { log.Fatal(err) } mv.Run( RectFill(5, 5, 5, 15), RectFill(25, 0, 30, 15), Rect(1, 1, 20, 40), Rect(40, 20, 20, 20), Rect(40, 20, 15, 15), Rect(40, 20, 10, 10), Rect(40, 20, 5, 5), ) }
Index ¶
- Constants
- func Circle(x, y, r uint8) []byte
- func CircleFill(x, y, r uint8) []byte
- func Clear(mode uint8) []byte
- func Contrast(c uint8) []byte
- func Delay(d time.Duration) func(*MicroView)
- func Display() []byte
- func DrawChar(x, y uint8, c rune) []byte
- func Fill() []byte
- func Invert(inv bool) []byte
- func Line(x0, y0, x1, y1 uint8) []byte
- func LineH(x, y, w uint8) []byte
- func LineHWithColorAndMode(x, y, w, color, mode uint8) []byte
- func LineV(x, y, h uint8) []byte
- func LineVWithColorAndMode(x, y, h, color, mode uint8) []byte
- func LineWithColorAndMode(x0, y0, x1, y1, color, mode uint8) []byte
- func Pixel(x, y uint8) []byte
- func PixelWithColorAndMode(x, y, color, mode uint8) []byte
- func Rect(x, y, w, h uint8) []byte
- func RectFill(x, y, w, h uint8) []byte
- func RectFillWithColorAndMode(x, y, w, h, color, mode uint8) []byte
- func RectWithColorAndMode(x, y, w, h, color, mode uint8) []byte
- func SetColor(c uint8) []byte
- func SetCursor(x, y uint8) []byte
- func SetDrawMode(mode uint8) []byte
- type Command
- type MicroView
Constants ¶
const ( WIDTH = 64 HEIGHT = 48 )
Size
const ( BLACK = 0 WHITE = 1 )
Colors
const ( NORM = 0 XOR = 1 )
Draw modes
const ( PAGE = 0 ALL = 1 )
Clear modes
const ( CLEAR = 0 INVERT = 1 CONTRAST = 2 DISPLAY = 3 SETCURSOR = 4 PIXEL = 5 LINE = 6 LINEH = 7 LINEV = 8 RECT = 9 RECTFILL = 10 CIRCLE = 11 CIRCLEFILL = 12 DRAWCHAR = 13 DRAWBITMAP = 14 // Not implemented yet GETLCDWIDTH = 15 GETLCDHEIGHT = 16 SETCOLOR = 17 SETDRAWMODE = 18 )
Command identifiers
Variables ¶
This section is empty.
Functions ¶
func Circle ¶
Circle draws a circle CMD_CIRCLE, 11
Draw circle with radius using current fore color and current draw mode at x,y of the screen buffer.
func CircleFill ¶
CircleFill draws a filled circle CMD_CIRCLEFILL, 12
Draw filled circle with radius using current fore color and current draw mode at x,y of the screen buffer.
func Clear ¶
Clear clears the display (ALL or PAGE) CMD_CLEAR, 0
To clear GDRAM inside the LCD controller, pass in the variable mode = ALL and to clear screen page buffer, pass in the variable mode = PAGE
func Contrast ¶
Contrast sets the contrast CMD_CONTRAST, 2
OLED contrast value from 0 to 255.
Note: Contrast level is not very obvious.
func Display ¶
func Display() []byte
Display the buffer on the OLED CMD_DISPLAY, 3
Bulk move the screen buffer to the SSD1306 controller's memory so that images/graphics drawn on the screen buffer will be displayed on the OLED.
func DrawChar ¶
DrawChar draws a character CMD_DRAWCHAR, 13
Draw character c using current color and current draw mode at x,y.
func Invert ¶
Invert inverts the display CMD_INVERT, 1
The WHITE color of the display will turn to BLACK and the BLACK will turn to WHITE.
func Line ¶
Line draws a line CMD_LINE, 6
Draw line using current fore color and current draw mode from x0,y0 to x1,y1 of the screen buffer.
func LineH ¶
LineH draws a horizontal line CMD_LINEH, 7
Draw horizontal line using current fore color and current draw mode from x,y to x+width,y of the screen buffer.
func LineHWithColorAndMode ¶
LineHWithColorAndMode draws a horizontal line with color and mode. CMD_LINEH, 7
Draw horizontal line using color and mode from x,y to x+width,y of the screen buffer.
func LineV ¶
LineV draws a vertical line CMD_LINEV, 8
Draw vertical line using current fore color and current draw mode from x,y to x,y+height of the screen buffer.
func LineVWithColorAndMode ¶
LineVWithColorAndMode draws a vertical line with color and mode CMD_LINEV, 8
Draw vertical line using color and mode from x,y to x,y+height of the screen buffer.
func LineWithColorAndMode ¶
LineWithColorAndMode draws a line with color and mode CMD_LINE, 6
Draw line using color and mode from x0,y0 to x1,y1 of the screen buffer.
func Pixel ¶
Pixel draws a pixel at x,y CMD_PIXEL, 5
Draw pixel using the current fore color and current draw mode in the screen buffer's x,y position.
func PixelWithColorAndMode ¶
PixelWithColorAndMode draws pixel at x,y with color and mode CMD_PIXEL, 5
Draw color pixel in the screen buffer's x,y position with NORM or XOR draw mode.
func Rect ¶
Rect draws a rectangle CMD_RECT, 9
Draw rectangle using current fore color and current draw mode from x,y to x+width,y+height of the screen buffer.
func RectFill ¶
RectFill draws a filled rectangle. CMD_RECTFILL, 10
Draw filled rectangle using current fore color and current draw mode from x,y to x+width,y+height of the screen buffer.
func RectFillWithColorAndMode ¶
RectFillWithColorAndMode draws a filled rectangle with color and mode CMD_RECT, 10
Draw filled rectangle using color and mode from x,y to x+width,y+height of the screen buffer.
func RectWithColorAndMode ¶
RectWithColorAndMode draws a rectangle with color and mode CMD_RECT, 9
Draw rectangle using color and mode from x,y to x+width,y+height of the screen buffer.
func SetColor ¶
SetColor sets the color CMD_SETCOLOR, 17
Set the current draw's color. Only WHITE and BLACK available.
func SetCursor ¶
SetCursor sets the cursor position CMD_SETCURSOR, 4
MicroView's cursor position to x,y.
func SetDrawMode ¶
SetDrawMode sets the draw mode CMD_SETDRAWMODE, 18
Set current draw mode with NORM or XOR.
Types ¶
type MicroView ¶
type MicroView struct { io.ReadWriteCloser // contains filtered or unexported fields }
MicroView represents a remote MicroView micro controller
func NewMicroView ¶
func NewMicroView(rwc io.ReadWriteCloser, options ...func(*MicroView)) *MicroView
NewMicroView creates a new MicroView instance
func OpenMicroView ¶
OpenMicroView opens a terminal connection to a MicroView
func (*MicroView) ColorModel ¶
ColorModel of the MicroView
func (*MicroView) DrawString ¶
DrawString draws the provided string at x,y