-
Notifications
You must be signed in to change notification settings - Fork 83
Implement DisplayMode and DisplayTrait for better mode handling #40
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
Implement DisplayMode and DisplayTrait for better mode handling #40
Conversation
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
|
@jamwaffles Putting this out there to get some feedback. I was hoping that there was a generic way to use |
|
So I've had a quick play around with this and I seem to have been able to get rid of the |
|
Can the mode still be switched at a later point? Specifying the mode is quite okay for me because that's exactly what a user should do, I'd rather try to get rid of other noise (like specifying the DisplayInterface all the time). |
|
The idea behind the trait is to have a common interface that would allow to easily implement new modes and have a guaranteed API for this. |
|
Sorry, was half way through typing this when you commented so I'll post it as a FWIW: I've also managed to nicely fix the I've also just readded into_graphicsmode().
Haven't tested yet! I'll implement a dummy mode and see how far I get.
Where do you mean? In the driver or in application code?
Right, of course! I'll keep playing... there's still the naming problem. I'll try and think of something. |
Uhm... :-D
That's specifically what I wanted to get rid of: It's not scalable (requires methods in every mode for every other available mode) and does not allow for custom modes.
Everywhere, I find it a major PITA to manage all the different generics and bounds plus if you get a small detail wrong it's really easy to get a crapload of non-saying errors (it actually is a lot more readable when rendered by GH compared to a terminal): |
|
The diff was supposed to show that I had removed the I see your point, it's ok for maybe two modes but for any more than that it gets unwieldy. That said, aren't we going to have to do some sort of "web of I found those error messages earlier. They're just awful. |
Well, in my version there's both a struct and a trait. Maybe we can get rid of the struct and pack the
I was kind of hoping we could find a neat trick with with the trait types/states that would automatically change the interface to whatever type the DisplayMode is in, similarly as we do it with the GPIO pins in the
The point of the trait was/is that all concrete modes provide the same I really haven't had much luck with the But every attempt I'm going after takes forever just to dance around the |
|
I've been trying to write something nice using I like the idea of the common trait having Also, I still like the cleanliness of not having to define a spaghetti type for |
|
I managed to make the However what's missing is the automatic coercion from But again that prevents later mode changes... |
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
|
Looking good! I was going through the diff and didn't see a Could you Would |
|
Out of curiosity, what are you use cases for switching mode on the fly? I'm thinking something like exception handling where you can switch the display into char mode and print a message but I might be off the mark there. It's something I'd like to support, but to keep this PR rolling if it means implementing a web of |
There're two options: Turning into a
Nope and nope. 😉 I cannot impl either
Yes! But I cannot make it work. 🙁
I haven't really though about it. Just thought it would be nice to have.
Hm, I maybe I can implement the same trick I did with the into from |
Nope, doesn't seem so. :( |
|
Shame :(. I'd rather add an API method in the future that's right than add one now that we'll have to break later. I think we should reduce the scope of this feature a bit and just focus on a clean P.s. I've pushed a couple of small hotfixes to master so you'll have to rebase again, sorry. |
|
Should be all there? |
jamwaffles
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah looks like it :) shame it didn't work out perfectly but I like the .into() changes.
Signed-off-by: Daniel Egger daniel@eggers-club.de