One of the core classes in the Vortex Manipulator is Hardware.cpp which acts as an interface to almost all the hardware. Almost because the graphics library is called directly and SD file operations are too.
But because of the possibility that the underlying hardware might change it seemed prudent to have this class hold all the rest of the hardware related calls. So what's in here?
init()
not surprisingly this is the method that initialises everything. It included initialisation for the SD and the graphics too, even though the rest of the time they are called directly.siren()
and PlayTone()
, which play standard noised on the speaker using the tone()
library. However the HeartRateInterrupt calls tone()
directly, not through Hardware.read16()
and read32()
are used by Gallery to read graphics files.dateString()
and timeString()
return printable strings with date and time values.getBatteryVoltage()
queries the voltage on pin A0 (or 14) and scales it to a voltage. This is the battery voltage displayed on the menu.It is worth saying a little more about sleep and wake functions because there are two kinds of sleep.
sleep()
is a soft sleep. The graphics are turned off, including the backlight, and the compass is shut down. This is triggered when you put your wrist down so the screen isn't glowing when you aren't looking at it. The opposite function: wake()
is triggered when you lift your wrist up to look at the screen. Naturally in light sleep the device is still listening for gestures and touch.
shutdown()
is a deeper sleep. This is triggered by the Sleep app and it shuts down everything, including the processor. So there is no gesture handling or heart rate monitored. You wake it by pressing the button. It is interesting that when the button is pressed the shutdown()
method continues from where it went to sleep, but some things need to be reinitialised.