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