Skip to content

ajanata/oled_font

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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