Automatic Cronjob Checkin: 20150209-181004
This commit is contained in:
@@ -26,6 +26,8 @@ class Led {
|
||||
void green(uint8_t g) {
|
||||
if(g==1) {
|
||||
ledgreen::set();
|
||||
} else if(g==2) {
|
||||
ledgreen::toggle();
|
||||
} else {
|
||||
ledgreen::clear();
|
||||
}
|
||||
|
||||
@@ -79,11 +79,53 @@ class Stripe {
|
||||
OCR2A = 0;
|
||||
}
|
||||
}
|
||||
void fadeto(uint8_t red, uint8_t green, uint8_t blue, uint8_t time) {
|
||||
this->setfadecolor(0, red, green, blue, time);
|
||||
this->fade_zylk = 1;
|
||||
}
|
||||
void setfadecolor(uint8_t index, uint8_t red, uint8_t green, uint8_t blue, uint8_t time) {
|
||||
this->fademap[0][index] = red;
|
||||
this->fademap[1][index] = green;
|
||||
this->fademap[2][index] = blue;
|
||||
this->fademap[3][index] = time;
|
||||
}
|
||||
void interrupt() {
|
||||
if(this->fade_zylk > 0) {
|
||||
if(this->fadesteps[0] == 0 && this->fadesteps[1] == 0 && this->fadesteps[2] == 0) {
|
||||
this->fadesteps[0] = (this->fademap[0][this->fade_zylk-1]-OCR0B)/this->fademap[3][this->fade_zylk-1]; //Calc Red;
|
||||
this->fadesteps[1] = (this->fademap[1][this->fade_zylk-1]-OCR2B)/this->fademap[3][this->fade_zylk-1]; //Calc Green;
|
||||
this->fadesteps[2] = (this->fademap[2][this->fade_zylk-1]-OCR2A)/this->fademap[3][this->fade_zylk-1]; //Calc Blue;
|
||||
} else {
|
||||
if((this->fadesteps[0] > 0 && (OCR0B + this->fadesteps[0]) <= this->fademap[0][this->fade_zylk-1]) || (this->fadesteps[0] < 0 && (OCR0B + this->fadesteps[0]) >= this->fademap[0][this->fade_zylk-1])) {
|
||||
OCR0B = OCR0B + this->fadesteps[0];
|
||||
} else {
|
||||
OCR0B = this->fademap[0][this->fade_zylk-1];
|
||||
this->fadesteps[0] = 0;
|
||||
}
|
||||
if((this->fadesteps[1] > 0 && (OCR2B + this->fadesteps[1]) <= this->fademap[1][this->fade_zylk-1]) || (this->fadesteps[1] < 0 && (OCR2B + this->fadesteps[1]) >= this->fademap[1][this->fade_zylk-1])) {
|
||||
OCR2B = OCR2B + this->fadesteps[1];
|
||||
} else {
|
||||
OCR2B = this->fademap[1][this->fade_zylk-1];
|
||||
this->fadesteps[1] = 0;
|
||||
}
|
||||
if((this->fadesteps[2] > 0 && (OCR2A + this->fadesteps[2]) <= this->fademap[2][this->fade_zylk-1]) || (this->fadesteps[2] < 0 && (OCR2A + this->fadesteps[2]) >= this->fademap[2][this->fade_zylk-1])) {
|
||||
OCR2A = OCR2A + this->fadesteps[2];
|
||||
} else {
|
||||
OCR2A = this->fademap[2][this->fade_zylk-1];
|
||||
this->fadesteps[2] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
uint8_t fade_zylk;
|
||||
uint8_t fademap[4][5];
|
||||
float fadesteps[3];
|
||||
void init() {
|
||||
stripered::make_output();
|
||||
stripegreen::make_output();
|
||||
stripeblue::make_output();
|
||||
this->fade_zylk = 0;
|
||||
this->initTimer();
|
||||
this->color(0, 0, 0);
|
||||
}
|
||||
@@ -114,6 +156,23 @@ class Stripe {
|
||||
TCCR0A=(0<<COM0A1) | (0<<COM0A0) | (0<<COM0B0) | (0<<WGM01) | (1<<WGM00);
|
||||
TCCR0B=(0<<WGM02) | (1<<CS02) | (0<<CS01) | (0<<CS00);
|
||||
TCNT0=0x00;
|
||||
// Timer/Counter 1 initialization
|
||||
// Clock source: System Clock
|
||||
// Clock value: 20000,000 kHz
|
||||
// Mode: Normal top=0xFFFF
|
||||
// OC1A output: Disconnected
|
||||
// OC1B output: Disconnected
|
||||
// Noise Canceler: Off
|
||||
// Input Capture on Falling Edge
|
||||
// Timer Period: 3,2768 ms
|
||||
// Timer1 Overflow Interrupt: On
|
||||
// Input Capture Interrupt: Off
|
||||
// Compare A Match Interrupt: Off
|
||||
// Compare B Match Interrupt: Off
|
||||
TCCR1A=(0<<COM1A1) | (0<<COM1A0) | (0<<COM1B1) | (0<<COM1B0) | (0<<WGM11) | (0<<WGM10);
|
||||
TCCR1B=(0<<ICNC1) | (0<<ICES1) | (0<<WGM13) | (0<<WGM12) | (0<<CS12) | (1<<CS11) | (0<<CS10);
|
||||
TCNT1H=0x00;
|
||||
TCNT1L=0x00;
|
||||
// Timer/Counter 2 initialization
|
||||
// Clock source: System Clock
|
||||
// Clock value: 8000,000 kHz
|
||||
@@ -128,6 +187,8 @@ class Stripe {
|
||||
TCNT2=0x00;
|
||||
// Timer/Counter 0 Interrupt(s) initialization
|
||||
TIMSK0=(0<<OCIE0B) | (0<<OCIE0A) | (0<<TOIE0);
|
||||
// Timer/Counter 1 Interrupt(s) initialization
|
||||
TIMSK1=(0<<ICIE1) | (0<<OCIE1B) | (0<<OCIE1A) | (1<<TOIE1);
|
||||
// Timer/Counter 2 Interrupt(s) initialization
|
||||
TIMSK2=(0<<OCIE2B) | (0<<OCIE2A) | (0<<TOIE2);
|
||||
this->timerOn();
|
||||
|
||||
Reference in New Issue
Block a user