Skip to content

Commit aa931d9

Browse files
committed
Add settings.openMenuWithPrintable - accessible from the "d" debug menu
1 parent 6d2a730 commit aa931d9

File tree

7 files changed

+50
-14
lines changed

7 files changed

+50
-14
lines changed

Firmware/OpenLog_Artemis/OpenLog_Artemis.ino

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,16 @@
135135
136136
v2.3:
137137
Resolve https://forum.sparkfun.com/viewtopic.php?f=171&t=58109
138-
138+
139+
v2.4:
140+
Add noPowerLossProtection to the main branch
141+
Add changes by KDB: If we are streaming to Serial, start the stream with a Mime Type marker, followed by CR
142+
Add debug option to only open the menu using a printable character: based on https://github.com/sparkfun/OpenLog_Artemis/pull/125
139143
140144
*/
141145

142146
const int FIRMWARE_VERSION_MAJOR = 2;
143-
const int FIRMWARE_VERSION_MINOR = 3;
147+
const int FIRMWARE_VERSION_MINOR = 4;
144148

145149
//Define the OLA board identifier:
146150
// This is an int which is unique to this variant of the OLA and which allows us
@@ -150,7 +154,7 @@ const int FIRMWARE_VERSION_MINOR = 3;
150154
// the variant * 0x100 (OLA = 1; GNSS_LOGGER = 2; GEOPHONE_LOGGER = 3)
151155
// the major firmware version * 0x10
152156
// the minor firmware version
153-
#define OLA_IDENTIFIER 0x123 // Stored as 291 decimal in OLA_settings.txt
157+
#define OLA_IDENTIFIER 0x124 // Stored as 292 decimal in OLA_settings.txt
154158

155159
//#define noPowerLossProtection // Uncomment this line to disable the sleep-on-power-loss functionality
156160

@@ -206,10 +210,6 @@ enum returnStatus {
206210
STATUS_PRESSED_X,
207211
};
208212

209-
//Header
210-
void beginSD(bool silent = false);
211-
void beginIMU(bool silent = false);
212-
213213
//Setup Qwiic Port
214214
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
215215
#include <Wire.h>
@@ -337,8 +337,6 @@ char serialTimestamp[40]; //Buffer to store serial timestamp, if needed
337337
volatile static bool powerLossSeen = false; //Flag to indicate if a power loss event has been seen
338338
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
339339

340-
uint8_t getByteChoice(int numberOfSeconds, bool updateDZSERIAL = false); // Header
341-
342340
// gfvalvo's flash string helper code: https://forum.arduino.cc/index.php?topic=533118.msg3634809#msg3634809
343341
void SerialPrint(const char *);
344342
void SerialPrint(const __FlashStringHelper *);
@@ -566,7 +564,7 @@ void setup() {
566564
//If we are immediately going to go to sleep after the first reading then
567565
//first present the user with the config menu in case they need to change something
568566
if (checkIfItIsTimeToSleep())
569-
menuMain();
567+
menuMain(true); // Always open the menu - even if there is nothing in the serial buffers
570568
}
571569

572570
void loop() {

Firmware/OpenLog_Artemis/Sensors.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99

1010
void printHelperText(uint8_t);
1111
void getData(char *buffer, size_t lenBuffer);
12-
12+
uint8_t getByteChoice(int numberOfSeconds, bool updateDZSERIAL = false);
13+
void menuMain(bool alwaysOpen = false);
14+
void beginSD(bool silent = false);
15+
void beginIMU(bool silent = false);

Firmware/OpenLog_Artemis/menuDebug.ino

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ void menuDebug()
1717
if (settings.printGNSSDebugMessages == true) SerialPrintln(F("Enabled"));
1818
else SerialPrintln(F("Disabled"));
1919

20+
SerialPrint(F("4) Only Open Main Menu With Printable Char: "));
21+
if (settings.openMenuWithPrintable == true) SerialPrintln(F("Yes"));
22+
else SerialPrintln(F("No"));
23+
2024
SerialPrintln(F("x) Exit"));
2125

2226
byte incoming = getByteChoice(menuTimeout); //Timeout after x seconds
@@ -46,10 +50,14 @@ void menuDebug()
4650
settings.resetOnZeroDeviceCount ^= 1;
4751
}
4852
}
49-
else if (incoming == '3')
53+
else if (incoming == '3')
5054
{
5155
settings.printGNSSDebugMessages ^= 1;
5256
}
57+
else if (incoming == '4')
58+
{
59+
settings.openMenuWithPrintable ^= 1;
60+
}
5361
else if (incoming == 'x')
5462
break;
5563
else if (incoming == STATUS_GETBYTE_TIMEOUT)

