Automatic Cronjob Checkin: 20150210-120501
This commit is contained in:
+39
-12
@@ -10,8 +10,6 @@
|
||||
|
||||
#include "hardware/pin.hpp"
|
||||
|
||||
#include <util/delay.h>
|
||||
|
||||
template <typename PortR, int pin_red, typename PortG, int pin_green, typename PortB, int pin_blue>
|
||||
class Stripe {
|
||||
public:
|
||||
@@ -19,14 +17,14 @@ class Stripe {
|
||||
this->init();
|
||||
}
|
||||
void color(uint8_t r, uint8_t g, uint8_t b) {
|
||||
OCR0B=r; //ROT
|
||||
OCR2B=g; //GRÜN
|
||||
OCR2A=b; //BLAU
|
||||
this->sp(0, r); //ROT
|
||||
this->sp(1, g); //GRÜN
|
||||
this->sp(2, 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;
|
||||
(mask & (1<<0)) ? this->sp(2, 0xFF) : this->sp(2, 0x00); //Blau
|
||||
(mask & (1<<1)) ? this->sp(1, 0xFF) : this->sp(1, 0x00); //Grün
|
||||
(mask & (1<<2)) ? this->sp(0, 0xFF) : this->sp(0, 0x00); //Rot
|
||||
}
|
||||
static const uint8_t BLACK = 0;
|
||||
static const uint8_t BLUE = 1;
|
||||
@@ -92,11 +90,24 @@ class Stripe {
|
||||
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;
|
||||
for(uint8_t i = 0; i<3; i++) { //0=red,1=green,2=blue
|
||||
this->fadesteps[i] = (this->fademap[i][this->fade_zylk-1]-this->gp(i))/this->fademap[3][this->fade_zylk-1];
|
||||
this->virtualcolor[i] = this->gp(i);
|
||||
}
|
||||
/*this->fadesteps[0] = (this->fademap[0][this->fade_zylk-1]-this->gp(0))/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;
|
||||
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])) {
|
||||
for(uint8_t i = 0; i<3; i++) { //0=red,1=green,2=blue
|
||||
if((this->fadesteps[i] > 0 && (this->virtualcolor[i] + this->fadesteps[i]) <= this->fademap[i][this->fade_zylk-1]) || (this->fadesteps[i] < 0 && (this->virtualcolor[i] + this->fadesteps[i]) >= this->fademap[i][this->fade_zylk-1])) {
|
||||
this->virtualcolor[i] = this->virtualcolor[i] + this->fadesteps[i];
|
||||
this->sp(i, this->virtualcolor[i]);
|
||||
} else {
|
||||
this->sp(i, this->fademap[i][this->fade_zylk-1]);
|
||||
this->fadesteps[i] = 0;
|
||||
}
|
||||
}
|
||||
/*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];
|
||||
@@ -113,7 +124,7 @@ class Stripe {
|
||||
} else {
|
||||
OCR2A = this->fademap[2][this->fade_zylk-1];
|
||||
this->fadesteps[2] = 0;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,6 +132,7 @@ class Stripe {
|
||||
uint8_t fade_zylk;
|
||||
uint8_t fademap[4][5];
|
||||
float fadesteps[3];
|
||||
float virtualcolor[3];
|
||||
void init() {
|
||||
stripered::make_output();
|
||||
stripegreen::make_output();
|
||||
@@ -129,6 +141,21 @@ class Stripe {
|
||||
this->initTimer();
|
||||
this->color(0, 0, 0);
|
||||
}
|
||||
void sp(uint8_t i, uint8_t c) {
|
||||
switch(i) {
|
||||
case 0: OCR0B = c; break; //ROT
|
||||
case 1: OCR2B = c; break; //GRÜN
|
||||
case 2: OCR2A = c; break; //BLAU
|
||||
}
|
||||
}
|
||||
uint8_t gp(uint8_t i) {
|
||||
switch(i) {
|
||||
case 0: return OCR0B; //ROT
|
||||
case 1: return OCR2B; //GRÜN
|
||||
case 2: return OCR2A; //BLAU
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void timerOff() {
|
||||
// OC0B output: Disconnected
|
||||
// OC2A output: Disconnected
|
||||
|
||||
Reference in New Issue
Block a user