// SPDX-License-Identifier: Apache-2.0 // Copyright (c) 2012-2024 Scott Penrose and WII5 Buoy contributors // // This file is part of WII5 Buoy firmware. // See LICENSE for full terms. /** * @file WII5ModePosition.h * @brief Declares WII5ModeLowBattery (low-battery mode). * * @note The WII5ModePosition.h / WII5ModeLowBattery.h header pair are * swapped relative to their filenames in this codebase: this file * (WII5ModePosition.h) declares class WII5ModeLowBattery, and * WII5ModeLowBattery.h declares class WII5ModePosition. The corresponding * .cpp files match their filenames. TODO: untangle and rename. */ #ifndef WII5ModeLowBattery_h #define WII5ModeLowBattery_h #include #include #include enum WII5LOWBATTERY_STEPS { WII5LOWBATTERY_START, WII5LOWBATTERY_STROBE, WII5LOWBATTERY_TIME, WII5LOWBATTERY_GPS_START, WII5LOWBATTERY_GPS_WAIT, WII5LOWBATTERY_IRIDIUM_WAIT, WII5LOWBATTERY_END }; /** * @brief Low-battery mode: degraded operation when supply is depleted. * * Suppresses Capture mode's heavy operations (IMU, SD writes), keeps * a minimum-viable position+telemetry cadence, and pesters Iridium * with a battery-low alert. The buoy returns to its default mode once * battery voltage recovers (or via an explicit Iridium override). */ class WII5ModeLowBattery : public WII5Mode { public: WII5ModeLowBattery() {} /** @brief Reset to WII5LOWBATTERY_START. */ void reset(); /** @brief One-time bring-up. */ void begin(); /** @brief State-machine tick. */ void loop(); /** @brief Begin a low-battery alert cycle. */ void start(); /** @brief Abort the current cycle. */ void stop(); protected: bool first; elapsedMillis displayWait; elapsedMillis wait; WII5LOWBATTERY_STEPS step; WII5LOWBATTERY_STEPS lastStep; uint32_t minutes; // since midnight. }; extern WII5ModeLowBattery wii5ModeLowBattery; #endif