ssd1306font

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: MIT Imports: 2 Imported by: 2

README

OLED font

This is a lite OLED font library using TinyGo. Tested on Raspberry Pi Pico.

This should actually work with anything that implements drivers.Displayer, though you may need to adjust the PixelOn and PixelOff colors.

Example:

package main

import (
	"machine"
	"time"

	font "github.com/ajanata/oled_font"
	"tinygo.org/x/drivers/ssd1306"
)

func main() {

	time.Sleep(time.Millisecond * 100) // Please wait some time after turning on the device to properly initialize the display
	machine.I2C0.Configure(machine.I2CConfig{Frequency: 400000})

	// Display
	dev := ssd1306.NewI2C(machine.I2C0)
	dev.Configure(ssd1306.Config{Width: 128, Height: 64, Address: 0x3C, VccState: ssd1306.SWITCHCAPVCC})
	dev.ClearBuffer()
	dev.ClearDisplay()

	//font library init
	display := font.NewDisplay(&dev)
	display.Configure(font.Config{FontType: font.FONT_7x10}) //set font here

	display.YPos = 20                 // set position Y
	display.XPos = 0                  // set position X
	display.PrintText("HELLO WORLD!") // print text

	for {
		time.Sleep(time.Hour)
	}
}
FONT_6x8

FONT_6x8

FONT_7x10

FONT_7x10

FONT_11x18

FONT_11x18

FONT_16x26

FONT_16x26

Documentation

Index

Constants

View Source
const (
	FONT_6x8   = 0x00
	FONT_7x10  = 0x01
	FONT_11x18 = 0x02
	FONT_16x26 = 0x03
)

Font types

Variables

View Source
var Font11x18 = [...]uint16{}/* 1710 elements not displayed */
View Source
var Font16x26 = [...]uint16{}/* 2470 elements not displayed */
View Source
var Font6x8 = [...]uint16{}/* 760 elements not displayed */
View Source
var Font7x10 = [...]uint16{}/* 950 elements not displayed */

start from 32[space] up to 126[~] = offset -32

View Source
var PixelOff = color.RGBA{}

PixelOff is used when a pixel should be "off" for the font. The default should work well for all displays.

View Source
var PixelOn = color.RGBA{R: 1}

PixelOn is used when a pixel should be "on" for the font. The default likely works for all common OLED drivers.

Functions

This section is empty.

Types

type Config

type Config struct {
	FontType uint8
}

Config is the configuration for the display

type Display

type Display struct {
	XPos int16
	YPos int16
	// contains filtered or unexported fields
}

Display wraps

func NewDisplay

func NewDisplay(device drivers.Displayer) Display

func (*Display) Configure

func (d *Display) Configure(cfg Config)

Configure initializes the display with default configuration

func (*Display) PrintChar

func (d *Display) PrintChar(char byte)

func (*Display) PrintCharEx added in v1.2.0

func (d *Display) PrintCharEx(char byte, inverse bool)

func (*Display) PrintCharInverse added in v1.2.0

func (d *Display) PrintCharInverse(char byte)

func (*Display) PrintText

func (d *Display) PrintText(str string)

func (*Display) PrintTextEx added in v1.2.0

func (d *Display) PrintTextEx(str string, inverse bool)

func (*Display) PrintTextInverse added in v1.2.0

func (d *Display) PrintTextInverse(str string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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