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

Retrieve supported display modes for device #155

Open
thijstriemstra opened this issue Jan 13, 2019 · 3 comments
Open

Retrieve supported display modes for device #155

thijstriemstra opened this issue Jan 13, 2019 · 3 comments
Assignees

Comments

@thijstriemstra
Copy link
Collaborator

thijstriemstra commented Jan 13, 2019

Would be nice to have a unified API that returns the supported display modes for a certain device. Right now these values are hardcoded and impossible to retrieve, e.g.

@thijstriemstra
Copy link
Collaborator Author

thijstriemstra commented Jan 13, 2021

@rm-hull I was thinking about something like a get_supported_modes() (or sizes) method on luma.core.device.device that returns whatever dimensions the luma device type supports.

For example, for luma.lcd.device.st7735, get_supported_modes() would currently return:

[(160, 80), (160, 128), (128, 128)]

For luma.oled.device.sh1106 it would have to include some extra data or we need to remap this dict action going on there:

{
    (128, 128): dict(multiplex=0xFF, displayoffset=0x02),
    (128, 64): dict(multiplex=0x3F, displayoffset=0x00),
    (128, 32): dict(multiplex=0x20, displayoffset=0x0F)
}

Like the previous example, it should return a list:

[(128, 128), (128, 64), (128, 32)]

but with some more metadata, so not a tuple but perhaps a dict with width/height keys?

Thoughts?

@rm-hull
Copy link
Owner

rm-hull commented Jan 13, 2021

What or how would you make use of get_supported_modes()?

I think in principle, yes we could readily add that to every device class (possibly as a class method?) but I’m wondering how a program could actually make use of it, because mostly if you have a display you almost certainly know up-front what the size is.

@thijstriemstra
Copy link
Collaborator Author

thijstriemstra commented Jan 13, 2021

I would use it in the luma.examples, and show what sizes are supported in the error message. And yea overall it's cleaner to have it in a central place, I often check the source code what sizes are supported and having it in a general place across all luma devices would be nice.

It's actually surprising to me that not having it central/in place since day one, and that it's an afterthought in the API. I guess this indicates it also not as important to have but still.

It's mostly a refactor thing to make things uniform.

@thijstriemstra thijstriemstra self-assigned this Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants