Skip to content

Commit f04b614

Browse files
committed
Add support for yyyy/mm/dd and ISO 8601 date. Add fix for Serial.end.
Add support for missing / not-populated IMU. Note: we're not out of the woods yet... The IMU is not restarting after sleep. More changes to follow!
1 parent ff69c89 commit f04b614

File tree

8 files changed

+78
-34
lines changed

8 files changed

+78
-34
lines changed

Firmware/OpenLog_Artemis/OpenLog_Artemis.ino

+10-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
1414
The Board should be set to SparkFun Apollo3 \ RedBoard Artemis ATP.
1515
16-
Please note: this version of the firmware compiles on v2.1.0 of the Apollo3 boards.
17-
18-
(At the time of writing, data logging with the the u-blox ZED-F9P is problematic when using v2.1.1 of the core.)
19-
2016
v1.0 Power Consumption:
2117
Sleep between reads, RTC fully charged, no Qwiic, SD, no USB, no Power LED: 260uA
2218
10Hz logging IMU, no Qwiic, SD, no USB, no Power LED: 9-27mA
@@ -112,10 +108,17 @@
112108
(done) Add a fix for issue #109 - check if a BME280 is connected before calling multiplexerBegin: https://github.com/sparkfun/OpenLog_Artemis/issues/109
113109
(done) Correct issue #104. enableSD was redundant. The microSD power always needs to be on if there is a card inserted, otherwise the card pulls
114110
the SPI lines low, preventing communication with the IMU: https://github.com/sparkfun/OpenLog_Artemis/issues/104
111+
112+
v2.2:
113+
Use Apollo3 v2.2.0 with changes by paulvha to fix Issue 117 (Thank you Paul!)
114+
https://github.com/sparkfun/OpenLog_Artemis/issues/117#issuecomment-1034973065
115+
Use SdFat v2.1.2
116+
Compensate for missing / not-populated IMU
117+
Add support for yyyy/mm/dd and ISO 8601 date style (Issue 118)
115118
*/
116119

117120
const int FIRMWARE_VERSION_MAJOR = 2;
118-
const int FIRMWARE_VERSION_MINOR = 1;
121+
const int FIRMWARE_VERSION_MINOR = 2;
119122

120123
//Define the OLA board identifier:
121124
// This is an int which is unique to this variant of the OLA and which allows us
@@ -125,7 +128,7 @@ const int FIRMWARE_VERSION_MINOR = 1;
125128
// the variant * 0x100 (OLA = 1; GNSS_LOGGER = 2; GEOPHONE_LOGGER = 3)
126129
// the major firmware version * 0x10
127130
// the minor firmware version
128-
#define OLA_IDENTIFIER 0x121 // Stored as 289 decimal in OLA_settings.txt
131+
#define OLA_IDENTIFIER 0x122 // Stored as 290 decimal in OLA_settings.txt
129132

130133
#include "settings.h"
131134

@@ -448,7 +451,7 @@ void setup() {
448451
else SerialPrintln(F("Serial logging offline"));
449452

450453
if (online.IMU == true) SerialPrintln(F("IMU online"));
451-
else SerialPrintln(F("IMU offline"));
454+
else SerialPrintln(F("IMU offline - or not present"));
452455

453456
if (settings.logMaxRate == true) SerialPrintln(F("Logging analog pins at max data rate"));
454457

Firmware/OpenLog_Artemis/Sensors.ino

+8-2
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,18 @@ void gatherDeviceValues()
299299
else
300300
sprintf(gnssMonthStr, "%d", gnssMonth);
301301
sprintf(gnssYearStr, "%d", gnssYear);
302-
if (settings.americanDateStyle == true)
302+
if (settings.dateStyle == 0)
303303
{
304304
sprintf(tempData, "%s/%s/%s,", gnssMonthStr, gnssDayStr, gnssYearStr);
305305
}
306-
else
306+
else if (settings.dateStyle == 1)
307+
{
307308
sprintf(tempData, "%s/%s/%s,", gnssDayStr, gnssMonthStr, gnssYearStr);
309+
}
310+
else // if (settings.dateStyle == 2)
311+
{
312+
sprintf(tempData, "%s/%s/%s,", gnssYearStr, gnssMonthStr, gnssDayStr);
313+
}
308314
strcat(outputData, tempData);
309315
}
310316
if (nodeSetting->logTime)

Firmware/OpenLog_Artemis/lowerPower.ino

+5-6
Original file line numberDiff line numberDiff line change
@@ -318,16 +318,16 @@ void goToSleep(uint32_t sysTicksToSleep)
318318
am_hal_gpio_pinconfig(PIN_QWIIC_SCL , g_AM_HAL_GPIO_DISABLE);
319319

320320
//If requested, disable pins 48 and 49 (UART0) to stop them back-feeding the CH340
321-
if (settings.serialTxRxDuringSleep == false)
322-
{
321+
if (settings.serialTxRxDuringSleep == false)
322+
{
323323
am_hal_gpio_pinconfig(48 , g_AM_HAL_GPIO_DISABLE); //TX0
324324
am_hal_gpio_pinconfig(49 , g_AM_HAL_GPIO_DISABLE); //RX0
325325
if (settings.useTxRxPinsForTerminal == true)
326326
{
327-
am_hal_gpio_pinconfig(12 , g_AM_HAL_GPIO_DISABLE); //TX1
328-
am_hal_gpio_pinconfig(13 , g_AM_HAL_GPIO_DISABLE); //RX1
327+
am_hal_gpio_pinconfig(12 , g_AM_HAL_GPIO_DISABLE); //TX1
328+
am_hal_gpio_pinconfig(13 , g_AM_HAL_GPIO_DISABLE); //RX1
329329
}
330-
}
330+
}
331331

332332
//Make sure PIN_POWER_LOSS is configured as an input for the WDT
333333
pinMode(PIN_POWER_LOSS, INPUT); // BD49K30G-TL has CMOS output and does not need a pull-up
@@ -475,7 +475,6 @@ void wakeFromSleep()
475475
pin_config(PinName(48), g_AM_BSP_GPIO_COM_UART_TX);
476476
pin_config(PinName(49), g_AM_BSP_GPIO_COM_UART_RX);
477477
}
478-
479478

480479
//Re-enable CIPO, COPI, SCK and the chip selects but may as well leave ICM_INT disabled
481480
pin_config(PinName(PIN_SPI_CIPO), g_AM_BSP_GPIO_IOM0_MISO);

Firmware/OpenLog_Artemis/menuMain.ino

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ void menuMain()
1212

1313
SerialPrintln(F("2) Configure Time Stamp"));
1414

15-
SerialPrintln(F("3) Configure IMU Logging"));
15+
if (online.IMU)
16+
SerialPrintln(F("3) Configure IMU Logging"));
1617

1718
if (settings.useTxRxPinsForTerminal == false)
1819
SerialPrintln(F("4) Configure Serial Logging"));
@@ -42,7 +43,7 @@ void menuMain()
4243
menuLogRate();
4344
else if (incoming == '2')
4445
menuTimeStamp();
45-
else if (incoming == '3')
46+
else if ((incoming == '3') && (online.IMU))
4647
restartIMU = menuIMU();
4748
else if ((incoming == '4') && (settings.useTxRxPinsForTerminal == false))
4849
menuSerialLogging();

Firmware/OpenLog_Artemis/menuTimeStamp.ino

+11-5
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ void menuTimeStamp()
2323
sprintf(rtcYear, "200%d", myRTC.year);
2424
else
2525
sprintf(rtcYear, "20%d", myRTC.year);
26-
if (settings.americanDateStyle == true)
26+
if (settings.dateStyle == 0)
2727
sprintf(rtcDate, "%s/%s/%s,", rtcMonth, rtcDay, rtcYear);
28-
else
28+
else if (settings.dateStyle == 1)
2929
sprintf(rtcDate, "%s/%s/%s,", rtcDay, rtcMonth, rtcYear);
30+
else
31+
sprintf(rtcDate, "%s/%s/%s,", rtcYear, rtcMonth, rtcDay);
3032

3133
SerialPrint(rtcDate);
3234
SerialPrint(F(" "));
@@ -79,8 +81,10 @@ void menuTimeStamp()
7981
SerialPrintln(F("4) Manually set RTC date"));
8082

8183
SerialPrint(F("5) Toggle date style: "));
82-
if (settings.americanDateStyle == true) SerialPrintln(F("mm/dd/yyyy"));
83-
else SerialPrintln(F("dd/mm/yyyy"));
84+
if (settings.dateStyle == 0) SerialPrintln(F("mm/dd/yyyy"));
85+
else if (settings.dateStyle == 1) SerialPrintln(F("dd/mm/yyyy"));
86+
else if (settings.dateStyle == 2) SerialPrintln(F("yyyy/mm/dd"));
87+
else SerialPrintln(F("ISO 8601"));
8488
}
8589

8690
if (settings.logTime == true)
@@ -181,7 +185,9 @@ void menuTimeStamp()
181185
}
182186
else if (incoming == 5)
183187
{
184-
settings.americanDateStyle ^= 1;
188+
settings.dateStyle += 1;
189+
if (settings.dateStyle == 4)
190+
settings.dateStyle = 0;
185191
}
186192
}
187193

Firmware/OpenLog_Artemis/nvm.ino

+5-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void recordSystemSettingsToFile()
125125
settingsFile.println("logRTC=" + (String)settings.logRTC);
126126
settingsFile.println("logHertz=" + (String)settings.logHertz);
127127
settingsFile.println("correctForDST=" + (String)settings.correctForDST);
128-
settingsFile.println("americanDateStyle=" + (String)settings.americanDateStyle);
128+
settingsFile.println("dateStyle=" + (String)settings.dateStyle);
129129
settingsFile.println("hour24Style=" + (String)settings.hour24Style);
130130
settingsFile.println("serialTerminalBaudRate=" + (String)settings.serialTerminalBaudRate);
131131
settingsFile.println("serialLogBaudRate=" + (String)settings.serialLogBaudRate);
@@ -348,8 +348,10 @@ bool parseLine(char* str) {
348348
settings.logHertz = d;
349349
else if (strcmp(settingName, "correctForDST") == 0)
350350
settings.correctForDST = d;
351-
else if (strcmp(settingName, "americanDateStyle") == 0)
352-
settings.americanDateStyle = d;
351+
else if (strcmp(settingName, "dateStyle") == 0)
352+
settings.dateStyle = d;
353+
else if (strcmp(settingName, "americanDateStyle") == 0) // Included for backward-compatibility
354+
settings.dateStyle = d;
353355
else if (strcmp(settingName, "hour24Style") == 0)
354356
settings.hour24Style = d;
355357
else if (strcmp(settingName, "serialTerminalBaudRate") == 0)

Firmware/OpenLog_Artemis/settings.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ struct struct_settings {
364364
bool logRTC = true;
365365
bool logHertz = true;
366366
bool correctForDST = false;
367-
bool americanDateStyle = true;
367+
int dateStyle = 0; // 0 : mm/dd/yyyy, 1 : dd/mm/yyyy, 2 : yyyy/mm/dd, 3 : ISO8601 (date and time)
368368
bool hour24Style = true;
369369
int serialTerminalBaudRate = 115200;
370370
int serialLogBaudRate = 9600;

Firmware/OpenLog_Artemis/timeStamp.ino

+35-8
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,20 @@ void getTimeString(char timeStringBuffer[])
2626
sprintf(rtcYear, "200%d", myRTC.year);
2727
else
2828
sprintf(rtcYear, "20%d", myRTC.year);
29-
if (settings.americanDateStyle == true)
29+
if (settings.dateStyle == 0)
3030
sprintf(rtcDate, "%s/%s/%s,", rtcMonth, rtcDay, rtcYear);
31-
else
31+
else if (settings.dateStyle == 1)
3232
sprintf(rtcDate, "%s/%s/%s,", rtcDay, rtcMonth, rtcYear);
33+
else if (settings.dateStyle == 2)
34+
sprintf(rtcDate, "%s/%s/%s,", rtcYear, rtcMonth, rtcDay);
35+
else // if (settings.dateStyle == 3)
36+
sprintf(rtcDate, "%s-%s-%sT", rtcYear, rtcMonth, rtcDay);
3337
strcat(timeStringBuffer, rtcDate);
3438
}
3539

36-
if (settings.logTime)
40+
if ((settings.logTime) || ((settings.logDate) && (settings.dateStyle == 3)))
3741
{
38-
char rtcTime[13]; //09:14:37.41,
42+
char rtcTime[16]; //09:14:37.41, or 09:14:37+00:00,
3943
int adjustedHour = myRTC.hour;
4044
if (settings.hour24Style == false)
4145
{
@@ -45,6 +49,7 @@ void getTimeString(char timeStringBuffer[])
4549
char rtcMin[3];
4650
char rtcSec[3];
4751
char rtcHundredths[3];
52+
char timeZone[4];
4853
if (adjustedHour < 10)
4954
sprintf(rtcHour, "0%d", adjustedHour);
5055
else
@@ -61,8 +66,30 @@ void getTimeString(char timeStringBuffer[])
6166
sprintf(rtcHundredths, "0%d", myRTC.hundredths);
6267
else
6368
sprintf(rtcHundredths, "%d", myRTC.hundredths);
64-
sprintf(rtcTime, "%s:%s:%s.%s,", rtcHour, rtcMin, rtcSec, rtcHundredths);
65-
strcat(timeStringBuffer, rtcTime);
69+
if (settings.localUTCOffset >= 0)
70+
{
71+
if (settings.localUTCOffset < 10)
72+
sprintf(timeZone, "+0%d", settings.localUTCOffset);
73+
else
74+
sprintf(timeZone, "+%d", settings.localUTCOffset);
75+
}
76+
else
77+
{
78+
if (settings.localUTCOffset <= -10)
79+
sprintf(timeZone, "-%d", 0 - settings.localUTCOffset);
80+
else
81+
sprintf(timeZone, "-0%d", 0 - settings.localUTCOffset);
82+
}
83+
if ((settings.logDate) && (settings.dateStyle == 3))
84+
{
85+
sprintf(rtcTime, "%s:%s:%s%s:00,", rtcHour, rtcMin, rtcSec, timeZone);
86+
strcat(timeStringBuffer, rtcTime);
87+
}
88+
if (settings.logTime)
89+
{
90+
sprintf(rtcTime, "%s:%s:%s.%s,", rtcHour, rtcMin, rtcSec, rtcHundredths);
91+
strcat(timeStringBuffer, rtcTime);
92+
}
6693
}
6794

6895
if (settings.logMicroseconds)
@@ -155,7 +182,7 @@ void correctDate(int &year, int &month, int &day, int &hour)
155182
adjustMonth = true;
156183
else if (month == 2)
157184
{
158-
if (year % 4 == 0 && day == 30)
185+
if (year % 4 == 0 && day == 30) // Note: this will fail in 2100. 2100 is not a leap year.
159186
adjustMonth = true;
160187
else if (day == 29)
161188
adjustMonth = true;
@@ -213,7 +240,7 @@ void correctDate(int &year, int &month, int &day, int &hour)
213240
day = 31;
214241
break;
215242
case 2: //February
216-
if (year % 4 == 0) day = 29;
243+
if (year % 4 == 0) day = 29; // Note: this will fail in 2100. 2100 is not a leap year.
217244
else day = 28;
218245
break;
219246
case 3: //March

0 commit comments

Comments
 (0)