From 878f509e4b5741684ad577edb2b804853e47b458 Mon Sep 17 00:00:00 2001
From: Bertrand Lemasle <blemasle@gmail.com>
Date: Sun, 18 Mar 2018 12:34:03 +1300
Subject: [PATCH] Reduced sleeping time for debugging purpose, and menu timeout
 is not effective after first command

---
 GpsTracker/Config.h       | 13 +++++++++++--
 GpsTracker/GpsTracker.ino | 10 +++++++---
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/GpsTracker/Config.h b/GpsTracker/Config.h
index 9250b83..d42180b 100644
--- a/GpsTracker/Config.h
+++ b/GpsTracker/Config.h
@@ -53,7 +53,7 @@ struct config_t {
 namespace config {
 
 	static const sleepTimings_t defaultSleepTimings[] PROGMEM = {
-	{ 5, SLEEP_DEFAULT_TIME_SECONDS },
+	/*{ 5, SLEEP_DEFAULT_TIME_SECONDS },
 	{ 10, 1200 },
 	{ 20, 600 },
 	{ 30, 540 },
@@ -61,8 +61,17 @@ namespace config {
 	{ 80, 240 },
 	{ 100, 210 },
 	{ 180, 180 },
-	};
+	};*/
 
+	{ 5, 600 },
+	{ 10, 600 },
+	{ 20, 600 },
+	{ 30, 540 },
+	{ 50, 480 },
+	{ 80, 240 },
+	{ 100, 210 },
+	{ 180, 180 },
+	};
 	namespace main {
 		extern config_t value;
 
diff --git a/GpsTracker/GpsTracker.ino b/GpsTracker/GpsTracker.ino
index 8d55721..0b908c8 100644
--- a/GpsTracker/GpsTracker.ino
+++ b/GpsTracker/GpsTracker.ino
@@ -2,12 +2,13 @@
 #include "Positions.h"
 
 #if _DEBUG
-#define MENU_TIMEOUT 0
+#define MENU_DEFAULT_TIMEOUT 0
 #else
-#define MENU_TIMEOUT 0
+#define MENU_DEFAULT_TIMEOUT 5000
 
 #endif
 bool bypassMenu = false;
+uint16_t menuTimeout = MENU_DEFAULT_TIMEOUT;
 
 void setup() {
 	logging::setup();
@@ -22,7 +23,10 @@ void setup() {
 void loop() {
 
 	debug::GPSTRACKER_DEBUG_COMMAND command = debug::GPSTRACKER_DEBUG_COMMAND::RUN;
-	if (Serial && !bypassMenu) command = debug::menu(MENU_TIMEOUT);
+	if (Serial && !bypassMenu) command = debug::menu(menuTimeout);
+
+	if (command == debug::GPSTRACKER_DEBUG_COMMAND::RUN) bypassMenu = true;
+	else menuTimeout = 0; //disable timeout once a command has been entered
 
 	bypassMenu = command == debug::GPSTRACKER_DEBUG_COMMAND::RUN;