change circle mapping to whole boxes

This commit is contained in:
interfisch 2018-01-10 01:26:43 +01:00
parent 8ade0b06f2
commit a742851383
2 changed files with 40 additions and 13 deletions

View File

@ -499,27 +499,27 @@ void NeoPatterns::Radar(float radarspeed,float radarthickness, uint8_t interval)
void NeoPatterns::RadarUpdate() void NeoPatterns::RadarUpdate()
{ {
Radarposition += Radarspeed; Radarposition += Radarspeed;
while (Radarposition>=32){ while (Radarposition>=20){
Radarposition-=32; Radarposition-=20;
} }
while (Radarposition<=-32){ while (Radarposition<=-20){
Radarposition+=32; Radarposition+=20;
} }
for (int i=0;i<32;i++){ for (int i=0;i<20;i++){
uint32_t c= Color(0,0,0); uint32_t c= Color(0,0,0);
float angulardistance; float angulardistance;
if (Radarspeed>0){ if (Radarspeed>0){
angulardistance=Radarposition-i; angulardistance=Radarposition-i;
if (angulardistance<0){ if (angulardistance<0){
angulardistance+=32; angulardistance+=20;
} }
} }
if (angulardistance<=Radarfadelength){ if (angulardistance<=Radarfadelength){
uint8_t _brightness=(Radarfadelength-angulardistance)*255/Radarfadelength; uint8_t _brightness=(Radarfadelength-angulardistance)*255/Radarfadelength;
c= Color (int( pow( (_brightness/255.0),2)*255.0), _brightness ,int(pow( (_brightness/255.0),2)*200.0) ); c= Color (int( pow( (_brightness/255.0),2)*255.0), _brightness ,int(pow( (_brightness/255.0),2)*150.0) );
} }
colorCircleSegment(i, c); colorCircleSegment(i, c);
@ -528,11 +528,15 @@ void NeoPatterns::RadarUpdate()
Radardotbrightness=255; Radardotbrightness=255;
} }
if (Radardotbrightness>10){ if (Radardotbrightness>10){
if (Radardotbrightness>=Radardotfadespeed){
Radardotbrightness-=Radardotfadespeed; Radardotbrightness-=Radardotfadespeed;
}else{
Radardotbrightness=0;
}
colorCircleSegment(Radardotposition, Color (Radardotbrightness,0,0)); colorCircleSegment(Radardotposition, Color (Radardotbrightness,0,0));
}else{ }else{
if (random(100)==0){ if (random(100)==0){
Radardotposition=random(0,32); //set new position Radardotposition=random(0,20); //set new position
} }
} }
@ -687,7 +691,7 @@ void NeoPatterns::setupboxs() {
} }
void NeoPatterns::colorCircleSegment(uint8_t wheelid, uint32_t c){ //color a wheel segment void NeoPatterns::colorCircleSegment(uint8_t wheelid, uint32_t c){ //color a wheel segment
for (int i=0;i<4;i++) { for (int i=0;i<6;i++) {
setPixelColor(boxcircle[wheelid][i], c); setPixelColor(boxcircle[wheelid][i], c);
} }
show(); show();

View File

@ -34,7 +34,7 @@ class NeoPatterns : public Adafruit_NeoPixel
void SmoothUpdate(); void SmoothUpdate();
void Plasma(float phase = 0, float phaseIncrement = 0.08, float colorStretch = 0.11, uint8_t interval = 60); // 0.08 and 0.11 // 0.03 und 0.3 void Plasma(float phase = 0, float phaseIncrement = 0.08, float colorStretch = 0.11, uint8_t interval = 60); // 0.08 and 0.11 // 0.03 und 0.3
void PlasmaUpdate(); void PlasmaUpdate();
void Radar(float radarspeed = 1,float radarthickness = 1, uint8_t interval = 50); void Radar(float radarspeed = 0.5,float radarthickness = 1, uint8_t interval = 50);
void RadarUpdate(); void RadarUpdate();
void SetColor1(uint32_t color); void SetColor1(uint32_t color);
@ -50,7 +50,30 @@ class NeoPatterns : public Adafruit_NeoPixel
}; };
struct box boxs[25]; struct box boxs[25];
uint8_t boxcircle[32][4]={
uint8_t boxcircle[20][6]={
{0,1,2,2,2,2},
{3,4,5,5,5,5},
{6,7,8,8,8,8},
{9,10,11,11,11,11},
{12,13,14,14,14,14},
{15,16,17,17,17,17},
{18,19,20,27,28,29},
{21,22,23,27,28,29},
{24,25,26,27,28,29},
{32,33,34,30,31,31},
{37,38,39,35,36,36},
{43,44,45,40,41,42},
{46,47,48,40,41,42},
{49,50,51,40,41,42},
{52,53,54,54,54,54},
{55,56,57,57,57,57},
{58,59,60,60,60,60},
{61,62,63,63,63,63},
{64,65,66,66,66,66},
{67,68,69,69,69,69},
};
/*uint8_t boxcircle[32][4]={
{0,0,0,0}, //0 {0,0,0,0}, //0
{1,2,2,2}, {1,2,2,2},
{3,4,4,4}, {3,4,4,4},
@ -83,7 +106,7 @@ class NeoPatterns : public Adafruit_NeoPixel
{65,66,66,66}, {65,66,66,66},
{67,68,68,68}, {67,68,68,68},
{69,69,69,69} //31 {69,69,69,69} //31
}; };*/
void setupboxs(); void setupboxs();
void colorBox(uint8_t boxid, uint32_t c); void colorBox(uint8_t boxid, uint32_t c);