Skip to content

Commit

Permalink
Merge pull request #173 from opentrv/TRV1.5-rc5-lowbattery
Browse files Browse the repository at this point in the history
Added error report for low battery
  • Loading branch information
Denzo77 authored Nov 14, 2017
2 parents cf38e65 + 2c606fb commit b890692
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions content/OTRadioLink/utility/OTV0P2BASE_ErrorReport.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ class ErrorReport final : public OTV0P2BASE::Actuator<int8_t>

// Unspecified error.
ERR_UNSPECIFIED = 1,

// Supply voltage is low (as defined by SupplyVoltageCentiVolts::BATTERY_LOW_cV).
ERR_BATTERY_LOW = 10,
};

private:
Expand Down
5 changes: 5 additions & 0 deletions content/OTRadioLink/utility/OTV0P2BASE_PowerManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Author(s) / Copyright (s): Damon Hart-Davis 2013--2016
#include "OTV0P2BASE_ADC.h"
#include "OTV0P2BASE_Entropy.h"
#include "OTV0P2BASE_Sleep.h"
#include "OTV0P2BASE_ErrorReport.h"

namespace OTV0P2BASE
{
Expand Down Expand Up @@ -315,6 +316,10 @@ uint16_t SupplyVoltageCentiVolts::read()
isLow = isVeryLow || (result <= BATTERY_LOW_cV);
static_assert(BATTERY_LOW_cV > BATTERY_VERY_LOW_cV, "thresholds should be such that 'not low' entails 'not very low'");
static_assert(MAINS_MIN_cV > BATTERY_LOW_cV, "thresholds should be such that 'on mains' entails 'not low'");

// Set an error if battery is low.
ErrorReporter.set(ErrorReport::ERR_BATTERY_LOW);

#if 0 && defined(DEBUG)
DEBUG_SERIAL_PRINT_FLASHSTRING("Battery cV: ");
DEBUG_SERIAL_PRINT(result);
Expand Down

0 comments on commit b890692

Please sign in to comment.