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.
141 lines
3.5 KiB
C++
141 lines
3.5 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 WII5Config.h
|
|
* @brief Persistent configuration in EEPROM: device ID, mode defaults, calibrations.
|
|
*/
|
|
|
|
#ifndef WII5Config_h
|
|
#define WII5Config_h
|
|
|
|
#ifdef WII5_EEPROMex
|
|
#include <EEPROMex.h>
|
|
#endif
|
|
#include <WII5.h>
|
|
|
|
/*
|
|
|
|
WII5 Configuration we must keeping
|
|
|
|
Big Areas:
|
|
* Default Mode
|
|
* Temorary Mode
|
|
* Disable LowBattery
|
|
|
|
Identifiers & Counters
|
|
|
|
* DeviceId - Unique device ID - see WII Server for names. Normally 5 digits
|
|
* RunCount - A counter that incremembers every time the AVR is booted
|
|
* RecordCount - A number that is incremented every time a Capture is done
|
|
*
|
|
|
|
*/
|
|
|
|
// Highly Oversimplified structured EEPROM storage (from past Sh3d managed code)
|
|
// Limitations:
|
|
// - Assume EEPROMex
|
|
// - Assume 384 bytes from where it says
|
|
// - Assume 64 bytes per struct (config for example is currently only 32)
|
|
// - Gives us 6 areas to write to
|
|
// - If we need more advanced, we can make a struct of structs
|
|
// TEMP: Manually copied from Sh3d Config
|
|
#define WII5CONFIG_MAXBLOCK 64
|
|
|
|
#define WII5CONFIG_OFFSET 128
|
|
// 0 - Config
|
|
#define WII5CONFIG_CONFIGDATA 0
|
|
// 1 - Status (TODO Maybe split Status, Counts, Errors)
|
|
#define WII5CONFIG_STATUSDATA 64
|
|
// 2 - ?
|
|
#define WII5CONFIG_RESERVED_2 128
|
|
// 3 - ?
|
|
#define WII5CONFIG_RESERVED_3 192
|
|
// 4 - ?
|
|
#define WII5CONFIG_RESERVED_4 256
|
|
// 5 - ?
|
|
#define WII5CONFIG_RESERVED_5 320
|
|
|
|
|
|
class WII5Config {
|
|
public:
|
|
WII5Config() {}
|
|
virtual WII5_CONTROLLERS controllerId() {return WII5CONTROLLER_CONFIG;}
|
|
void begin();
|
|
uint32_t getDeviceId(); // getNodeId
|
|
void setDeviceId(uint32_t newId); // setNodeId
|
|
|
|
// MODES: - do we have valid ones?
|
|
bool _checkMode(WII5_MODES newMode, uint32_t v1, uint32_t v2, uint32_t v3, uint32_t v4);
|
|
|
|
void setDefaultMode(WII5_MODES newMode);
|
|
WII5_MODES getDefaultMode();
|
|
|
|
void setTemporaryMode(time_t exp, WII5_MODES newMode);
|
|
WII5_MODES getTemporaryMode();
|
|
|
|
void setCapturePeriod(uint32_t in);
|
|
uint32_t getCapturePeriod();
|
|
|
|
void setCaptureRecords(uint32_t in);
|
|
uint32_t getCaptureRecords();
|
|
|
|
void setCaptureBinaryType(uint32_t in);
|
|
uint32_t getCaptureBinaryType();
|
|
|
|
void setPositionPeriod(uint32_t in);
|
|
uint32_t getPositionPeriod();
|
|
|
|
void setPositionBinaryType(uint32_t in);
|
|
uint32_t getPositionBinaryType();
|
|
|
|
// MODE Sleep
|
|
void setSleepBinaryType(uint32_t in);
|
|
uint32_t getSleepBinaryType();
|
|
void setSleepPeriod(uint32_t in);
|
|
uint32_t getSleepPeriod();
|
|
void setSleepUntil(uint32_t in);
|
|
uint32_t getSleepUntil();
|
|
|
|
void setDisableLowBattery(time_t exp);
|
|
time_t getDisableLowBattery();
|
|
|
|
uint32_t updateRecordCount();
|
|
uint32_t getRecordCount();
|
|
|
|
void resetCounters(); // clearRunCount(), clearRecordCount()
|
|
|
|
void readConfigData();
|
|
void updateConfigData();
|
|
void resetConfigData();
|
|
void readStatusData();
|
|
void updateStatusData();
|
|
void resetStatusData();
|
|
|
|
bool getFlag(WII5_FLAGS f);
|
|
void setFlag(WII5_FLAGS f, bool state);
|
|
|
|
uint32_t getGpsTimeout();
|
|
void setGpsTimeout(uint32_t t);
|
|
|
|
void dump(bool toConsole, Print* toOther);
|
|
|
|
uint16_t getBatteryLow();
|
|
void setBatteryLow(uint16_t in);
|
|
uint16_t getBatteryMid();
|
|
void setBatteryMid(uint16_t in);
|
|
|
|
protected:
|
|
uint32_t _deviceId;
|
|
WII5_Data_Config configData;
|
|
// TODO Data_Config - why is status same as config ?
|
|
WII5_Data_Config statusData;
|
|
};
|
|
|
|
extern WII5Config wii5Config;
|
|
|
|
#endif
|