Display abstraction interface
See original GitHub issueI’ve noticed all the various displays have different methods exposed to work with them. I’d like to suggest an interface (or abstract base class) is provided for all of them, so we can write common code, and quickly swap out the display used in our code, without having to change anything but the display creation. I’ve found that I’d often change displays to something better, and having rewrite quite a lot of code because of it, and it would also make it easier for people to adapt existing code and apps for the display they have.
For instance it’s pretty typical that there’s a method for SendBitmap(Bitmap)
, ClearScreen()
and FillRect(Color,Rectangle
)`, and it would be nice to be able to write display-agnostic code against all of these. It would also allow us to build a common text and line drawing API for all of these.
The interface would also need a few getters to get display info like width/height, bit depth, etc, information about whether there’s on/off control (and if so methods for doing that).
Describe the ideal solution
Suggestion for interface
public interface IDisplay
{
void SendBitmap(Bitmap bmp);
void FillRect(Color color, Rectangle rect);
void ClearScreen();
Task ResetScreenAsync();
void SetDisplayOn();
void SetDisplayOff();
bool IsDisplayOnOffSupported() { get; }
ushort Width { get; }
ushort Height { get; }
byte BitsPerPixel { get; }
bool IsColorDisplay { get; }
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:13 (13 by maintainers)
Top GitHub Comments
Just want to put on the table that we could also start with an existing API/implementation and morph it to what we want. There is a mid-point between “start from scratch” and “use an existing package”.
@maloo I think this is the wrong ticket. You’re looking for #1832. Work on this has been started.