20131115-191620

This commit is contained in:
BlubbFish 2013-11-15 18:16:09 +00:00
parent 623c50bb30
commit 6fac9c92d0
3 changed files with 36 additions and 3 deletions

Binary file not shown.

View File

@ -9,6 +9,7 @@
#define LED_H_
#include "pin.hpp"
#include <avr/interrupt.h>
template <typename Port, int pin_red, int pin_green, int pin_blue>
class Led {
@ -56,17 +57,47 @@ class Led {
}
private:
void init() {
r = 0;
g = 0;
b = 0;
red::make_output();
green::make_output();
blue::make_output();
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 16000,000 kHz
// Mode: Normal top=0xFF
// OC0 output: Disconnected
// Timer Period: 0,016 ms
TCCR0=(0<<WGM00) | (0<<COM01) | (0<<COM00) | (0<<WGM01) | (0<<CS02) | (0<<CS01) | (1<<CS00);
TCNT0=0x00;
OCR0=0x00;
sei();
}
void uninit();
const typedef avrlib::pin<Port, pin_red> red;
const typedef avrlib::pin<Port, pin_green> green;
const typedef avrlib::pin<Port, pin_blue> blue;
uint8_t r = 0;
uint8_t g = 0;
uint8_t b = 0;
static uint8_t r;
static uint8_t g;
static uint8_t b;
/* TIMER0_OVF_vect */
static void timer_int() __asm__("__vector_11") __attribute__((__signal__, __used__)) {
for(uint8_t i=0;i<0xFF;i++) {
uint8_t rgb = 0;
if(i<r) {
rgb |= RED;
}
if(i<g) {
rgb |= GREEN;
}
if(i<b) {
rgb |= BLUE;
}
this->color(rgb);
}
}
};

View File

@ -14,6 +14,8 @@
#define CAN_SEND_BUTTON_ID 0x01
#define CAN_GET_BUTTON_ID 0x02
#define CAN_GET_COLOR 0x03
#define CAN_GET_OK 0x04
#define CAN_GET_WRONG 0x05