Firmware/OpenLog_Artemis/menuMain.ino

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,28 @@
44

55
//Display the options
66
//If user doesn't respond within a few seconds, return to main loop
7-
void menuMain()
7+
void menuMain(bool alwaysOpen)
88
{
99
bool restartIMU = false;
10+
11+
if (settings.openMenuWithPrintable) // If settings.openMenuWithPrintable is true, eat the first character. Return if < 9 (Tab)
12+
{
13+
if ((settings.useTxRxPinsForTerminal == true) && (Serial1.available()))
14+
{
15+
uint8_t firstChar = Serial1.read();
16+
if (firstChar < 9)
17+
return;
18+
}
19+
else if (Serial.available())
20+
{
21+
uint8_t firstChar = Serial.read();
22+
if (firstChar < 9)
23+
return;
24+
}
25+
else if (!alwaysOpen)
26+
return;
27+
}
28+
1029
while (1)
1130
{
1231
SerialPrintln(F(""));

Firmware/OpenLog_Artemis/nvm.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ void recordSystemSettingsToFile()
181181
settingsFile.println("identifyBioSensorHubs=" + (String)settings.identifyBioSensorHubs);
182182
settingsFile.println("serialTxRxDuringSleep=" + (String)settings.serialTxRxDuringSleep);
183183
settingsFile.println("printGNSSDebugMessages=" + (String)settings.printGNSSDebugMessages);
184+
settingsFile.println("openMenuWithPrintable=" + (String)settings.openMenuWithPrintable);
184185
updateDataFileAccess(&settingsFile); // Update the file access time & date
185186
settingsFile.close();
186187
}
@@ -464,6 +465,8 @@ bool parseLine(char* str) {
464465
settings.serialTxRxDuringSleep = d;
465466
else if (strcmp(settingName, "printGNSSDebugMessages") == 0)
466467
settings.printGNSSDebugMessages = d;
468+
else if (strcmp(settingName, "openMenuWithPrintable") == 0)
469+
settings.openMenuWithPrintable = d;
467470
else
468471
{
469472
SerialPrintf2("Unknown setting %s. Ignoring...\r\n", settingName);

Firmware/OpenLog_Artemis/settings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ struct struct_settings {
423423
unsigned long minimumAwakeTimeMillis = 0; // Set to greater than zero to keep the Artemis awake for this long between sleeps
424424
bool identifyBioSensorHubs = false; // If true, Bio Sensor Hubs (Pulse Oximeters) will be included in autoDetect (requires exclusive use of pins 32 and 11)
425425
bool serialTxRxDuringSleep = false; // If true, the Serial Tx and Rx pins are left enabled during sleep - to prevent the COM port reinitializing
426-
bool printGNSSDebugMessages = false;
426+
bool printGNSSDebugMessages = false; // If true, the GNSS library debug messages are enabled
427+
bool openMenuWithPrintable = false; // If true, only a printable char can open the main menu. Chars < 9 (Tab) are ignored
427428
} settings;
428429

429430
//These are the devices on board OpenLog that may be on or offline.

Firmware/OpenLog_Artemis/support.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2+
3+
#include "Sensors.h"
4+
15
bool useRTCmillis(void)
26
{
37
return (((settings.useGPIO11ForTrigger == false) && (settings.usBetweenReadings >= maxUsBeforeSleep))

0 commit comments

Comments
 (0)