Files
RGBController/pwm.h
2017-05-19 09:48:19 +02:00

36 lines
910 B
C++

#ifndef PWM_H
#define PWM_H
#include <avr/io.h>
class Pwm16b //TC1 pwm on PB1 & PB2
{
public:
Pwm16b();
~Pwm16b();
void setDuty( const uint16_t duty );
void off();
void on();
};
class Pwm8b
{
private:
volatile unsigned char *_timerControlRegisterA; //TCCRxA
volatile unsigned char *_compareRegisterA; //OCRxA
volatile unsigned char *_compareRegisterB; //OCRxB
bool _enableA;
bool _enableB;
public:
Pwm8b( volatile unsigned char *timerControlRegisterA, volatile unsigned char *timerControlRegisterB, volatile unsigned char *compareRegisterA, volatile unsigned char *compareRegisterB, const uint8_t speed = 0b00000011, const bool enableA = true, const bool enableB = true, const uint8_t dutyA = 0, const uint8_t dutyB = 0 );
~Pwm8b();
void setDutyA(const uint8_t duty);
void setDutyB(const uint8_t duty);
void off();
void on();
};
#endif