GY-63_MS5611/libraries/PulsePattern/PulsePattern.h

56 lines
1.0 KiB
C
Raw Normal View History

2013-09-30 12:38:54 -04:00
#ifndef PulsePattern_h
#define PulsePattern_h
2013-09-30 12:29:52 -04:00
//
2013-09-30 12:38:54 -04:00
// FILE: PulsePattern.h
2013-09-30 12:29:52 -04:00
// AUTHOR: Rob dot Tillaart at gmail dot com
2013-09-30 12:38:54 -04:00
// PURPOSE: PulsePattern library for Arduino
// sends a pulse pattern to a digital pin (continuously)
2013-09-30 12:38:54 -04:00
// HISTORY: See PulsePattern.cpp
2013-09-30 12:29:52 -04:00
//
// Released to the public domain
//
#include <inttypes.h>
2013-09-30 12:38:54 -04:00
#define PULSEPATTERN_LIB_VERSION "0.0.5"
2013-09-30 12:29:52 -04:00
#define NOTINIT -1
2013-09-30 12:29:52 -04:00
#define STOPPED 0
#define RUNNING 1
2013-09-30 12:34:23 -04:00
#define NO_CLOCK 0
#define PRESCALE_1 1
#define PRESCALE_8 2
#define PRESCALE_64 3
#define PRESCALE_256 4
#define PRESCALE_1024 5
class PulsePattern
2013-09-30 12:29:52 -04:00
{
2013-09-30 12:34:23 -04:00
public:
PulsePattern();
2013-09-30 12:34:23 -04:00
void init(uint8_t pin, uint16_t * ar, uint8_t size,
uint8_t level, uint8_t prescaler);
2013-09-30 12:29:52 -04:00
void start();
void stop();
bool isRunning();
void worker();
2013-09-30 12:34:23 -04:00
private:
2013-09-30 12:29:52 -04:00
void stopTimer();
void setTimer(uint16_t cc);
uint16_t * _ar;
uint8_t _size;
uint8_t _pin;
2013-09-30 12:34:23 -04:00
uint8_t _prescaler;
2013-09-30 12:29:52 -04:00
volatile uint8_t _level;
volatile int8_t _state;
2013-09-30 12:29:52 -04:00
volatile uint8_t _cnt;
};
2013-09-30 12:38:54 -04:00
extern PulsePattern PPGenerator;
2013-09-30 12:29:52 -04:00
#endif
// END OF FILE