// a 120*WS2812B (screenmatrix) +16x WS2812 (above, lives and waponpower) + 8dig led (score etc..) superbright+colorfull Acardegamingproject //controler: current 2axes console analogjoistig with pushjtaster and 4tasters cros (3Watt RGB in controllerplatine for effects) // i want the glow Atro Commander verry old lcd acarde game but its expensive and never money so build my own (maybe also snake, other games ) in a verry bright vision // the 120 WS2812B have a total factory rated powerconsumtion from 30Watts (purrrr this is even psychedwelic bright if somany) //cutrrent controllertest working fine its calibrated.. now have do martenkode the games i want // fastled lib SmartMatrix function haven worked so find my own system caused its faster to write own than try to get the example working.. //its free use it or parts if something usefull [MEOW] =^.^= //** Serial 3 is connectet to 433Mhz rx/tx RF modules, maybe let pc play the gemesound.. or use serial2 sor serial mp3 player don't know.. // 3gp video from testing this running kote http://marderchen.de/NEU/120xWS2812B_acardematrix_purrgamepadworking+calibrated.3gp // video from rainbowtesting matrix http://marderchen.de/NEU/120xWS2812B_selfbuildacardematrix_rainbowtest.3gp /* * pictures: * http://marderchen.de/NEU/120x_WS2812B_30Watt-ledcolormatrix_gamepad.jpg * http://marderchen.de/NEU/120xWS2812B_matrixtest_5Vunlimited-Ampere_test.jpg * http://marderchen.de/NEU/120x-ws2812B_Matrix10x12_fordrivewith_factoryrated_30watt.jpg for using maximum efficience and brighteness its a mass cooper (NYM 1,5mm²) wire on read for cooling and optimal power to spread, capacitors for Stabilasing voltage: 6x 1000yF 10V (for 5V) 2x 1000yF in controller for 3v3 and 5v) * http://marderchen.de/NEU/120xWS2812B_matrix_testfine.jpg */ //today get mp3/wav serial mp3player purrrfect functional and batterypowerledbar in controller //video from playerfunction http://marderchen.de/0/WS2812_acartegamematrix_serial_microsdplayercontroll_purrfect.3gp now its macing noise for games just have to create them^^ #include #include #include const byte chips = 1; // 1 chip, bit banged SPI on pins 6, 7, 8 MAX7219 display (chips, PA4, PA7, PA5); // Chips / LOAD / DIN / CLK String mews = "Purrrrrr "; //const char message []= "Start config"; #include #define LED_PIN PB8 //DIN connect to pin B8 #define BRIGHTNESS 255 #define LED_TYPE WS2812B //did you know you can mix WS2812B and WS2812 leds in sane stripe on same databus oh its realy moving cute fast.. like the older WS2812 more causet little more power consumtion, bigger LED chips, (looking brighter caused biger chips) and think it make sense to use the old big chips caused better heataway.. think the smallittlenew ones have just not enought ground contakt foor goot efficient cooling #define COLOR_ORDER GRB #define screeny 145 //number of leds CRGB leds[screeny]; CRGBPalette16 currentPalette; TBlendType currentBlending; #define UPDATES_PER_SECOND 5000 extern CRGBPalette16 myRedWhiteBluePalette; #define rot PA8 #define grun PB15 #define blau PB14 #define t1 PB12 #define t2 PB13 #define t3 PB5 #define t4 PA10 #define t5 PA9 #define achsex PA0 #define achsey PA1 #define power PB1 int mwidth= 12; int mhight=10; uint8_t matrix[14][12][4]; long maintime = millis(); long beadtime=millis(); int zeit1,zeit2; int xj=0; int yj=0; int8_t onpress[17]; //serial mp3 player thingy oh no i have reead the manuyl.. tthe first ever^^ int8_t commandbuild[8]= {0}; // first command begin byte, second versionbyte, 3. bytelength (without start/endbyte),4. should do byte, 5. want answer=01 else =00, 6 and 7 numbers 00-FF more information what should do).. see how simple it is^^ /* soundschosen:: somday.. win pinpall from 261-309 .. pacman 188-191 * playone(123); move x || playone(134); movey || playone(220); start game || endgegener playone(231); || playone(106); lost game || win game playone(357); * schiez sounds playone(178); playone(5); playone(108); playone(315); playone(228); || shot lazor playone(143); playone(201); * aufschlag gegner sound playone(122); playone(135); * zerstört gegner sounds playone(142); playone(119); playone(73); playone(20); playone(221); playone(177); playone(172); playone(229); * level up playone(242); || lost energy playone(257); || get energy playone(256); || granat playone(309); * loosinglive playone(323); || get live playone(157); playone(18); || error playone(22); || pick up playone(101); playone(43); playone(44); * new enemy playone(117); * caused kitten playone(131); playone(132); playone(133); */ void setup(){ delay(1000); commandbuild[0]=0x7e; commandbuild[1]=0xFF; commandbuild[2]=0x06; commandbuild[4]=0x01; commandbuild[7]=0xEF; display.begin(); Serial3.begin(9600);//RF Serial2.begin(9600);//grun tx mitte rx orange 3v3+++++++++++++ //player FastLED.addLeds(leds, screeny).setCorrection( TypicalLEDStrip ); FastLED.setBrightness( BRIGHTNESS ); currentPalette = RainbowColors_p; currentBlending = BLEND; outputon(true); delay(50); nureinmal(true); } int16_t counts=0; int battvoll=0; int wielaud=0; int prog=1; int multi1,hellc,hellcc; int lcc=0; long beattime=millis(); long beattrig=11700; uint8_t beatstep=1; String outzi=""; void loop(){ zeitreise(); joy(); buttons(); if (prog == 0) {clearleds(); matrix[xj][yj][3]=1;} if (prog == 1) {beatblitz();} if (prog == 2) {prog=0;} regenbogen(); // scratchdigs(); FastLED.show(); // FastLED.delay(1000 / 15000); //realy need this delay? XD } void batt(void) { //think have to adjust more its for get the battery charge over analog meassure from optokopler powered by cellvoltage over resistor.. battvoll=136+round(analogRead(power)/400); for( int bing= 136; bing < 144; bing++) { if (bing >battvoll) {leds[bing]=0x880011;} if (bing <=battvoll) {leds[bing]=ColorFromPalette( currentPalette,random(0,255),255,currentBlending);} } } void joy(void) { //for reading the analog xbox gambap ** pinleft 1 3V3 pin center GPIO analog input pin right GND || joystickpotis and get value with display meassures xj= round((4096-analogRead(achsex))/341); yj= round(analogRead(achsey)/410); } void buttons() { // for reading tasters without clipping multiple count on one press effect if (zeit2 >=1) { if (digitalRead(t1) == HIGH && onpress[0] ==0) { onpress[0] =1; prog++; if (prog == 0) {counts++; undlos(String(counts)); playone(counts);} if (prog == 1) {}} if (onpress[0] == 1) { onpress[1]++; }// leds[121]=ColorFromPalette( currentPalette,onpress[1]*5,255,currentBlending); }//spiel(melodie2); if (onpress[1] >= 10) { onpress[1] =0; onpress[0]=0; } if (digitalRead(t2) == HIGH && onpress[2] ==0) { onpress[2] =1; if (prog == 0) {counts--; undlos(String(counts)); playone(counts);} if (prog==1) {multi1++; zeigzahlL(multi1);}} if (onpress[2] == 1) { onpress[3]++; }// leds[122]=ColorFromPalette( currentPalette,onpress[3]*10,255,currentBlending); } if (onpress[3] >= 5) { onpress[3] =0; onpress[2]=0; } if (digitalRead(t3) == HIGH && onpress[4] ==0) { onpress[4] =1; if (prog == 0) {wielaud++;if (wielaud >=30){wielaud=0;} undlos(String(wielaud)); mux(wielaud); } if (prog == 1) {beattrig+=100; zeigzahlR(beattrig);}} if (onpress[4] == 1) { onpress[5]++; }// leds[123]=ColorFromPalette( currentPalette,onpress[5]*15,255,currentBlending); } if (onpress[5] >= 10) { onpress[5] =0; onpress[4]=0; } if (digitalRead(t4) == HIGH && onpress[6] ==0) { onpress[6] =1; if (prog == 0) {wielaud--;if (wielaud <=0){wielaud=0;} undlos(String(wielaud)); mux(wielaud);} if (prog == 1) {beattrig-=10; zeigzahlR(beattrig);}} if (onpress[6] == 1) { onpress[7]++; }// leds[124]=ColorFromPalette( currentPalette,onpress[7]*20,255,currentBlending); } if (onpress[7] >= 10) { onpress[7] =0; onpress[6]=0; } if (digitalRead(t5) == HIGH && onpress[8] ==0) { onpress[8] =1; if (prog == 0) {commandbuild[3]=0x03; commandbuild[5]=0x00; commandbuild[6]=0x00; texteplayerzu();}// playone(counts);} if (prog == 1) {beatstep++; zeigzahlL(beatstep);}} if (onpress[8] == 1) { onpress[9]++; }// leds[125]=ColorFromPalette( currentPalette,onpress[9]*25,255,currentBlending); } if (onpress[9] >= 10) { onpress[9] =0; onpress[8]=0; } zeit2=0; }} void clearleds(void) { for( int xxx= 0; xxx < mwidth; xxx++) { for( int yyy= 0; yyy < mhight; yyy++) {matrix[xxx][yyy][3]=0;}} for( int live= 121; live < 136; live++) { leds[live]=CRGB::Black;} } int zeitk=0; int color2=0; int color=0; int speedz=0; int merkup=0; int positron=0; void regenbogen(void){ // for hurryscurry ma matrixarradata indo the 12x10px WS2812B screen if (merkup==0) {color2++;} // if (merkup==1) {color2--;} if (color2 > 4096) {color2=0; } // if (color2 < 0) {merkup=0;} color=color2; positron=0; for( int xx= (mwidth); xx > 0; xx--) { for( int yy= 2; yy < (mhight+2); yy++) { color++; if (matrix[xx][yy][3]==0){ leds[positron]= 0x000000;} if (matrix[xx][yy][3]==1){ leds[positron]= 0xffffff;} if (matrix[xx][yy][3]==2){ leds[positron]= 0xff0000;} if (matrix[xx][yy][3]==3){ leds[positron]= 0xffff00;} if (matrix[xx][yy][3]==4){ leds[positron]= 0x00ff00;} if (matrix[xx][yy][3]==5){ leds[positron]= 0x00ffff;} if (matrix[xx][yy][3]==6){ leds[positron]= 0x0000ff;} if (matrix[xx][yy][3]==7){ leds[positron]= 0xff00ff;} if (matrix[xx][yy][3]==8){ // matrix[xx][yy][0]=color; // matrix[xx][yy][1]=sin(color/360)*360; leds[positron]=ColorFromPalette( currentPalette,matrix[xx][yy][0], matrix[xx][yy][1],currentBlending);} positron++; }}} int xdelay=25; int denda,blinkz; void scratchdigs() { mews =""; if(xj <=9) {mews+="0";} if(xj <=99) {mews+="0";} if(xj <=999) {mews+="0";} if(xj <=9999) {mews+="0";} mews += String(xj); if(yj <=9) {mews+="0";} if(yj <=99) {mews+="0";} if(yj <=999) {mews+="0";} if(yj <=9999) {mews+="0";} mews += String(yj); undlos(String(mews)); } 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]); } } int intbattime=0; int npress =0; void zeitreise(void){ while ((millis()- maintime) >= 10) { zeit1++; zeit2++; if(zeit1 > zeitk) { speedz++;zeit1=0;} if (speedz > 200) { speedz = 0; zeitk=random(20,50);} maintime = millis();} while ((micros()- beattime) >= ((beattrig)+23000)) { if (prog == 1) { beatstep++; if (beatstep >=11) {beatstep=1;} beatblitz(); batt(); beattime=micros();} } while ((millis()- beadtime) > 2) { if (prog == 1) { fadeoutall(xdelay); } beadtime = millis();} } // mp3/wav microsd serial mp3 player stuff uint8_t das0xzeug=0x00; uint8_t mehr0xzeug=0x00; void playone(int16_t dasda){ das0xzeug= (int8_t)(dasda >> 8); mehr0xzeug= (int8_t)(dasda); commandbuild[3]= 0x03; commandbuild[5]= das0xzeug;commandbuild[6]= mehr0xzeug; texteplayerzu(); } void mux(int8_t wielaut){ //wielaut 0-30 das0xzeug= (int8_t)(wielaut); commandbuild[3]= 0x06; commandbuild[5]= 0x00; commandbuild[6]= das0xzeug; texteplayerzu(); } void nureinmal(boolean janein){ if (janein ==true ) {commandbuild[3]= 0x19; commandbuild[5]=0x00; commandbuild[6]=0x00;} if (janein ==false) {commandbuild[3]= 0x19; commandbuild[5]=0x00; commandbuild[6]=0x01;} texteplayerzu(); } void playmitmux(int8_t dasdar, int8_t wielaut){ das0xzeug= (int8_t)dasdar; mehr0xzeug= (int8_t)wielaut; commandbuild[3]= 0x22; commandbuild[5]=mehr0xzeug; commandbuild[6]=das0xzeug; texteplayerzu(); } void texteplayerzu(void){ delay(50); for(uint8_t woo=0; woo<8; woo++){Serial3.write(commandbuild[woo]);} } void outputon(boolean sicher){ if (sicher ==true ) {commandbuild[3]= 0x22; commandbuild[5]=0x00; commandbuild[6]=0x00;} if (sicher ==false) {commandbuild[3]= 0x22; commandbuild[5]=0x00; commandbuild[6]=0x01;} texteplayerzu(); } //end //gamestuff void setfighter(int8_t xwol, int8_t ywol, int8_t colorz,int8_t addons){ if (colorz ==0) { matrix[xwol-1][ywol-1][3]=6; matrix[xwol-1][ywol][3]=4; matrix[xwol][ywol][3]=7; matrix[xwol-1][ywol+1][3]=6; }} void colorFillRect(uint8_t xsi,uint8_t ysi,uint8_t hochsi,uint8_t langsi, uint8_t colorsi, uint8_t brightsi){ for (uint8_t xmerk= xsi; xmerk <(xsi + langsi); xmerk++) { for (uint8_t ymerk=(ysi + hochsi); ymerk > ysi; ymerk--) { matrix[xmerk][ymerk][0]=colorsi; matrix[xmerk][ymerk][1]=brightsi; matrix[xmerk][ymerk][3]=8; }}} void rainbowlineV(int16_t qxfi,int16_t qyfi, int16_t hochfi,int16_t startcol,int16_t multiply,int16_t sohell){ for (int16_t ymarka=(qyfi+hochfi); ymarka >qyfi; ymarka--) {matrix[qxfi][ymarka][3]=8; matrix[qxfi][ymarka][0]=startcol+((ymarka-qyfi)*multiply/10); matrix[qxfi][ymarka][1]=sohell;}} int16_t coladjusty=0; int16_t brightsetzi=254; int remidemi1,remidemi2,remidemi3; void beatblitz(void) { matrix[remidemi1][remidemi2][3]=8; matrix[remidemi1][remidemi2][0]=remidemi3; matrix[remidemi1][remidemi2][1]=random(180,255); if (beatstep ==1) { lcc=254;remidemi1= random(5,9); colorFillRect(2,1,2,10,190,brightsetzi);//mo } if (beatstep ==2) {lcc=202;remidemi2= random(6,8); colorFillRect(4,7,1,6,220,brightsetzi);//mu } if (beatstep ==3) {lcc=175;remidemi3= random(0,25)*25; colorFillRect(2,1,2,10,200,brightsetzi);//mo } if (beatstep ==4) {lcc=152;remidemi1= random(5,9); colorFillRect(2,3,6,1,160,brightsetzi);//l colorFillRect(3,3,1,8,160,brightsetzi);//m } if (beatstep ==5) {lcc=125;remidemi2= random(6,8); colorFillRect(3,4,4,1,40,brightsetzi);//l colorFillRect(4,4,1,6,50,brightsetzi);//m colorFillRect(11,3,6,1,50,brightsetzi);//r } if (beatstep ==6) {lcc=100;remidemi2= random(6,8); colorFillRect(4,5,2,1,0,brightsetzi);//l colorFillRect(10,4,4,1,0,brightsetzi);//r } if (beatstep ==7) {lcc=76;remidemi3= random(0,25)*25; colorFillRect(9,5,2,1,20,brightsetzi);//r } if (beatstep ==8) {lcc=50;remidemi1= random(5,9); colorFillRect(2,9,2,10,230,brightsetzi);//u } if (beatstep ==9) {lcc=26;remidemi2= random(6,8); colorFillRect(3,8,1,8,220,brightsetzi);//u } if (beatstep ==10) {lcc=0;remidemi1= random(5,9); colorFillRect(4,7,1,6,210,brightsetzi);//um } // lcc+=255; if (lcc > 25500) {lcc=0;} multi1=255; rainbowlineV(1,1,11,(lcc),multi1,hellc); if (beatstep<=5) {hellc+=random(2,1);} if (beatstep>=5) {hellc-=random(1,3);} if (hellc >=150) {hellc=150;} if (hellc <50) {hellc=50;} xdelay=18+(hellc/30); rainbowlineV(12,1,11,(lcc),multi1,hellc); } void fadeoutall(int howfast){ for (int xer=0;xer <13;xer++) { for (int8_t yer=11; yer >0; yer--) { if (matrix[xer][yer][3]==8 && matrix[xer][yer][1] >40) {matrix[xer][yer][1]-=howfast;} if (matrix[xer][yer][1] >0) {matrix[xer][yer][1]--;} if (matrix[xer][yer][1] <0) {matrix[xer][yer][1]++;}} }} void cuteta(void) { } // for xth=0; xth > 0 } nv_ ´ßß0ßp098999978867777755655 !§T&HZBCGF YSDA