1
0
mirror of https://github.com/taigrr/arduinolibs synced 2025-01-18 04:33:12 -08:00

Remove voltage monitor logic - no longer relevant

This commit is contained in:
Rhys Weatherley
2012-06-15 14:42:46 +10:00
parent f5f4282e1a
commit e9a5287b32
8 changed files with 1 additions and 433 deletions

View File

@@ -42,14 +42,10 @@
// I/O pins that are used by this sketch.
#define RADIO 11
#define BUZZER 12
#define SENSE_BATTERY A1
#define RTC_DATA A4
#define RTC_CLOCK A5
#define RTC_ONE_HZ A3
// Value to adjust for the voltage drop on D2.
#define VOLTAGE_DROP_ADJUST 70 // 0.7 volts
// Offsets of settings in the realtime clock's NVRAM.
#define SETTING_24HOUR 0 // 0: 12 hour, 1: 24 hour
#define SETTING_ALARM_TIMEOUT 1 // Timeout in minutes for the alarm
@@ -92,9 +88,7 @@ BoolField radioActive(mainForm, "Radio", "On", "Off", false);
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);
@@ -160,16 +154,6 @@ 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
voltage += VOLTAGE_DROP_ADJUST;
if (voltage > 500)
voltage = 500;
frontScreen.setVoltage(voltage);
#endif
// Trigger an alarm if necessary.
if (time.second == 0 && nextAlarm.flags && !alarmMelody.isPlaying()) {
if (time.hour == nextAlarm.hour && time.minute == nextAlarm.minute) {

View File

@@ -28,22 +28,12 @@
#endif
// Special characters for indicators.
#define IND_BATTERY_EMPTY 0
#define IND_BATTERY_20PCT 1
#define IND_BATTERY_40PCT 2
#define IND_BATTERY_60PCT 3
#define IND_BATTERY_80PCT 4
#define IND_BATTERY_FULL 5
#define IND_RADIO_ON 0
#define IND_ALARM_ACTIVE1 6
#define IND_ALARM_ACTIVE2 7
FrontScreenField::FrontScreenField(Form &form)
: Field(form, "")
#ifdef USE_VOLTAGE_MONITOR
, _voltage(360)
, _voltageTrunc(36)
, _batteryBars(IND_BATTERY_FULL)
#endif
, _alarmMode(FrontScreenField::AlarmOff)
, _hourMode(false)
{
@@ -63,9 +53,6 @@ FrontScreenField::~FrontScreenField()
void FrontScreenField::enterField(bool reverse)
{
updateDate();
#ifdef USE_VOLTAGE_MONITOR
updateVoltage();
#endif
updateTime();
updateAlarm();
}
@@ -99,39 +86,6 @@ 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
// for the clock will no longer function below 2.7 volts.
if (_voltage == voltage)
return;
_voltage = voltage;
int ind;
if (voltage > 355)
ind = IND_BATTERY_FULL;
else if (voltage > 345)
ind = IND_BATTERY_80PCT;
else if (voltage > 325)
ind = IND_BATTERY_60PCT;
else if (voltage > 305)
ind = IND_BATTERY_40PCT;
else if (voltage > 285)
ind = IND_BATTERY_20PCT;
else
ind = IND_BATTERY_EMPTY;
int trunc = voltage / 10;
if (ind != _batteryBars || trunc != _voltageTrunc) {
_batteryBars = ind;
_voltageTrunc = trunc;
if (isCurrent())
updateVoltage();
}
}
#endif
static uint8_t alarmActive1[8] = {
B00100,
B01001,
@@ -232,108 +186,15 @@ void FrontScreenField::updateTime()
lcd()->print(pm ? "pm" : "am");
}
#ifdef USE_VOLTAGE_MONITOR
void FrontScreenField::updateVoltage()
{
lcd()->setCursor(15, 1);
lcd()->write(_batteryBars);
/*
lcd()->setCursor(12, 1);
lcd()->write('0' + _voltageTrunc / 10);
lcd()->write('.');
lcd()->write('0' + _voltageTrunc % 10);
lcd()->write('v');
*/
}
#endif
void FrontScreenField::updateAlarm()
{
#ifdef USE_VOLTAGE_MONITOR
lcd()->setCursor(13, 1);
#else
lcd()->setCursor(14, 1);
#endif
lcd()->write(_alarmMode != AlarmOff ? IND_ALARM_ACTIVE1 : ' ');
lcd()->write(_alarmMode != AlarmOff ? IND_ALARM_ACTIVE2 : ' ');
}
#ifdef USE_VOLTAGE_MONITOR
static uint8_t batteryEmpty[8] = {
B01110,
B10001,
B10001,
B10001,
B10001,
B10001,
B11111,
B00000
};
static uint8_t battery20Pct[8] = {
B01110,
B10001,
B10001,
B10001,
B10001,
B11111,
B11111,
B00000
};
static uint8_t battery40Pct[8] = {
B01110,
B10001,
B10001,
B10001,
B11111,
B11111,
B11111,
B00000
};
static uint8_t battery60Pct[8] = {
B01110,
B10001,
B10001,
B11111,
B11111,
B11111,
B11111,
B00000
};
static uint8_t battery80Pct[8] = {
B01110,
B10001,
B11111,
B11111,
B11111,
B11111,
B11111,
B00000
};
static uint8_t batteryFull[8] = {
B01110,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B00000
};
#endif
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);
}

