... | ... | @@ -19,23 +19,39 @@ what is going on, so they have a chance to respond appropriately. An |
|
|
example of action that results in event reception is a button press or
|
|
|
sensor interrupt. Afterwards, you may decide to redraw a part of user
|
|
|
interface, update internal state or save data - depending on what has
|
|
|
happened. Available event types are listed in src/sw/common/event.h.
|
|
|
happened. Available event types are listed in.
|
|
|
Events are transferred from the operating system to applications via
|
|
|
queue. Typically, there is one main loop that receives them and lets you
|
|
|
decide what should happen next.
|
|
|
queue. Typically, there is one main event loop that receives them and
|
|
|
lets you decide what should happen next. The event loop also allows you
|
|
|
to react if there are no events for a specified period of time.
|
|
|
If you expect events from sensors, you should configure them to generate
|
|
|
interrupts. Enabling unnecessary interrupt sources results in redundant
|
|
|
events and may decrease both performance and battery life. It is a good
|
|
|
practice to react only to events that you expect and really handle in
|
|
|
the code.
|
|
|
the code.
|
|
|
In the provided example there are only two types of events, but you
|
|
|
should expect more in the final version.
|
|
|
|
|
|
#### Widgets
|
|
|
|
|
|
Widgets are parts of the graphical user interface, such as buttons,
|
|
|
checkboxes, scrollbars, etc. They have a visible representation and are
|
|
|
expected to react to events.
|
|
|
|
|
|
Do not forget to add the new file to Makefile.
|
|
|
expected to react to events. That is the reason why they are described
|
|
|
by a structure (*struct ui\_widget*) that contains:
|
|
|
|
|
|
1. Drawing routine - code that describe appearance.
|
|
|
2. Event handler - processes received events.
|
|
|
3. Dimensions - contain the location and size of a widget.
|
|
|
4. Surface - canvas used for drawing.
|
|
|
5. Flags - indicate the internal state.
|
|
|
You may create a single widget that handles all events and then
|
|
|
redraws everything, but it could be easier to manage more smaller
|
|
|
widgets that have a single task to perform.
|
|
|
If you think that widget that you have just created could be of any
|
|
|
use for others, please put it to folder
|
|
|
sw/freertos/src/apps/widgets. There you may also find source code
|
|
|
for the status bar, that is expected to be displayed by most of the
|
|
|
applications.
|
|
|
|
|
|
### Menu entry
|
|
|
|
... | ... | |