This will be a quick tutorial on how to create and deploy an "application" for the Dilbert badge.
Before starting ensure you have the following:
Applications are generally fairly unrestricted as to what they can do with the hardware, however there are a few notable design considerations:
The only thing that is actually enforced is that apps can only run in the foreground, switching applications forces the currently active one to exit and it cannot execute any code until it is the active application again.
The memory allocation is a general good coding practice regardless, the preference of allocating all memory at creation time is to help avoid heap fragmentation from multiple allocations during run time.
When updating the display it can often be faster to only update a subset of the display, I also believe that updating entire rows/columns (one of the two, I can't remember which from memory) is faster due to the way in which the display is addressed. For this reason it is worth only drawing areas of the screen that have actually changed, a good example of this is the App Manager application in which only the selected arrow and the area of the screen it can possibly reside ever has to br redrawn.
AppManagerexample and save a copy of it
create()is called when the app is created, ideally all memory allocation should be performed here
onEntry()is called when the application becomes the foreground application, this should be used for setting the initial state of the application (for example, drawing items to the LCD that will not change throughout the runtime of the application)
run()is called periodically whilst the application is in the foreground, delays can (and often should) be added where possible/required
onExit()is called when the application is no longer the foreground application, this can be used to save the application state or reset any hardware used by the application
destroy()is called when the application is destroyed, all memory allocated in
create()should be freed here
There are a few examples in the library already that can be used as example implementations: