Automatic Cronjob Checkin: 20150211-181004
This commit is contained in:
+27
-35
@@ -79,7 +79,16 @@ class Stripe {
|
||||
}
|
||||
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;
|
||||
this->fade(1);
|
||||
}
|
||||
void fade(uint8_t num) {
|
||||
if(num <= max_map_size && num >= 0) {
|
||||
this->fade_zylk = num;
|
||||
}
|
||||
else {
|
||||
this->fade_zylk = 0;
|
||||
}
|
||||
this->_l = 0;
|
||||
}
|
||||
void setfadecolor(uint8_t index, uint8_t red, uint8_t green, uint8_t blue, uint8_t time) {
|
||||
this->fademap[0][index] = red;
|
||||
@@ -87,57 +96,48 @@ class Stripe {
|
||||
this->fademap[2][index] = blue;
|
||||
this->fademap[3][index] = time;
|
||||
}
|
||||
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 interrupt() {
|
||||
if(this->fade_zylk > 0) {
|
||||
if(this->fadesteps[0] == 0 && this->fadesteps[1] == 0 && this->fadesteps[2] == 0) {
|
||||
this->_l = (this->_l + 1 < this->fade_zylk) ? this->_l + 1 : 0;
|
||||
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->fadesteps[i] = (this->fademap[i][this->_l]-this->gp(i))/this->fademap[3][this->_l];
|
||||
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;*/
|
||||
} else {
|
||||
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])) {
|
||||
if((this->fadesteps[i] > 0 && (this->virtualcolor[i] + this->fadesteps[i]) <= this->fademap[i][this->_l]) || (this->fadesteps[i] < 0 && (this->virtualcolor[i] + this->fadesteps[i]) >= this->fademap[i][this->_l])) {
|
||||
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->sp(i, this->fademap[i][this->_l]);
|
||||
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];
|
||||
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:
|
||||
static const uint8_t max_map_size = 6;
|
||||
uint8_t fade_zylk;
|
||||
uint8_t fademap[4][5];
|
||||
uint8_t fademap[4][max_map_size];
|
||||
float fadesteps[3];
|
||||
float virtualcolor[3];
|
||||
uint8_t _l;
|
||||
void init() {
|
||||
stripered::make_output();
|
||||
stripegreen::make_output();
|
||||
stripeblue::make_output();
|
||||
this->fade_zylk = 0;
|
||||
this->_l = 0;
|
||||
this->initTimer();
|
||||
this->color(0, 0, 0);
|
||||
}
|
||||
@@ -148,14 +148,6 @@ class Stripe {
|
||||
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