2012-07-27 11:49:05 +02:00
|
|
|
#pragma once
|
|
|
|
|
2014-02-02 15:04:14 +01:00
|
|
|
#include "hal.h"
|
2012-07-27 11:49:05 +02:00
|
|
|
|
2013-12-27 21:35:37 +01:00
|
|
|
class PWMIn {
|
|
|
|
public:
|
2012-07-27 11:49:05 +02:00
|
|
|
PWMIn();
|
|
|
|
|
2014-01-05 16:21:28 +01:00
|
|
|
static const int NumChannels = 6;
|
|
|
|
|
2013-12-29 18:47:32 +01:00
|
|
|
static const int8_t Missing = -128;
|
2014-02-02 15:04:14 +01:00
|
|
|
static const int8_t Full = F_CPU/HAL::Prescaler/1000/2;
|
2013-12-28 19:25:56 +01:00
|
|
|
|
2013-12-21 21:48:45 +01:00
|
|
|
void init();
|
2012-07-27 11:49:05 +02:00
|
|
|
void expire();
|
|
|
|
|
2013-12-21 21:48:45 +01:00
|
|
|
int8_t get(uint8_t channel) const;
|
2014-01-05 16:21:28 +01:00
|
|
|
void get_all(int8_t* pinto) const;
|
2013-12-21 21:48:45 +01:00
|
|
|
|
2013-12-30 19:00:53 +01:00
|
|
|
volatile uint8_t cycles;
|
|
|
|
|
2013-12-21 21:48:45 +01:00
|
|
|
void pcint();
|
2012-07-27 11:49:05 +02:00
|
|
|
|
2013-12-27 21:35:37 +01:00
|
|
|
private:
|
|
|
|
struct Input {
|
2013-12-21 21:48:45 +01:00
|
|
|
volatile int8_t width;
|
|
|
|
uint8_t rose_at;
|
|
|
|
uint8_t good;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const int Saturate = 10;
|
2014-01-07 22:34:54 +01:00
|
|
|
static const int Center = 150;
|
2013-12-21 21:48:45 +01:00
|
|
|
|
|
|
|
uint8_t level_;
|
|
|
|
Input inputs_[NumChannels];
|
2012-07-27 11:49:05 +02:00
|
|
|
};
|