Answer the question
In order to leave comments, you need to log in
How to organize the structure of the graphics library in C for the microcontroller?
The point is.
I am writing my bike for a device with a monochrome graphic display.
I am thinking over the structure of the graphics library for its further use on various platforms.
So far I see it like this:
0) Hardware level - functions that depend on the display interface and the way the microcontroller communicates with it. At this level, I write a send_byte () function that sends data to the physical port of the display.
1) Display driver level - display initialization functions, display clearing functions, data array filling functions in the display, brightness control, etc. All these functions somehow access send_byte () to work with the display itself
2) The "paint" library level - drawing data into a temporary buffer (functions for drawing primitives such as point, line, square, text), a function for updating information on the display from this buffer.
3) "Effect" library level - text animation effects, animation of simple graphics (shift of a point in space, line rotation, etc.)
4) Application level - functions for displaying date, time on the display using all lower layers, functions for displaying text with a scroll, drawing custom graphics.
I made such a partition based on the fact that each layer can be redone for its own tasks. For example, to transfer from one MK architecture to another, only layer 0 needs to be fixed.
When changing the display, only layer 1
When modifying animation, we only touch layer 3
When new tasks arise (for example, drawing controls) - only layer 4
, etc.
Question: Am I doing it right or am I missing something?
PS Ready-made libraries can not be taken.
Answer the question
In order to leave comments, you need to log in
That's right, but you also need to understand that the library is written under MK, which has very limited memory. It may happen that your mega-cool library will take up all the memory and will be terribly slow.
It may make sense to describe the general algorithm of each level and implement it by optimizing for each individual MK and display, in fact there are not so many of them and not all of them will fall into your hands
1. functions for drawing buttons, menus, radio buttons, drop-down lists and other entities where?
2. input devices, pointers, cursors where?
3. Is there any event handling from input/emulation devices?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question