//driver for DIY rinbowkeyboart #include #include // 1 chip, bit banged SPI on pins 6, 7, 8 MAX7219 display (1, PA4, PA7, PA5); // Chips / LOAD / DIN / CLK #include #define screeny 72//number of leds CRGB leds[screeny]; CRGBPalette16 currentPalette; TBlendType currentBlending; extern CRGBPalette16 myRedWhiteBluePalette; #define ledoard P5 #define t4 PA0 #define t3 PA3 #define t1 PC15 #define t2 PC14 #define t5 PA10 #define w PB12 #define ww PB13 #define rot PB14 #define grun PB15 #define blau PA8 #define UV PA9 long slowtime = millis();long wechsel = millis(); uint16_t speedY[9]={35,17,17,8,8,4},color=0,color2=0,beatsplit2=0,rbeat=24,resuz=24,updown,pos[screeny][6],merk[screeny+1],wahl=910,abc=0,daneben,fixx=7; uint16_t resu=0,fix=1,rspeed=0,voll,cach[screeny+1][8],rands[10]; uint16_t speedz=30,fine=15,laag=0,mehr=screeny,use,colors,r,d=3,i,wart,rmax=4; String outzi=""; int8_t onpress[17]; void setup(){ delay(1000); display.begin();pinMode(UV,OUTPUT);pinMode(t1,INPUT);pinMode(t2,INPUT);pinMode(t3,INPUT);pinMode(t4,INPUT);pinMode(t5,INPUT); FastLED.addLeds(leds, screeny); display.begin();pinMode(w,OUTPUT);pinMode(ww,OUTPUT);pinMode(rot,OUTPUT);pinMode(grun,OUTPUT);pinMode(blau,OUTPUT); delay(50);} void loop(){ zeitreise(); } //((cach 0color 1 bright 2speed 3position 4ob void zeitreise(void){ while ((micros()- slowtime)>((5130+wahl*10)/2)){ //17800130 beatsplit2++;if (beatsplit2 >=speedY[fix]){beatsplit2=1;r++;beatsplit2=1;digitalWrite(w,HIGH);digitalWrite(ww,LOW); if(abc==1){digitalWrite(rot,HIGH);} if(abc==2){digitalWrite(grun,HIGH);} if(abc==3){digitalWrite(blau,HIGH);} if(abc==3){abc=0;}abc++;} if(beatsplit2%4==2){digitalWrite(UV,HIGH);} if(beatsplit2%4==2){digitalWrite(ww,HIGH);digitalWrite(rot,LOW);digitalWrite(blau,LOW);digitalWrite(grun,LOW);digitalWrite(UV,LOW);digitalWrite(w,LOW);} if(fixx==6){ daneben=round(screeny/2-13); pos[0][3]=27;//27; //sposition pos[0][4]=1; //abstand cach[pos[0][0]+daneben][1]=255; //hell cach[pos[0][0]+daneben][2]=30; //speed fade cach[merk[0]][1]=255;cach[merk[0]][2]=42; //dunkelspeed} cach[screeny-merk[1]][1]=255;cach[screeny-merk[1]][2]=30;} //dunkelspeed} if(fixx==7){ for(uint8_t h=0;h=mehr){i=0;}} if(beatsplit2==4&&r%2==1&&rands[6]>=35){pos[i][0]=0;pos[i][1]=1;pos[i][3]=2;pos[i][5]=125;;pos[i][2]=50;cach[i][2]=pos[i][2];i++;if(i>=mehr){i=0;}} if(beatsplit2==5&&rands[0]>25){pos[i][0]=0;pos[i][1]=2;pos[i][3]=2;pos[i][5]=random(120,255);;pos[i][2]=84;cach[i][2]=pos[i][2];i++;if(i>=mehr){i=0;}} if(beatsplit2==6&&r==1&&rands[1]>25){pos[i][0]=0;pos[i][1]=2;pos[i][3]=2;pos[i][5]=148;;pos[i][2]=random(0,120);cach[i][2]=pos[i][2];i++;if(i>=mehr){i=0;}} if(beatsplit2==3&&r==1&&rands[2]>25){pos[i][0]=0;pos[i][1]=1;pos[i][3]=2;pos[i][5]=196;;pos[i][2]=random(120,255);cach[i][2]=pos[i][2];i++;if(i>=mehr){i=0;}} if(beatsplit2%3==round(rands[4]/10)&&r==2&&rands[3]>25){pos[i][0]=0;pos[i][1]=5;pos[i][3]=2;pos[i][5]=random(0,120);;pos[i][2]=120;cach[i][2]=pos[i][2];i++;if(i>=mehr){i=0;}} if(beatsplit2%4==round(rands[4]/10)&&r==0&&rands[5]>25){pos[i][0]=0;pos[i][1]=2;pos[i][3]=2;pos[i][5]=random(0.255);pos[i][2]=36;cach[i][2]=pos[i][2];i++;if(i>=mehr){i=0;}} } if(r>=rmax){r=0;wart++;} if(wart>d){wart=0;d=random(2,4); rmax=random(4,8); for(uint8_t h=0;h<10;h++){rands[h]=random(0,70);}} gfx();istinput();regenbogen(); slowtime = micros();} while ((millis()- wechsel)>1000){ rbeat++;resuz++; if(rbeat >18&&(fixx==0||fixx==7)){rbeat=random(0,12);fix=random(0,5);} if(fixx >0&&fixx<=5){fix=fixx-1;} if(resuz >20){resuz=random(0,18);resu=random(4,10);} wechsel = millis(); } } void gfx(void){ for( uint8_t x = 0; x < screeny; x++) { if(cach[x][1]>=cach[x][2]){cach[x][1]-=cach[x][2];} //helligkeit if(cach[x][1]>0){cach[x][1]--;} for(uint8_t z=0;z=pos[d][3]-pos[d][4]){pos[d][1]=1;merk[use]++;if(merk[use]>screeny){merk[use]=screeny/2;} use++;if(use>=mehr){use=0;}}//screeny/2+14 if(pos[d][0]=mehr){use=0;}} }} void istinput(void){onpress[11]++; if (onpress[11] >2) { if (digitalRead(t1) == HIGH && onpress[0] ==0&&wahl>=20) { onpress[0] =1;speedz++;wahl-=20;} if (onpress[0] == 1) { onpress[1]++;} if (onpress[1] >= 10) { onpress[1] =0; onpress[0]=0; } if (digitalRead(t2) == HIGH && onpress[2] ==0 &&speedz>0) { onpress[2] =1;wahl+=20;} if (onpress[2] == 1) { onpress[3]++;} if (onpress[3] >= 5) { onpress[3] =0; onpress[2]=0; } if (digitalRead(t3) == HIGH && onpress[3] ==0&&fixx>0) { onpress[3] =1;fixx--;} if (onpress[3] == 1) { onpress[4]++;} if (onpress[4] >= 5) { onpress[4] =0; onpress[3]=0; } if (digitalRead(t4) == HIGH && onpress[5] ==0&&fixx<24) { onpress[5] =1;fixx++;} if (onpress[5] == 1) { onpress[6]++;} if (onpress[6] >= 10) { onpress[6] =0; onpress[5]=0; } if (digitalRead(t5) == HIGH && onpress[7] ==0&&fine >0) { onpress[7] =1;} if (onpress[7] == 1) { onpress[8]++;} if (onpress[8] >= 10) { onpress[8] =0; onpress[7]=0; } zeigzahlL(fixx);zeigzahlR(wahl); onpress[11]=0; }} void regenbogen(void){ color+=speedY[fix]; colors++; if (colors > 255) {colors=0; } if (color > 255) {color=0; } color2=color; for( uint8_t y = 0; y < screeny; y++) { color2+=resu; if(fixx<=5){leds[y]=ColorFromPalette(RainbowColors_p,color2,255,BLEND);} if(fixx==6){leds[y]=ColorFromPalette(RainbowColors_p,(255/screeny)*y+colors,cach[y][1],BLEND);} if(fixx>=7){leds[y]=ColorFromPalette(RainbowColors_p,cach[y][4],cach[y][1],BLEND);} // if(beatsplit2&8==1){leds[y].setRGB(255,255,255);} }FastLED.show();} void zeigwortuzahl(String wortzz,int zahlzz){ zeigwort(wortzz); zeigzahlR(zahlzz); } void zeigzahlR(int zahlz) { outzi=""; if(zahlz <=9) {outzi+="0";} if(zahlz <=99) {outzi+="0";} if(zahlz <=999) {outzi+="0";} outzi+=String(zahlz); for (byte ixx = 0; ixx < 4; ixx++){display.sendChar (ixx+4, outzi[ixx]);}} void zeigzahlL(int zaalz) { outzi=""; if(zaalz <=9) {outzi+="0";} if(zaalz <=99) {outzi+="0";} if(zaalz <=999) {outzi+="0";} outzi+=String(zaalz); for (byte ixxx = 0; ixxx < 4; ixxx++){display.sendChar (ixxx, outzi[ixxx]);}} void zeigwort(String woortz) { for (int iqq = 0; iqq < 4; iqq++){display.sendChar (iqq, woortz[iqq]);}} void undlos(String meows) { // for print string to MAX 8dig display for (int i = 0; i < 8; i++){ display.sendChar (i, meows[i]); } }