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

ssd1306: Displayer interface improvements #665

Closed
wants to merge 2 commits into from

Conversation

deadprogram
Copy link
Member

This PR is to implement the pixel package based interface for the SSD1306 display.

@aykevl
Copy link
Member

aykevl commented Mar 2, 2024

Does this display support any other pixel formats than the one monochrome pixel format?
If not, I would suggest not using generics and simply using DrawBitmap(x, y int16, bitmap pixel.Image[pixel.MonochromeVertical]) error. This will still match the generic interface in TinyGL.
(If needed, it's relatively simple to change the ssd1306 driver to be generic in the future without breaking backwards compatibility).

Comment on lines +285 to +295
d.Command(COLUMNADDR)
d.Command(d.resetCol[0] + uint8(x))
d.Command(d.resetCol[0] + uint8(x) + uint8(w) - 1)

// TODO: handle when the bitmap is not aligned to 8 vertical pixels
d.Command(PAGEADDR)
d.Command((d.resetPage[0] + uint8(y)) / 8)
d.Command((d.resetPage[0] + uint8(y) + uint8(h)) / 8)

d.Tx(bitmap.RawBuffer(), false)
return nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a prototype it may be easier to go through the bitmap and set it manually:

width, height := bitmap.Size()
for by := 0; by < height; by++ {
    for bx := 0; bx < width; bx++ {
        d.SetPixel(x+bx, y+by, bitmap.Get(bx, by).RGBA())
    }
}

It'll be slower than necessary but it has a good chance of actually working.

@deadprogram
Copy link
Member Author

Closing since #663 and #671 are doing this better.

@deadprogram deadprogram deleted the ssd1306-display-improvements branch April 21, 2024 09:54
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