295abb37ee
Firmware for an autonomous wave-measurement buoy (ATmega2560-based WII5 v2 board). Reads wave motion from a Sparton AHRS-M1/M2 IMU, samples GPS and battery state, and reports back over Iridium SBD satellite telemetry. Originally developed 2012-2024. This is the first public release. Code, documentation, and field-tested operating modes (Capture, Sleep, Position, ManualTest, SelfTest, LowBattery) are licensed under Apache 2.0 — see LICENSE and NOTICE. See README.md for an overview and build instructions, CONTRIBUTING.md for how to contribute, and DEPLOYMENTS.md for the field-deployment log.
61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
// SPDX-License-Identifier: Apache-2.0
|
|
// Copyright (c) 2012-2024 Scott Penrose <scottp@dd.com.au> and WII5 Buoy contributors
|
|
//
|
|
// This file is part of WII5 Buoy firmware.
|
|
// See LICENSE for full terms.
|
|
|
|
/**
|
|
* @file WII5ModeSleep.h
|
|
* @brief Sleep mode: long sleeps between wake-ups; powers down the Maths CPU.
|
|
*/
|
|
|
|
#ifndef WII5ModeSleep_h
|
|
#define WII5ModeSleep_h
|
|
|
|
#include <Arduino.h>
|
|
#include <WII5.h>
|
|
#include <TimeLib.h>
|
|
|
|
// TODO - Namespace these - e.g enum class ...
|
|
enum WII5SLEEP_STEPS {
|
|
WII5SLEEP_START,
|
|
WII5SLEEP_WAIT,
|
|
WII5SLEEP_SLEEPING,
|
|
WII5SLEEP_BUTTONS,
|
|
WII5SLEEP_UPDATE,
|
|
WII5SLEEP_TIME,
|
|
WII5SLEEP_COMMS,
|
|
WII5SLEEP_FINISH
|
|
};
|
|
|
|
/**
|
|
* @brief Sleep mode: long sleeps between wake-ups.
|
|
*
|
|
* Computes how long to sleep until the next configured wake-up
|
|
* (capture window, position update, etc.), powers down the Maths CPU
|
|
* and other peripherals, and uses sh3dNodeUtil.sleep() to put the AVR
|
|
* into deep sleep.
|
|
*/
|
|
class WII5ModeSleep : public WII5Mode {
|
|
public:
|
|
WII5ModeSleep() {}
|
|
/** @brief Reset to WII5SLEEP_START. */
|
|
void reset();
|
|
/** @brief One-time bring-up. */
|
|
void begin();
|
|
/** @brief State-machine tick. */
|
|
void loop();
|
|
|
|
protected:
|
|
bool first;
|
|
WII5SLEEP_STEPS lastStep;
|
|
elapsedMillis stepWait;
|
|
elapsedMillis displayWait;
|
|
WII5SLEEP_STEPS step;
|
|
uint32_t sleepNextSeconds; // How long we going to sleep (cleared after sleep)
|
|
};
|
|
|
|
extern WII5ModeSleep wii5ModeSleep;
|
|
|
|
#endif
|