You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
866 B
C++

#ifndef __TIMED_PIN__H__
#define __TIMED_PIN__H__
#include <Arduino.h>
enum TPinModes {
TPM_OFF, // On
TPM_ON, // Off
TPM_BLINK, // Blink
TPM_ASYM, // asymmetric blink
TPM_TIMED_ON, // timed on, then off
TPM_TIMED_OFF // timed off, then on
};
class TimedPin {
private:
uint8_t PinId;
TPinModes PinMode;
bool PinState;
bool PinInvert;
uint32_t RefTime;
uint32_t OnTime;
uint32_t OffTime;
uint16_t CycleCnt;
void PinOn();
void PinOff();
public:
TimedPin(uint8_t pin, bool inverted = false);
void begin();
void loop();
void Blink(uint32_t t_on, uint32_t t_off);
void Blink(uint32_t t) { Blink(t, t); }
// void BlinkCycles(uint32_t t_on, uint32_t t_off, uint16_t cycles);
void Off();
void OffTimed(uint32_t t);
void On();
void OnTimed(uint32_t t);
};
#endif