ArduinoLibs
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PowerSave.h
1 /*
2  * Copyright (C) 2012 Southern Storm Software, Pty Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef PowerSave_h
24 #define PowerSave_h
25 
26 #if defined(ARDUINO) && ARDUINO >= 100
27 #include <Arduino.h>
28 #else
29 #include <WProgram.h>
30 #endif
31 
32 inline void unusedPin(uint8_t pin)
33 {
34  pinMode(pin, INPUT);
35  digitalWrite(pin, HIGH);
36 }
37 
39 {
50 };
51 
52 void sleepFor(SleepDuration duration, uint8_t mode = 0);
53 
54 #endif
void unusedPin(uint8_t pin)
Marks an I/O pin as unused.This function sets pin to be an input with pullups enabled, which will reduce power consumption compared to pins that are left floating.
Definition: PowerSave.h:32
Sleep for 60 milliseconds.
Definition: PowerSave.h:42
Sleep for 250 milliseconds.
Definition: PowerSave.h:44
void sleepFor(SleepDuration duration, uint8_t mode=0)
Puts the CPU to sleep for a specific duration.The analog to digital converter and the brown out detec...
Definition: PowerSave.cpp:132
Sleep for 120 milliseconds.
Definition: PowerSave.h:43
SleepDuration
Duration to put the CPU to sleep with sleepFor().
Definition: PowerSave.h:38
Sleep for 30 milliseconds.
Definition: PowerSave.h:41
Sleep for 2 seconds.
Definition: PowerSave.h:47
Sleep for 8 seconds.
Definition: PowerSave.h:49
Sleep for 1 second.
Definition: PowerSave.h:46
Sleep for 4 seconds.
Definition: PowerSave.h:48
Sleep for 500 milliseconds.
Definition: PowerSave.h:45
Sleep for 15 milliseconds.
Definition: PowerSave.h:40