Skip to content

ssd1306: avoid unnecessary heap allocations #767

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

Draft
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

ysoldak
Copy link
Contributor

@ysoldak ysoldak commented Jun 19, 2025

This re-uses internal buffer to avoid unnecessary heap allocations in ssd1306 driver; switches away from the legacy I2C interface.

See similar: #766

Draft since not tested

@soypat
Copy link
Contributor

soypat commented Jun 20, 2025

It is seems to me Buser should have a command() method to avoid the big buffer juggling since commands always write a single byte.

type Buser interface {
    // ... other methods
    command(cmd byte) error
}
func (b *I2CBus) command(cmd byte) error {
	b.cmdbuf[0] = 0x00 // cmdbuf is only length 2 on I2CBus since SPI does some DC pin stuff. in place of 0x40/0x00 byte
	b.cmdbuf[1]= cmd 
	return b.wire.Tx(b.Address,b.cmdbuf[:],nil)
}

This will likely make it much more readable and easier to understand

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

Successfully merging this pull request may close these issues.

2 participants