Skip to content
Snippets Groups Projects
Commit 94bf3c7e authored by user2684's avatar user2684 Committed by GitHub
Browse files

Added ability to turn the ADC off so save power (#97)

parent 8bf0952d
Branches
Tags
No related merge requests found
...@@ -3486,6 +3486,7 @@ void NodeManager::process(Request & request) { ...@@ -3486,6 +3486,7 @@ void NodeManager::process(Request & request) {
case 28: setInterruptMinDelta(request.getValueInt()); break; case 28: setInterruptMinDelta(request.getValueInt()); break;
case 30: setSleepOrWait(request.getValueInt()); break; case 30: setSleepOrWait(request.getValueInt()); break;
case 31: setRebootPin(request.getValueInt()); break; case 31: setRebootPin(request.getValueInt()); break;
case 32: setADCOff(); break;
default: return; default: return;
} }
_send(_msg.set(function)); _send(_msg.set(function));
...@@ -3655,6 +3656,14 @@ void NodeManager::setRebootPin(int value) { ...@@ -3655,6 +3656,14 @@ void NodeManager::setRebootPin(int value) {
_reboot_pin = value; _reboot_pin = value;
} }
// turn the ADC off so to save 0.2 mA
void NodeManager::setADCOff() {
// Disable the ADC by setting the ADEN bit (bit 7) to zero
ADCSRA = ADCSRA & B01111111;
// Disable the analog comparator by setting the ACD bit (bit 7) to one
ACSR = B10000000;
}
// sleep if the node is a battery powered or wait if it is not for the given number of milliseconds // sleep if the node is a battery powered or wait if it is not for the given number of milliseconds
void NodeManager::sleepOrWait(long value) { void NodeManager::sleepOrWait(long value) {
// if the node is sleeping, sleep-or-wait is enabled and we need to sleep for a decent amount of time, call sleep() otherwise wait() // if the node is sleeping, sleep-or-wait is enabled and we need to sleep for a decent amount of time, call sleep() otherwise wait()
......
...@@ -1435,6 +1435,8 @@ class NodeManager { ...@@ -1435,6 +1435,8 @@ class NodeManager {
void sleepOrWait(long value); void sleepOrWait(long value);
// [31] set which pin is connected to RST of the board to reboot the board when requested. If not set the software reboot is used instead (default: -1) // [31] set which pin is connected to RST of the board to reboot the board when requested. If not set the software reboot is used instead (default: -1)
void setRebootPin(int value); void setRebootPin(int value);
// [32] turn the ADC off so to save 0.2 mA
void setADCOff();
// hook into the main sketch functions // hook into the main sketch functions
void before(); void before();
void presentation(); void presentation();
......
...@@ -340,10 +340,12 @@ The next step is to configure NodeManager with settings which will instruct how ...@@ -340,10 +340,12 @@ The next step is to configure NodeManager with settings which will instruct how
void setReportIntervalSeconds(int value); void setReportIntervalSeconds(int value);
// [30] if set and when the board is battery powered, sleep() is always called instead of wait() (default: true) // [30] if set and when the board is battery powered, sleep() is always called instead of wait() (default: true)
void setSleepOrWait(bool value); void setSleepOrWait(bool value);
// [31] set which pin is connected to RST of the board to reboot the board when requested. If not set the software reboot is used instead (default: -1)
void setRebootPin(int value);
// sleep if the node is a battery powered or wait if it is not for the given number of milliseconds // sleep if the node is a battery powered or wait if it is not for the given number of milliseconds
void sleepOrWait(long value); void sleepOrWait(long value);
// [31] set which pin is connected to RST of the board to reboot the board when requested. If not set the software reboot is used instead (default: -1)
void setRebootPin(int value);
// [32] turn the ADC off so to save 0.2 mA
void setADCOff();
~~~ ~~~
### Set reporting intervals and sleeping cycles ### Set reporting intervals and sleeping cycles
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment