sparkfun / OpenLog_Artemis

The OpenLog Artemis is an open source datalogger the comes preprogrammed to automatically log IMU, GPS, serial data, and various pressure, humidity, and distance sensors. All without writing a single line of code!
https://www.sparkfun.com/products/15846
Other
88 stars 47 forks source link

Feature Request: Easier access to console when using long sample times #83

Closed ryanneve closed 3 years ago

ryanneve commented 3 years ago

Subject of the issue

For long sample rates, it can be very hard to get into the console. It would be nice if for sample rates > maxUsBeforeSleep * 30 (60 seconds) there was a delay between printing out the line of logged data to the console and going back to sleep.

In our use case, we're logging every 30 minutes and have Bluetooth console access via the serial pins. It can be very hard to catch the console. We have ended up just sending a constant stream of characters to the OLA via BT until we get in the console. This is terribly inefficient on several levels. We'd prefer to just wait for some characters to come from the OLA, then try to connect to console.

Your workbench

OLA BT module on serial pins (not required)

Steps to reproduce

Try to access console at slow sample rates as soon as you see serial log output.

Expected behavior

When characters are seen from the OLA, there should be a little time for the OLA to check incoming serial characters.

Actual behavior

OLA only checks for characters after waking up, but before getting and reporting new data. No check is done after, except on first sample.

Perhaps something like this at the end of loop()

if (checkIfItIsTimeToSleep()) 
{
  uint32_t msToSleep = howLongToSleepFor();
  if ( settings.usBetweenReadings >= (maxUsBeforeSleep * 30))
  {
     delay(consoleDelay_ms); // There are much better ways of doing this, but perhaps not simpler.
     if ((Serial.available()) || ((settings.useTxRxPinsForTerminal == true) && (SerialLog.available())))
         menuMain(); //Present user menu
     else msToSleep -= consoleDelay_ms;
  }
  goToSleep(msToSleep);
}
PaulZC commented 3 years ago

Hi Ryan (@ryanneve ),

Thanks again for this suggestion. This feature has been added in v1.11. Please follow the upgrade instructions to update your firmware.

If you open the Terminal Menu, option 21 will let you set a minimum awake time. The code will log the sensor values to SD card and send via the TX pin as normal, then stay awake for the defined interval before going back into deep sleep. You can open the main menu by hitting a key or sending a byte to the RX pin at any time during that interval.

https://github.com/sparkfun/OpenLog_Artemis/blob/1859ea6b64e6adc7025ed0d3cee2c493006f55fc/Firmware/OpenLog_Artemis/menuTerminal.ino#L135-L139

I'm closing this issue but please re-open if you find any issues with the new firmware. Best wishes, Paul