Permalink
Browse files

Added optional flag for when LOW is ON and HIGH is OFF

  • Loading branch information...
1 parent 66ba421 commit ad4d9faae3fda3f83dc5df5b3b88063855ba9b9d @chalkers committed Jan 26, 2014
Showing with 14 additions and 4 deletions.
  1. +12 −3 DigitalPin.cpp
  2. +2 −1 DigitalPin.h
View
15 DigitalPin.cpp
@@ -1,21 +1,30 @@
#include "Arduino.h"
#include "DigitalPin.h"
-DigitalPin::DigitalPin(int pin)
+DigitalPin::DigitalPin(int pin, bool off_is_on)
{
pinMode(pin, OUTPUT);
_pin = pin;
+ _off_is_on = off_is_on;
off();
}
void DigitalPin::on()
{
- write(HIGH);
+ if (_off_is_on) {
+ write(LOW);
+ } else {
+ write(HIGH);
+ }
}
void DigitalPin::off()
{
- write(LOW);
+ if (_off_is_on) {
+ write(HIGH);
+ } else {
+ write(LOW);
+ }
}
void DigitalPin::write(boolean onOff)
View
3 DigitalPin.h
@@ -6,11 +6,12 @@
class DigitalPin
{
public:
- DigitalPin(int pin);
+ DigitalPin(int pin, bool off_is_on = false);
void on();
void off();
void write(boolean onOff);
private:
int _pin;
+ bool _off_is_on;
};
#endif

0 comments on commit ad4d9fa

Please sign in to comment.