Philip Abbey d9ecaf34ee Removed Debug
On some devices it looks like removing the System.println() statements from inside an 'if' clause whose condition is a constant (static constant Globals.scDebug) makes a memory saving. This would suggest the compiler does not propagate constants and prune unreachable code. However in the device of greatest interest debug removal has made no difference to the memory usage. Here the conditional clauses have been turned into comments that can be removed on a case-by-case basis otherwise the debug printing is too voluminous anyway.
2024-01-21 17:53:37 +00:00

51 lines
1.4 KiB
MonkeyC

//-----------------------------------------------------------------------------------
//
// Distributed under MIT Licence
// See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE.
//
//-----------------------------------------------------------------------------------
//
// GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely
// tested on a Venu 2 device. The source code is provided at:
// https://github.com/house-of-abbey/GarminHomeAssistant.
//
// J D Abbey & P A Abbey, 28 December 2022
//
//
// Description:
//
// Quit the application after a period of inactivity in order to save the battery.
//
//-----------------------------------------------------------------------------------
using Toybox.Lang;
using Toybox.Timer;
using Toybox.Application.Properties;
using Toybox.WatchUi;
class QuitTimer extends Timer.Timer {
function initialize() {
Timer.Timer.initialize();
}
function exitApp() as Void {
// System.println("QuitTimer exitApp(): Exiting");
// This will exit the system cleanly from any point within an app.
System.exit();
}
function begin() {
var api_timeout = Settings.getAppTimeout(); // ms
if (api_timeout > 0) {
start(method(:exitApp), api_timeout, false);
}
}
function reset() {
// System.println("QuitTimer reset(): Restarted quit timer");
stop();
begin();
}
}