mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
Disable the voltage monitor
This commit is contained in:
parent
054c59e3e8
commit
9c60d94909
@ -81,6 +81,9 @@ IntField alarmTimeout(mainForm, "Alarm timeout", 2, 10, 1, 2, " minutes");
|
|||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Reduce power consumption on I/O pins we don't need.
|
// Reduce power consumption on I/O pins we don't need.
|
||||||
|
#ifndef USE_VOLTAGE_MONITOR
|
||||||
|
unusedPin(A1);
|
||||||
|
#endif
|
||||||
unusedPin(A2);
|
unusedPin(A2);
|
||||||
unusedPin(0);
|
unusedPin(0);
|
||||||
unusedPin(1);
|
unusedPin(1);
|
||||||
@ -139,6 +142,7 @@ void loop() {
|
|||||||
prevHour = time.hour;
|
prevHour = time.hour;
|
||||||
setTime.updateCurrentTime();
|
setTime.updateCurrentTime();
|
||||||
|
|
||||||
|
#ifdef USE_VOLTAGE_MONITOR
|
||||||
// Update the battery status once a second also.
|
// Update the battery status once a second also.
|
||||||
int status = analogRead(SENSE_BATTERY);
|
int status = analogRead(SENSE_BATTERY);
|
||||||
int voltage = (int)((status * 500L) / 1024L); // e.g. 2.81V = 281
|
int voltage = (int)((status * 500L) / 1024L); // e.g. 2.81V = 281
|
||||||
@ -146,6 +150,7 @@ void loop() {
|
|||||||
if (voltage > 500)
|
if (voltage > 500)
|
||||||
voltage = 500;
|
voltage = 500;
|
||||||
frontScreen.setVoltage(voltage);
|
frontScreen.setVoltage(voltage);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Trigger an alarm if necessary.
|
// Trigger an alarm if necessary.
|
||||||
if (time.second == 0 && nextAlarm.flags && !alarmMelody.isPlaying()) {
|
if (time.second == 0 && nextAlarm.flags && !alarmMelody.isPlaying()) {
|
||||||
|
@ -35,9 +35,11 @@
|
|||||||
|
|
||||||
FrontScreenField::FrontScreenField(Form &form)
|
FrontScreenField::FrontScreenField(Form &form)
|
||||||
: Field(form, "")
|
: Field(form, "")
|
||||||
|
#ifdef USE_VOLTAGE_MONITOR
|
||||||
, _voltage(360)
|
, _voltage(360)
|
||||||
, _voltageTrunc(36)
|
, _voltageTrunc(36)
|
||||||
, _batteryBars(IND_BATTERY_FULL)
|
, _batteryBars(IND_BATTERY_FULL)
|
||||||
|
#endif
|
||||||
, _alarmActive(false)
|
, _alarmActive(false)
|
||||||
, _hourMode(false)
|
, _hourMode(false)
|
||||||
{
|
{
|
||||||
@ -57,7 +59,9 @@ FrontScreenField::~FrontScreenField()
|
|||||||
void FrontScreenField::enterField(bool reverse)
|
void FrontScreenField::enterField(bool reverse)
|
||||||
{
|
{
|
||||||
updateDate();
|
updateDate();
|
||||||
|
#ifdef USE_VOLTAGE_MONITOR
|
||||||
updateVoltage();
|
updateVoltage();
|
||||||
|
#endif
|
||||||
updateTime();
|
updateTime();
|
||||||
updateAlarm();
|
updateAlarm();
|
||||||
}
|
}
|
||||||
@ -87,6 +91,8 @@ void FrontScreenField::setTime(const RTCTime &time)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_VOLTAGE_MONITOR
|
||||||
|
|
||||||
void FrontScreenField::setVoltage(int voltage)
|
void FrontScreenField::setVoltage(int voltage)
|
||||||
{
|
{
|
||||||
// Normal voltage ranges between 2.7 and 3.6. The power supply
|
// Normal voltage ranges between 2.7 and 3.6. The power supply
|
||||||
@ -116,6 +122,8 @@ void FrontScreenField::setVoltage(int voltage)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void FrontScreenField::setAlarmActive(bool active)
|
void FrontScreenField::setAlarmActive(bool active)
|
||||||
{
|
{
|
||||||
if (_alarmActive != active) {
|
if (_alarmActive != active) {
|
||||||
@ -180,6 +188,8 @@ void FrontScreenField::updateTime()
|
|||||||
lcd()->print(pm ? "pm" : "am");
|
lcd()->print(pm ? "pm" : "am");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_VOLTAGE_MONITOR
|
||||||
|
|
||||||
void FrontScreenField::updateVoltage()
|
void FrontScreenField::updateVoltage()
|
||||||
{
|
{
|
||||||
lcd()->setCursor(15, 0);
|
lcd()->setCursor(15, 0);
|
||||||
@ -192,13 +202,20 @@ void FrontScreenField::updateVoltage()
|
|||||||
lcd()->write('v');
|
lcd()->write('v');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void FrontScreenField::updateAlarm()
|
void FrontScreenField::updateAlarm()
|
||||||
{
|
{
|
||||||
|
#ifdef USE_VOLTAGE_MONITOR
|
||||||
lcd()->setCursor(13, 0);
|
lcd()->setCursor(13, 0);
|
||||||
|
#else
|
||||||
|
lcd()->setCursor(14, 0);
|
||||||
|
#endif
|
||||||
lcd()->write(_alarmActive ? IND_ALARM_ACTIVE1 : ' ');
|
lcd()->write(_alarmActive ? IND_ALARM_ACTIVE1 : ' ');
|
||||||
lcd()->write(_alarmActive ? IND_ALARM_ACTIVE2 : ' ');
|
lcd()->write(_alarmActive ? IND_ALARM_ACTIVE2 : ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_VOLTAGE_MONITOR
|
||||||
static uint8_t batteryEmpty[8] = {
|
static uint8_t batteryEmpty[8] = {
|
||||||
B01110,
|
B01110,
|
||||||
B10001,
|
B10001,
|
||||||
@ -259,6 +276,7 @@ static uint8_t batteryFull[8] = {
|
|||||||
B11111,
|
B11111,
|
||||||
B00000
|
B00000
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
static uint8_t alarmActive1[8] = {
|
static uint8_t alarmActive1[8] = {
|
||||||
B00100,
|
B00100,
|
||||||
B01001,
|
B01001,
|
||||||
@ -282,12 +300,14 @@ static uint8_t alarmActive2[8] = {
|
|||||||
|
|
||||||
void FrontScreenField::registerIndicators()
|
void FrontScreenField::registerIndicators()
|
||||||
{
|
{
|
||||||
|
#ifdef USE_VOLTAGE_MONITOR
|
||||||
lcd()->createChar(IND_BATTERY_EMPTY, batteryEmpty);
|
lcd()->createChar(IND_BATTERY_EMPTY, batteryEmpty);
|
||||||
lcd()->createChar(IND_BATTERY_20PCT, battery20Pct);
|
lcd()->createChar(IND_BATTERY_20PCT, battery20Pct);
|
||||||
lcd()->createChar(IND_BATTERY_40PCT, battery40Pct);
|
lcd()->createChar(IND_BATTERY_40PCT, battery40Pct);
|
||||||
lcd()->createChar(IND_BATTERY_60PCT, battery60Pct);
|
lcd()->createChar(IND_BATTERY_60PCT, battery60Pct);
|
||||||
lcd()->createChar(IND_BATTERY_80PCT, battery80Pct);
|
lcd()->createChar(IND_BATTERY_80PCT, battery80Pct);
|
||||||
lcd()->createChar(IND_BATTERY_FULL, batteryFull);
|
lcd()->createChar(IND_BATTERY_FULL, batteryFull);
|
||||||
|
#endif
|
||||||
lcd()->createChar(IND_ALARM_ACTIVE1, alarmActive1);
|
lcd()->createChar(IND_ALARM_ACTIVE1, alarmActive1);
|
||||||
lcd()->createChar(IND_ALARM_ACTIVE2, alarmActive2);
|
lcd()->createChar(IND_ALARM_ACTIVE2, alarmActive2);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include <Field.h>
|
#include <Field.h>
|
||||||
#include <RTC.h>
|
#include <RTC.h>
|
||||||
|
|
||||||
|
//#define USE_VOLTAGE_MONITOR 1
|
||||||
|
|
||||||
class FrontScreenField : public Field
|
class FrontScreenField : public Field
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -40,8 +42,10 @@ public:
|
|||||||
RTCTime time() const { return _time; }
|
RTCTime time() const { return _time; }
|
||||||
void setTime(const RTCTime &time);
|
void setTime(const RTCTime &time);
|
||||||
|
|
||||||
|
#ifdef USE_VOLTAGE_MONITOR
|
||||||
int voltage() const { return _voltage; }
|
int voltage() const { return _voltage; }
|
||||||
void setVoltage(int voltage);
|
void setVoltage(int voltage);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool isAlarmActive() const { return _alarmActive; }
|
bool isAlarmActive() const { return _alarmActive; }
|
||||||
void setAlarmActive(bool active);
|
void setAlarmActive(bool active);
|
||||||
@ -52,15 +56,19 @@ public:
|
|||||||
private:
|
private:
|
||||||
RTCDate _date;
|
RTCDate _date;
|
||||||
RTCTime _time;
|
RTCTime _time;
|
||||||
|
#ifdef USE_VOLTAGE_MONITOR
|
||||||
int _voltage;
|
int _voltage;
|
||||||
int _voltageTrunc;
|
int _voltageTrunc;
|
||||||
int _batteryBars;
|
int _batteryBars;
|
||||||
|
#endif
|
||||||
bool _alarmActive;
|
bool _alarmActive;
|
||||||
bool _hourMode;
|
bool _hourMode;
|
||||||
|
|
||||||
void updateDate();
|
void updateDate();
|
||||||
void updateTime();
|
void updateTime();
|
||||||
|
#ifdef USE_VOLTAGE_MONITOR
|
||||||
void updateVoltage();
|
void updateVoltage();
|
||||||
|
#endif
|
||||||
void updateAlarm();
|
void updateAlarm();
|
||||||
|
|
||||||
void registerIndicators();
|
void registerIndicators();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user