Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TinyGo support for SSD1306 #4483

Open
ohchloeho opened this issue Sep 26, 2024 · 1 comment
Open

TinyGo support for SSD1306 #4483

ohchloeho opened this issue Sep 26, 2024 · 1 comment

Comments

@ohchloeho
Copy link

ohchloeho commented Sep 26, 2024

I have tested both an Arduino Nano and ESP32 module with the SSD1306 OLED module while using the Go machine package with the tinygo SSD1306 driver ("tinygo.org/x/drivers/ssd1306"). It seems no matter how I flash TinyGo code to the modules the SSD1306 will not work. I'm certain this is a configuration issue as I'm able to flash LEDs and button controls to the pins. Please let me know if there's a resolution on this that I'm missing out on.

For reference, this is my code to print "Hello world!" on the OLED screen:

package main

import (
	"time"

	"github.com/tinygo-org/tinygo/src/machine"
	"tinygo.org/x/drivers/ssd1306"
)

func main() {
	// Initialize I2C
	machine.I2C0.Configure(machine.I2CConfig{
		SCL: machine.IO22, 
		SDA: machine.IO21, 
	})

	// Initialize the SSD1306 display
	display := ssd1306.NewI2C(machine.I2C0)
	display.Configure(ssd1306.Config{
		Width:  128,
		Height: 64,
	})

	display.ClearBuffer()
	drawText(&display, 0, 0, "Hello World!")

	display.Display()

	for {
		time.Sleep(time.Second)
	}
}

func drawText(display *ssd1306.Device, x int16, y int16, text string) {
	for i := int16(0); i < int16(len(text)); i++ {
		display.SetPixel(x+i*6, y, 1) // Basic "dot" rendering for each character
	}
}


This is the error message I get:

# github.com/tinygo-org/tinygo/src/machine
../../../../../go/pkg/mod/github.com/tinygo-org/[email protected]/src/machine/machine_esp32_i2c.go:38:16: undefined: SCL_PIN
../../../../../go/pkg/mod/github.com/tinygo-org/[email protected]/src/machine/machine_esp32_i2c.go:41:16: undefined: SDA_PIN
@aykevl
Copy link
Member

aykevl commented Sep 26, 2024

For the ESP32 you need to specify a board, not just -target=esp32.

I don't know what's up with the Arduino Nano, does it produce the same error message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants