-
Notifications
You must be signed in to change notification settings - Fork 143
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
Refactor modm:ui:display #604
Conversation
e78637f
to
5db4730
Compare
e4a48a7
to
496c3ab
Compare
6790a1e
to
7119514
Compare
beacdcc
to
64f9d4f
Compare
64f9d4f
to
675d30e
Compare
-> I'm going to create PRs for the two 🙄👆 but let's first get this PR shipped. All interfaces remain the same, except that you have to replace pointers "Color"-control for monochrome Displays is a thing, i want to implement after my planned refactor-color PR is merged (or not ;P) so I struck it from here for now. Would someone please review the commit !? @salkinium ? @rleh ? @chris-durand ? |
675d30e
to
4e88bd4
Compare
4e88bd4
to
06ee7fd
Compare
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.
So far so good!
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.
The ext/modm-devices submodule shouldn't be modified
06ee7fd
to
10e67d9
Compare
e68a1ac
to
69b2f42
Compare
All done. Thanks @chris-durand and @salkinium for your always enriching comments. I did a few more addition improvements you propably want to check. |
69b2f42
to
138fbd3
Compare
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.
I like it a lot!
{ | ||
const int16_t y = start.y / 8; | ||
|
||
// TODO Implement draw / clear pixels for monochrome displays |
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.
What about this?
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.
Postponed. I'm not clear about a good solution yet. nothing is lost, it hasn't worked before.
There's some stuff that interacts with foreground and background color, like writing characters. Also there's already setPixel(), clearPixel()
I fell like there could be a general solution that works with color and monochrome uniformly. but I want to cleanup color first #616 and afterwards spent some time on the ili9341 driver.
When i have nice color-class and a good to read ili9341 driver i want to dive into setting and clearing pixels ;)
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.
One possible solution: Define modm::color::Grayscale witch stores one byte with grayscale value.
For Monochrome, we only need a a boolean - storing Pixel On/Off - nut boolean will anyways consume a full byte.
So why not just using the Grayscale here too? If (value & 0x80) -> Monochrome pixel is On
All the color-types and diplays will be very compatible to each other. You will be able to use the same functions to write a colored image on a color, grayscale or monochrome display (very simplified) if you need to.
class modm::color::Grayscale{
uint8_t value; // Grayscale value
};
But yea... that's just one idea
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.
I think 8-bit grayscale is fine, since it's only an intermediate value anyways and it's a simple solution.
You need have an optimized image format for binary images anyways.
You can convert RGB into grayscale using this formula, however that doesn't necessarily makes sense without dithering (which definitely needs to be done beforehand).
https://github.com/salkinium/upainter/blob/master/doc/surface/README.md#8bpp-grayscale
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.
Cool, I check this tomorrow :)
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.
Update docs? I'm happy with the rest. (and squash pls).
04ac120
to
f27abbd
Compare
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.
A few more touches:
f27abbd
to
22bf657
Compare
Merge? |
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.
Thanks for this good cleanup! Let's squash your commits into one or more with good messages, then we can merge this!
e918ee1
to
8b022a3
Compare
8b022a3
to
295dbc3
Compare
That was a nice warmup. Thanks @salkinium 🌻 and @chris-durand 🌻 for taking me by the hand until these pleassent sessions. By the time (and of course due to the cleanification) i gained more overview about the display API. I did not really wanted to warp all around but... now has taken me over. After some polishing of ssd1306 and ili9341, witch i use as reference hardware, i would love to present plans for and discus "refactor modm:ui:display part 2" ;). Enjoy the days. |
Followup from #601
Color has nothing to do in any of the
MonochromeGraphicDisplay
but it inherits Color fromGraphicDisplay
. ForMonochromeGraphicDisplay
it shouldn't be color but pixel On / Off.New inheritances
GraphicDisplay <-- ColoredGraphicDisplay (Color stuff in here) <-- ILI9341, ,,,
GraphicDisplay <-- MonochromeGraphicDisplay (Light / dark stuff in here) <-- SSD1306, KS0108, ...
ColoredGraphicDisplay
MonochromeGraphicDisplay