View File

@@ -26,8 +26,6 @@
#include <Field.h>
#include <RTC.h>
//#define USE_VOLTAGE_MONITOR 1
class FrontScreenField : public Field
{
public:
@@ -42,11 +40,6 @@ 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
enum AlarmMode
{
AlarmOff,
@@ -63,19 +56,11 @@ public:
private:
RTCDate _date;
RTCTime _time;
#ifdef USE_VOLTAGE_MONITOR
int _voltage;
int _voltageTrunc;
int _batteryBars;
#endif
AlarmMode _alarmMode;
bool _hourMode;
void updateDate();
void updateTime();
#ifdef USE_VOLTAGE_MONITOR
void updateVoltage();
#endif
void updateAlarm();
void registerIndicators();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -1,206 +0,0 @@
#FIG 3.2 Produced by xfig version 3.2.5b
Landscape
Center
Metric
A4
100.00
Single
-2
1200 2
6 2925 3105 3285 3195
2 1 0 1 0 -1 0 0 20 0.000 1 0 -1 0 0 4
3150 3150 3060 3195 3060 3105 3150 3150
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
3150 3105 3150 3195
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
3060 3150 2925 3150
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
3150 3150 3285 3150
-6
6 4950 3105 5310 3195
2 1 0 1 0 -1 0 0 20 0.000 1 0 -1 0 0 4
5175 3150 5085 3195 5085 3105 5175 3150
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
5175 3105 5175 3195
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
5085 3150 4950 3150
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
5175 3150 5310 3150
-6
6 6660 3960 6840 4275
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
6750 4095 6750 3960
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
6750 4140 6750 4275
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
6660 4095 6840 4095
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
6660 4140 6840 4140
-6
6 8460 3960 8640 4275
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
8550 4095 8550 3960
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
8550 4140 8550 4275
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
8460 4095 8640 4095
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
8460 4140 8640 4140
-6
6 9540 3960 9765 4275
5 1 0 1 0 -1 0 0 -1 0.000 1 0 0 0 9675.000 4285.000 9585 4165 9675 4135 9765 4165
2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2
9675 4135 9675 4275
2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2
9585 4095 9765 4095
2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2
9675 4095 9675 3960
2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2
9611 3989 9611 4059
2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2
9581 4024 9641 4024
-6
6 7380 5130 7470 5220
1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 7425 5175 30 30 7425 5175 7425 5205
-6
6 7830 5130 7920 5220
1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 7875 5175 30 30 7875 5175 7875 5205
-6
6 9630 3105 9720 3195
1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 9675 3150 30 30 9675 3150 9675 3180
-6
6 9630 5130 9720 5220
1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 9675 5175 30 30 9675 5175 9675 5205
-6
6 3465 3825 3735 4365
2 1 0 1 0 -1 0 0 0 0.000 0 0 -1 0 0 2
3600 4140 3600 4365
2 2 0 1 0 -1 0 0 20 0.000 0 0 -1 0 0 5
3510 4095 3690 4095 3690 4140 3510 4140 3510 4095
2 1 0 1 0 -1 0 0 0 0.000 0 0 -1 0 0 2
3465 4050 3735 4050
2 1 0 1 0 -1 0 0 0 0.000 0 0 -1 0 0 2
3600 4050 3600 3825
-6
6 3555 3105 3645 3195
1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 3600 3150 30 30 3600 3150 3600 3180
-6
6 3555 5130 3645 5220
1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 3600 5175 30 30 3600 5175 3600 5205
-6
6 3960 3015 4500 3195
1 3 0 1 0 -1 0 0 -1 0.000 1 0.0000 4095 3150 38 38 4095 3150 4133 3150
1 3 0 1 0 -1 0 0 -1 0.000 1 0.0000 4365 3150 38 38 4365 3150 4403 3150
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
4055 3150 3960 3150
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
4405 3150 4500 3150
2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2
4135 3129 4377 3033
-6
6 5580 3105 5670 3195
1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5625 3150 30 30 5625 3150 5625 3180
-6
6 5490 3960 5715 4275
5 1 0 1 0 -1 0 0 -1 0.000 1 0 0 0 5625.000 4285.000 5535 4165 5625 4135 5715 4165
2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2
5625 4135 5625 4275
2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2
5535 4095 5715 4095
2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2
5625 4095 5625 3960
2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2
5561 3989 5561 4059
2 1 0 1 0 -1 0 0 -1 0.000 0 1 -1 0 0 2
5531 4024 5591 4024
-6
6 5580 5130 5670 5220
1 3 0 1 0 -1 0 0 20 0.000 1 0.0000 5625 5175 30 30 5625 5175 5625 5205
-6
6 2340 3825 2610 4455
1 3 0 1 0 -1 0 0 -1 0.000 1 0.0000 2475 4140 135 135 2475 4140 2610 4140
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
2475 3915 2475 3825
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 4
2410 4015 2410 3915 2540 3915 2540 4015
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
2450 3960 2500 3960
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
2475 3935 2475 3985
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
2450 4320 2500 4320
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 4
2410 4265 2410 4365 2540 4365 2540 4265
2 1 0 1 0 -1 0 0 -1 0.000 0 0 -1 0 0 2
2475 4365 2475 4455
4 0 0 0 0 16 8 0.0000 4 105 210 2392 4180 DC\001
-6
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
2475 3825 2475 3150 3015 3150
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
5265 3150 7200 3150
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2
5 0 1.00 60.00 120.00
8100 3150 11025 3150
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
6750 4005 6750 3825 7200 3825
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
6750 4230 6750 4500 7200 4500
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
8550 3960 8550 3825 8100 3825
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
8550 4230 8550 4500 8100 4500
2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
7200 2925 8100 2925 8100 4725 7200 4725 7200 2925
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
7875 4725 7875 5175
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
7425 4725 7425 5175
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
9675 4005 9675 3150
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
9675 4230 9675 5175
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
3600 3870 3600 3150
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
3600 4365 3600 5175
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
3960 3150 3240 3150
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
4500 3150 4950 3150
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
5625 4005 5625 3150
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
5625 4230 5625 5175
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3
5 0 1.00 60.00 120.00
5625 3150 5625 2250 11025 2250
2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3
5 0 1.00 60.00 120.00
2475 4410 2475 5175 11025 5175
4 0 0 50 -1 0 12 0.0000 4 135 660 4815 3015 1N4001\001
4 0 0 50 -1 0 12 0.0000 4 135 660 2835 3015 1N4001\001
4 0 0 50 -1 0 12 0.0000 4 135 420 4995 4185 10uF\001
4 0 0 50 -1 0 12 0.0000 4 135 105 7020 3060 2\001
4 0 0 50 -1 0 12 0.0000 4 135 570 6030 4185 0.22uF\001
4 0 0 50 -1 0 12 0.0000 4 135 570 8685 4185 0.22uF\001
4 0 0 50 -1 0 12 0.0000 4 135 105 7065 4410 8\001
4 0 0 50 -1 0 12 0.0000 4 135 105 7065 3735 1\001
4 0 0 50 -1 0 12 0.0000 4 135 105 8145 3735 4\001
4 0 0 50 -1 0 12 0.0000 4 135 105 8145 3060 3\001
4 0 0 50 -1 0 12 0.0000 4 135 105 8145 4455 5\001
4 0 0 50 -1 0 12 0.0000 4 135 105 7470 4905 6\001
4 0 0 50 -1 0 12 0.0000 4 135 105 7920 4905 7\001
4 0 0 50 -1 0 12 0.0000 4 135 765 7290 2745 MAX619\001
4 0 0 50 -1 0 12 0.0000 4 135 420 9855 4185 10uF\001
4 0 0 50 -1 0 12 0.0000 4 135 510 11160 3195 5VDC\001
4 0 0 50 -1 0 12 0.0000 4 135 405 11160 5220 GND\001
4 0 0 50 -1 0 12 0.0000 4 135 465 11205 2070 Sense\001
4 0 0 50 -1 0 12 0.0000 4 180 600 11205 2295 Battery\001
4 0 0 50 -1 0 12 0.0000 4 135 495 11205 2520 Status\001
4 0 0 50 -1 0 12 0.0000 4 135 240 3015 2835 D1\001
4 0 0 50 -1 0 12 0.0000 4 135 240 4995 2835 D2\001
4 0 0 50 -1 0 12 0.0000 4 135 390 3870 4050 3.6V\001
4 0 0 50 -1 0 12 0.0000 4 135 510 3825 4275 NiMH\001
4 0 0 50 -1 0 12 0.0000 4 180 690 1530 4365 Dynamo\001
4 0 0 50 -1 0 12 0.0000 4 135 510 1620 4140 5VDC\001

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB