This library is a SSD1331 driver for Raspberry Pi 4.
See a Document at https://pkg.go.dev/github.com/BinaryDolphin29/SSD1331
No...This library is Written by begginer.
So I can't take any responsibility.
I use this OLED module https://akizukidenshi.com/catalog/g/gP-14435/, and Raspberry Pi 4(Raspbian Lite 32bit). I tested only these device.
go get github.com/BinaryDolphin29/SSD1331
And you need to append 👇
spidev.bufsiz=65536
to the /boot/cmdline.txt
.
It is raises the SPI buffer limit(Must be 16 bits or higher)
GND -> GND
VCC -> 5V
SCL -> GPIO 11
SDA -> GPIO 10
RES -> GPIO 25
DC -> GPIO 24
CS -> GPIO 8
package main
import (
"log"
OLED "github.com/BinaryDolphin29/SSD1331"
"periph.io/x/conn/v3/physic"
"periph.io/x/host/v3/rpi"
)
type pattColor struct {
R, G, B int
}
const max75 int = ((2<<7)*0.75) - 1
var testPattern = [6]pattColor{
{max75, max75, max75}, // white
{max75, max75, 0}, // yellow
{0, max75, max75}, // cyan
{0, max75, 0}, // green
{max75, 0, max75}, // magenta
{0, 0, max75}, // blue
}
func main() {
display := &OLED.SSD1331{
Name: "/dev/spidev0.0",
Frequency: 8 * physic.MegaHertz,
ResetPin: rpi.P1_22,
DCPin: rpi.P1_18,
}
if err := display.Init(); err != nil {
log.Fatalln(err.Error())
}
width, height := display.Resolution()
defer display.Close()
display.ClearDisplay()
var (
rowSize = width / len(testPattern)
maxX = rowSize
x = 0
)
for _, c := range testPattern {
for ; x < maxX; x++ {
for y := 0; y < height; y++ {
display.SetPixel(x, y, c.R, c.G, c.B)
}
}
maxX += rowSize
}
display.Display()
}
This code in the example directry.
periph.io/x/conn/v3/driver/driverreg
periph.io/x/conn/v3/gpio
periph.io/x/conn/v3/physic
periph.io/x/conn/v3/spi
periph.io/x/conn/v3/spi/spireg
periph.io/x/host/v3
Thanks!
Library for more information periph.io and GitHub repository github.com/google/periph.
If you can speak Japanese, I created this Discord server, join us!