microview

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

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

Go to latest
Published: Apr 7, 2017 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

microview

Build Status Go Report Card GoDoc License MIT

Go library used to remote control a MicroView

Requirements

Install

Go package
go get -u github.com/peterhellberg/microview
MicroView Arduino Library

Note: This package requires the use of a newer version of the MicroView Arduino Library (v1.07b or later) than what is currently available in the Arduino Library Manager.

So just follow these steps instead:

  1. Change directory to Arduino's main directory (~/Documents/Arduino/ in my case)
  2. cd libraries
  3. mkdir MicroView
  4. cd MicroView
  5. git clone https://github.com/geekammo/MicroView-Arduino-Library.git .
Arduino sketch

Now you need to upload the following sketch to your MicroView using the Arduino IDE

#include <MicroView.h>

void setup() {
  uView.begin();
  uView.clear(PAGE);

  Serial.begin(115200);
  Serial.print("MicroView");
}

void loop() {
  uView.checkComm();
}

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),
	)
}

rectangles

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

View Source
const (
	WIDTH  = 64
	HEIGHT = 48
)

Size

View Source
const (
	BLACK = 0
	WHITE = 1
)

Colors

View Source
const (
	NORM = 0
	XOR  = 1
)

Draw modes

View Source
const (
	PAGE = 0
	ALL  = 1
)

Clear modes

View Source
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

func Circle(x, y, r uint8) []byte

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

func CircleFill(x, y, r uint8) []byte

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

func Clear(mode uint8) []byte

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

func Contrast(c uint8) []byte

Contrast sets the contrast CMD_CONTRAST, 2

OLED contrast value from 0 to 255.

Note: Contrast level is not very obvious.

func Delay

func Delay(d time.Duration) func(*MicroView)

Delay between each command sent to the MicroView (25ms seems to be the minimum delay)

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

func DrawChar(x, y uint8, c rune) []byte

DrawChar draws a character CMD_DRAWCHAR, 13

Draw character c using current color and current draw mode at x,y.

func Fill

func Fill() []byte

Fill the screen with the current fore color CMD_RECTFILL, 10

func Invert

func Invert(inv bool) []byte

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

func Line(x0, y0, x1, y1 uint8) []byte

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

func LineH(x, y, w uint8) []byte

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

func LineHWithColorAndMode(x, y, w, color, mode uint8) []byte

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

func LineV(x, y, h uint8) []byte

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

func LineVWithColorAndMode(x, y, h, color, mode uint8) []byte

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

func LineWithColorAndMode(x0, y0, x1, y1, color, mode uint8) []byte

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

func Pixel(x, y uint8) []byte

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

func PixelWithColorAndMode(x, y, color, mode uint8) []byte

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

func Rect(x, y, w, h uint8) []byte

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

func RectFill(x, y, w, h uint8) []byte

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

func RectFillWithColorAndMode(x, y, w, h, color, mode uint8) []byte

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

func RectWithColorAndMode(x, y, w, h, color, mode uint8) []byte

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

func SetColor(c uint8) []byte

SetColor sets the color CMD_SETCOLOR, 17

Set the current draw's color. Only WHITE and BLACK available.

func SetCursor

func SetCursor(x, y uint8) []byte

SetCursor sets the cursor position CMD_SETCURSOR, 4

MicroView's cursor position to x,y.

func SetDrawMode

func SetDrawMode(mode uint8) []byte

SetDrawMode sets the draw mode CMD_SETDRAWMODE, 18

Set current draw mode with NORM or XOR.

Types

type Command

type Command []byte

Command is a command to be sent to the MicroView

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

func OpenMicroView(name string, options ...func(*MicroView)) (*MicroView, error)

OpenMicroView opens a terminal connection to a MicroView

func (*MicroView) At

func (mv *MicroView) At(x, y int) color.Color

At returns the color at x,y (always black for now)

func (*MicroView) Bounds

func (mv *MicroView) Bounds() image.Rectangle

Bounds of the MicroView (it is 64x48)

func (*MicroView) ColorModel

func (mv *MicroView) ColorModel() color.Model

ColorModel of the MicroView

func (*MicroView) DrawString

func (mv *MicroView) DrawString(x, y uint8, s string)

DrawString draws the provided string at x,y

func (*MicroView) Run

func (mv *MicroView) Run(cmds ...Command)

Run commands

func (*MicroView) Set

func (mv *MicroView) Set(x, y int, c color.Color)

Set the pixel at x,y to WHITE or BLACK based on the provided color

Jump to

Keyboard shortcuts

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