I'm assuming you will want to change the VM software, or add your own stuff to it, and it is designed to make that possible. Not necessarily easy, but this post will help. You do need to know enough C++ to get something compiled and we already covered how to set up the development environment.
The VM software is divided into apps: Clock, Compass, Dalek Detector, Gallery, Graphics, Heart, Notifications, Set Clock and Sleep. Each of those is a class that extends the App class. They self-register with the AppRegistry and that is what the menu (another class) uses to present all the options.
Let's start with something easy. The Gallery app reads images off the SD card. You will find a copy of the files I put on my own SD card in the project (under SDBackup). You can replace those images with your own. You just need to make your images into 240x320 BMP files. Copy the resulting files to your SD card, push the card into the slot on the main board and you are ready to display images like this one:
Now let's take a look at that Gallery app's code. In the Gallery.h file you'll find that it extends the App class which means it needs to implement the following methods:
void init()
does any initialisation needed. This inevitably includes loading the icon for the menu. Icons are discussed later.void setup()
is called whenever we invoke the app from the menu. Gallery uses this to establish the list of image files and display the first one.boolean touch(TS_Point ps)
is called when the screen detects a touch and it passes the point that was touched. All Gallery does is move to the next image regardless of where it was pressed. If this method returns false we go back to the menu, and this is what Gallery does when it runs out of images.void display()
is called when the app should redisplay. This is decided by the interval set by...unsigned long getUpdateInterval()
returns the number of milliseconds between updates. Gallery does not need to update very often because it is user driven. Other apps such as Compass and Clock update more frequently.const char* getName()
returns the name of the app.That is the basic structure of an app.
Each app needs an icon to display on the menu. Making one of these is a bit tricky and I covered the details this post. The shorter version is that I create a 28x28 pixel image in Gimp and export it as a .h file, then I process that with some logic (in the MakeIcons program referred to in that post) and finally paste the results into the app code.
You end up with a lot of hex values which we can use to define the image in an array which we eventually load into m_icon
, a variable defined in the App class. App and Menu take care of displaying the icon on the menu. An important point to remember is that the icon is held in the app class, not in the menu. It makes the apps more self contained. In the same way we also add this at the end of the Gallery.cpp file:
App *gallery = new Gallery();
Instantiating the class causes it to register with the AppRegister which is what the Menu uses to display the options. The menu does its best to fit everything on the screen but there are, after all, only so many rows and columns. It is probably possible to have menu display a second page of options but that is not in this code. So if you want to add another app you'll need to remove one of the ones already there, or rework the menu.
This is about how the app software works. Each of the VM functions is implemented in an app and this post took us through the Gallery app and added some information about icons.