/* * Led.h * * Created: 03.11.2013 17:11:58 * Author: BlubbFish */ #ifndef STRIPE_H_ #define STRIPE_H_ #include "hardware/pin.hpp" template class Stripe { public: Stripe() { init(); } void color(uint8_t r, uint8_t g, uint8_t b) { OCR0B=r; //ROT OCR2B=g; //GRÜN OCR2A=b; //BLAU } void setcolor(uint8_t mask) { (mask & (1<<0)) ? OCR2A=0xFF : OCR2A=0x00; (mask & (1<<1)) ? OCR2B=0xFF : OCR2B=0x00; (mask & (1<<2)) ? OCR0B=0xFF : OCR0B=0x00; } static const uint8_t BLACK = 0; static const uint8_t BLUE = 1; static const uint8_t GREEN = 2; static const uint8_t CYAN = 3; static const uint8_t RED = 4; static const uint8_t MAGENTA = 5; static const uint8_t YELLOW = 6; static const uint8_t WHITE = 7; private: void init() { stripered::make_output(); stripegreen::make_output(); stripeblue::make_output(); initTimer(); color(0, 0, 0); } void uninit(); void initTimer() { // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: 8000,000 kHz // Mode: Phase correct PWM top=0xFF // OC0A output: Disconnected // OC0B output: Non-Inverted PWM // Timer Period: 0,06375 ms // Output Pulse(s): // OC0B Period: 0,06375 ms Width: 0 us TCCR0A=(0< stripered; const typedef avrlib::pin stripegreen; const typedef avrlib::pin stripeblue; }; #endif /* STRIPE_H_ */