goled

package module
v0.0.0-...-0f5a50f Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: MIT Imports: 2 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

go-oled-i2c

Go Report Card GoDoc MIT License

Go implementation for .96 OLED I2C manipulation

This is a very basic Go implementation for 0.96" Oled i2c display manipulation.

Why

Story behing this library is that I have an Omega2+ with me and I wanted to do something with it(which should be suited for this little beast's capability). So I decided to build a local file server with this. Now a basic file server is okay but I also have various 0.96" Oled display with me so decided to add for this file server.

I tried initializing this Oled with Go's Periph package but it was not working. So while searching for other i2c libraries for Go, I found go-i2c and it was working.. TADA!

So I wrote this wrapper around this library for 0.96" Oled display.

Features

As of now the library is very basic and only supports,

  1. Switch on/off display functions
  2. Clear function
  3. Write text function
  4. Set cursor function

Usage

Library is very easy to use. Check the following example,

package main

import (
	"log"
	goled "github.com/sachingorade/go-oled-i2c"
)

func main() {
	oled, err := goled.BeginOled()
	if err != nil {
		log.Fatal(err)
		return
	}
	defer oled.Close()

	oled.Clear()

	oled.Write("Hello from go!")
}

License

Licensed under MIT :)

go-oled-i2c

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OLEDDefaultI2cAddress       uint8 = 0
	OLEDDefaultI2cBus           int
	OLEDScreenWidth             int
	OLEDScreenHeight            int
	OLEDDisplayRows             int
	OLEDDisplayColumns          byte
	OLEDCharLength              int
	OLEDCommandColumnAddressing int
	OLEDAddressBasePageStart    int
	OLEDStartColumn             int
)

Functions

This section is empty.

Types

type Oled

type Oled struct {
	// contains filtered or unexported fields
}

Oled Represents oled display

func BeginOled

func BeginOled(mOLEDDefaultI2cAddress uint8, mOLEDDefaultI2cBus int, mOLEDScreenWidth int, mOLEDScreenHeight int, mOLEDDisplayRows int, mOLEDDisplayColumns uint8, mOLEDStartColumn int, mOLEDCharLength int, mOLEDCommandColumnAddressing int, mOLEDAddressBasePageStart int) (*Oled, error)

BeginOled Creates a new Oled reference

func (*Oled) Clear

func (v *Oled) Clear() error

Clear clears oled screen

func (*Oled) Close

func (v *Oled) Close()

Close closes the oled i2c bus

func (*Oled) DisplayOff

func (v *Oled) DisplayOff() error

DisplayOff switches off the oled display

func (*Oled) DisplayOn

func (v *Oled) DisplayOn() error

DisplayOn switches on the oled display

func (*Oled) SetColumnAddressing

func (v *Oled) SetColumnAddressing(startPixel int, endPixel int) (int, error)

SetColumnAddressing sets the oled viewport

func (*Oled) SetCursor

func (v *Oled) SetCursor(row int, column int) error

SetCursor sets the cursor at specified row and column

func (*Oled) Write

func (v *Oled) Write(message string) (int, error)

Write writes the specified string on oled

func (*Oled) WriteChar

func (v *Oled) WriteChar(c int) error

WriteChar writes specified character on oled display

func (*Oled) WriteCharUnchecked

func (v *Oled) WriteCharUnchecked(c int) error

WriteCharUnchecked write specified character as it is on oled

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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