SafeString  4.1.27
SafeString is a safe, robust and debuggable replacement for string processing in Arduino
PinFlasher.h
Go to the documentation of this file.
1 #ifndef _PIN_FLASHER_H_
2 #define _PIN_FLASHER_H_
3 /*
4  PinFlasher.h
5  by Matthew Ford, 2021/12/06
6  (c)2021 Forward Computing and Control Pty. Ltd.
7  NSW, Australia www.forward.com.au
8  This code may be freely used for both private and commerical use.
9  Provide this copyright is maintained.
10 */
11 #include <Arduino.h>
12 #include "millisDelay.h"
19 extern const int PIN_ON;
23 extern const int PIN_OFF;
24 
25 
49 class PinFlasher: protected millisDelay {
50  public:
57  PinFlasher(int pin = -1, bool invert = false);
58 
59  ~PinFlasher(); // sets pin back to input
60 
65  void update();
66 
75  void setPin(int pin);
76 
86  void setOnOff(unsigned long onOff_ms);
87 
101  bool invertOutput();
102 
103  protected:
107  virtual void setOutput();
108  int io_pin; // initially -1, not set
109  bool io_pin_on;//initially false/ off;
110  bool outputInverted; // initially false, not inverted, i.e. off is LOW, on is HIGH
111 
112  private:
113  unsigned long half_period; // initially 0, off
114 };
115 
116 #endif
const int PIN_ON
Flashes the io_pin.
const int PIN_OFF
PIN_OFF is a 'magic' number that turns the output OFF when setOnOff(PIN_ON) called.
The PinFlasher class inherits from millisDelay to provide non-blocking repeating on/off toggle of the...
Definition: PinFlasher.h:49
bool io_pin_on
Definition: PinFlasher.h:109
virtual void setOutput()
set the output based on io_pin, io_pin_on and outputInverted
bool outputInverted
Definition: PinFlasher.h:110
PinFlasher(int pin=-1, bool invert=false)
Constructor.
bool invertOutput()
Normally pin output is LOW for off, HIGH for on.
void setPin(int pin)
Set the output pin to flash.
void update()
check if output should be changed.
void setOnOff(unsigned long onOff_ms)
Set the On and Off length, the period is twice this setting.
millisDelay** implements a non-blocking, repeatable delay, see the detailed description.
Definition: millisDelay.h:35