//adjustable turbine driver 3x IRF1404 (ofe NPN-PNP transistorbrigde connectet to stm //kote for STM32F103C8T6 //progress project by marderchen #include #include #include //thanks to adafruit // Software SPI (slower updates, more flexible pin options): // pin 7 - Serial clock out (SCLK) // pin 6 - Serial data out (DIN) // pin 5 - Data/Command select (D/C) // pin 4 - LCD chip select (CS) // pin 3 - LCD reset (RST) Adafruit_PCD8544 display = Adafruit_PCD8544(PA5, PA7, PA4, PA6, PB0); //Adafruit_PCD8544(int8_t SCLK, int8_t DIN, int8_t DC, int8_t CS, int8_t RST); // 1-> PB0 -- 2->PA6 -- 3->PA4 -- 4->PA7 -- 5->PA5 -- 6->3V3 -- 7->3V3 -- 8->GND (NOKIA 5510 PCB board) const unsigned char PROGMEM monstercat []=//cute bootpicture :3 { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x7F, 0xFF, 0x7F, 0xFF, 0xF0, // ############################################## ############### ################### 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0x3F, 0xFE, 0xFF, 0xFF, 0xC0, // ############################################# # ############# ################## 0xC3, 0x87, 0xFF, 0xFE, 0xFF, 0xFB, 0xBF, 0xFD, 0xFF, 0xFF, 0x30, // ## ### ################## ############# ### ############ ################# ## 0xDD, 0x77, 0xFF, 0xFD, 0x3F, 0x9B, 0xDF, 0xFB, 0xFF, 0xF8, 0xF0, // ## ### # ### ################# # ####### ## #### ########## ############### #### 0xDE, 0xF7, 0xFF, 0xFD, 0xD0, 0x67, 0xDF, 0xFB, 0xFF, 0xE7, 0xF0, // ## #### #### ################# ### # ## ##### ########## ############# ####### 0xDF, 0xF7, 0xFF, 0xFD, 0xEF, 0xFF, 0xEF, 0xF7, 0xFE, 0x1F, 0xF0, // ## ######### ################# #### ############### ######## ########## ######### 0xDB, 0xB7, 0xFF, 0xFD, 0xFC, 0x07, 0xF7, 0xFF, 0xF1, 0xFF, 0xF0, // ## ## ### ## ################# ####### ####### ############### ############# 0xD9, 0x37, 0xCF, 0xFD, 0xF0, 0x1F, 0xFB, 0xFF, 0xCF, 0xFF, 0xF0, // ## ## # ## ##### ########## ##### ########## ############ ################ 0xDA, 0xB7, 0xF3, 0xFD, 0xFF, 0xFF, 0xFD, 0xFF, 0x3F, 0xFF, 0xF0, // ## ## # # ## ####### ######## ####################### ######### ################## 0xC3, 0x87, 0xFC, 0xFB, 0xFF, 0xFF, 0xE5, 0xFF, 0xFF, 0xFF, 0xF0, // ## ### ######### ##### ##################### # ############################# 0xFF, 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, 0xF4, 0xFF, 0xFF, 0xFF, 0xF0, // ############################ ####################### # ############################ 0xFF, 0xFF, 0xFF, 0xED, 0xFF, 0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0xF0, // ########################### ## ######################### ########################## 0xC0, 0x07, 0xFF, 0xE9, 0xFF, 0xFF, 0xFF, 0x9F, 0x00, 0x00, 0x00, // ## ############## # ########################## ##### 0xDF, 0xF7, 0xFF, 0xEB, 0xFF, 0xFF, 0xFF, 0xCF, 0xFF, 0xFF, 0xF0, // ## ######### ############## # ############################ ######################## 0xDF, 0xF7, 0xFF, 0xDF, 0xFF, 0xFF, 0xFF, 0xCF, 0xFF, 0xFF, 0xF0, // ## ######### ############# ############################### ######################## 0xD8, 0x07, 0x01, 0xDF, 0xFF, 0xE3, 0x1F, 0xDF, 0xFF, 0xFF, 0xF0, // ## ## ### ### ################ ## ####### ######################### 0xDB, 0xFF, 0xFF, 0xDF, 0xFE, 0x01, 0x0F, 0xBF, 0xF3, 0xFF, 0xF0, // ## ## #################### ############ # ##### ########## ############## 0xD8, 0x3F, 0xFF, 0xDF, 0xF2, 0x00, 0x0F, 0x7F, 0x7C, 0x1F, 0xF0, // ## ## ################ ######### # #### ####### ##### ######### 0xDF, 0xBF, 0xFF, 0xEF, 0xE0, 0x00, 0x0C, 0xC0, 0xFF, 0xE0, 0x70, // ## ###### ################# ####### ## ## ########### ### 0xD8, 0x3F, 0xF8, 0x77, 0xE0, 0x00, 0x0C, 0x1E, 0x7F, 0xFF, 0x80, // ## ## ########### ### ###### ## #### ################ 0xDB, 0xFF, 0xE7, 0xF8, 0xF0, 0x00, 0x8C, 0xFF, 0x7F, 0xFF, 0xF0, // ## ## ############# ######## #### # ## ######## ################### 0xD8, 0x07, 0x9F, 0xFF, 0x78, 0x43, 0xFB, 0xFF, 0x7F, 0xFF, 0xF0, // ## ## #### ############# #### # ####### ########## ################### 0xDF, 0xF7, 0x7F, 0xFF, 0xBC, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0xF0, // ## ######### ### ################ #### ####################### ################### 0xDF, 0xF6, 0xFF, 0xFF, 0xCF, 0xFF, 0xFF, 0xFE, 0x7F, 0xFF, 0xF0, // ## ######### ## ################## ########################### ################### 0xC0, 0x07, 0xFF, 0xC0, 0x07, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0xF0, // ## ############# ######################### #################### 0xFF, 0xFF, 0xFF, 0xBF, 0xFF, 0xFF, 0xFF, 0xC0, 0xFF, 0xFF, 0xF0, // ######################### ################################ #################### 0xC0, 0x07, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x0F, 0xFF, 0xFF, 0xF0, // ## ########### ############################### ######################## 0xDF, 0xF7, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x9F, 0xFF, 0xFF, 0xF0, // ## ######### ########## ################################# ######################### 0xDF, 0xF7, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xFF, 0xFF, 0xF0, // ## ######### ########## ################################## ######################### 0xD8, 0x37, 0xFF, 0x7F, 0x3F, 0xFF, 0xFF, 0xDF, 0xFF, 0xFF, 0xF0, // ## ## ## ########### ####### ######################## ######################### 0xDB, 0xB7, 0xFF, 0x80, 0x1F, 0xE7, 0x1F, 0xDF, 0xFF, 0xFF, 0xF0, // ## ## ### ## ############ ######## ### ####### ######################### 0xDB, 0xB7, 0xFE, 0x00, 0x3F, 0xC7, 0xDF, 0xD1, 0xFF, 0xFF, 0xF0, // ## ## ### ## ########## ######## ##### ####### # ##################### 0xD8, 0x37, 0xFC, 0xFC, 0x7F, 0x87, 0xCF, 0x88, 0x3F, 0xFF, 0xF0, // ## ## ## ######### ###### ######## ##### ##### # ################## 0xDF, 0xF7, 0xF9, 0xFF, 0xFF, 0xBF, 0xEF, 0x8F, 0xBF, 0xFF, 0xF0, // ## ######### ######## ################## ######### ##### ##### ################## 0xDF, 0xF7, 0xFB, 0xC0, 0xFF, 0xBF, 0xEF, 0xFF, 0x9F, 0xFF, 0xF0, // ## ######### ######## #### ######### ######### ############# ################# 0xC0, 0x07, 0xFB, 0x9F, 0x7F, 0xBF, 0xEF, 0xFF, 0x9F, 0xFF, 0xF0, // ## ######## ### ##### ######## ######### ############# ################# 0xFF, 0xFF, 0xF8, 0x1F, 0x7F, 0xBF, 0xCF, 0xFF, 0xBF, 0xFF, 0xF0, // ##################### ##### ######## ######## ############# ################## 0xFF, 0xFF, 0xFC, 0x3F, 0x3F, 0x9F, 0xDF, 0xFF, 0x3F, 0xFF, 0xF0, // ###################### ###### ####### ####### ############# ################## 0xC3, 0x87, 0xFF, 0x3F, 0xBF, 0xDF, 0xDF, 0xF8, 0x7F, 0xFC, 0xF0, // ## ### ########### ####### ######## ####### ########## ############# #### 0xDB, 0xB7, 0xFF, 0xFF, 0xDF, 0xCF, 0xC0, 0x03, 0xFF, 0x9F, 0x70, // ## ## ### ## ##################### ####### ###### ########### ##### ### 0xDA, 0xB7, 0xFF, 0xF8, 0x0F, 0xEF, 0xFF, 0xFF, 0xFF, 0x9F, 0x70, // ## ## # # ## ################ ####### ############################# ##### ### 0xD9, 0x37, 0xFF, 0xF7, 0xC7, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0x70, // ## ## # ## ############### ##### ###### #################################### ### 0xDB, 0xB7, 0xFF, 0xEF, 0xFF, 0xEF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, // ## ## ### ## ############## ############### ################################## #### 0xDF, 0xF7, 0xFF, 0xEF, 0xFF, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0x70, // ## ######### ############## ############### ################################### ### 0xDE, 0xF7, 0xFF, 0xEF, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0x9F, 0x70, // ## #### #### ############## ################ ############################ ##### ### 0xDD, 0x77, 0xFF, 0xE7, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0x9F, 0x70, // ## ### # ### ############## ############### ############################ ##### ### 0xC3, 0x87, 0xFF, 0xF0, 0x78, 0x03, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, // ## ### ############### #### ################################ #### 0xFF, 0xFF, 0xFF, 0xF8, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, // ############################# ############################################## }; //mosfets #define Tvorne PC13// GPIO ->470R ->groundet DB237 NPN->220R ->12V connected DB140 PNP->IRF1404 Gate ->gate Groundet with 220R #define Thinten PC14 #define Stepup150Watt PC15 //ledspotunit #define blau PB12 //active cooled spot light 2x 2Watt RGB + 2x 3Watt blue #define grun PB13 // led colors GPIO ->470R->D882->10yF capacitor parralel to LEDcolor #define rot PB11 // N4007 diode before red caused lower voltage #define blau1 PB14 #define blau2 PB15 #define fan1 PB10 //2x NPN DB237 connectet with 220R to stmPGIO charging 550yFcapacitors parralel to turbinefan on 12V for cooling mosfets #define fan2 PA0 //2x NPN D882 SMD with 2x 470R to STM GPIO charging 110yF parralel to turbine for cooling on high power leds soldered cooperwires in spot //input #define T1 PB5 //switching 470R groundet 3V3 to GPIO #define T2 PB6 #define T3 PB7 #define T4 PB8 #define T5 PB9 uint8_t contraent=28; //set contrast change displays are different void displaystart(void) {display.begin();display.setContrast(contraent);display.clearDisplay();display.setRotation(2);display.fillRect(0, 0, 84, 48, BLACK);display.drawBitmap(0,0, monstercat, 84, 48, WHITE);display.display();} boolean ONOFF=false; uint32_t led[5]; int8_t onpress[11]; uint16_t dutywidth=400; uint8_t steps=6; uint32_t TV,TH,W100; uint32_t blau_A=0; uint32_t blau_B=0; uint32_t blau_ziel=25; uint16_t fadespeed=600; uint32_t casefan1=300; uint32_t spotfan=300; uint32_t cooltarget=40; String farben[11]={"rot","pink","rosa","lila","blau","cyan","gren","gelb","orangr","weis"}; uint8_t setzen; void setup() { pinMode(rot, OUTPUT); pinMode(grun, OUTPUT); pinMode(blau, OUTPUT); pinMode(blau1, OUTPUT); pinMode(blau2, OUTPUT); pinMode(fan1, OUTPUT);pinMode(fan2, OUTPUT); pinMode(Tvorne, OUTPUT); pinMode(Thinten, OUTPUT); pinMode(Stepup150Watt, OUTPUT); pinMode(T1, INPUT); pinMode(T2, INPUT); pinMode(T3, INPUT); pinMode(T4, INPUT); pinMode(T5, INPUT); delay(100); displaystart(); delay(300); malscreen(); } void loop() { zeitreise(); } void drueckmich(void){ if (onpress[10] >=3) { if (digitalRead(T1) == HIGH && onpress[0] ==0 ) { onpress[0]=1; setzden(setzen,true); } if (onpress[0] == 1) { onpress[1]++; } if (onpress[1] >= 2) { onpress[1] =0; onpress[0]=0; } if (digitalRead(T2) == HIGH && onpress[2] ==0 ) { onpress[2] =1; setzden(setzen,false); } if (onpress[2] == 1) { onpress[3]++; } if (onpress[3] >= 10) { onpress[3] =0; onpress[2]=0; } if (digitalRead(T3) == HIGH && onpress[4] ==0 ) { onpress[4] =1; setzen++; if (setzen >4) {setzen=0;} } if (onpress[4] == 1) { onpress[5]++; } if (onpress[5] >= 20) { onpress[5] =0; onpress[4]=0; } if (digitalRead(T4) == HIGH && onpress[6] ==0 ) { onpress[6] =1; ONOFF=true; casefan1=300;spotfan=casefan1;} //start button set case and spot turbine fast for starting than slowdown.. if (onpress[6] == 1) { onpress[7]++; } if (onpress[7] >= 20) { onpress[7] =0; onpress[6]=0; } if (digitalRead(T5) == HIGH && onpress[8] ==0 ) { onpress[8] =1; ONOFF=false;} if (onpress[8] == 1) { onpress[9]++; } if (onpress[9] >= 20) { onpress[9] =0; onpress[8]=0; } onpress[10]=0; }} void setzden(int welch,boolean updown){ if(welch==0 && updown==true && TV =1){TV--;} if(welch==1 && updown==true && TH =1){TH--;} if(welch==2 && updown==true && W100 =1){W100--;} if(welch==3 && updown==true && cooltarget =1){cooltarget--;} if(welch==4 && updown==true && blau_A =1){blau_A--;blau_B--;} } void malscreen(){ display.clearDisplay();//84 48 display.fillRect(1,2,TV/10,8,BLACK); textso(TV/10+2,2,String(TV),1); display.fillRect(1,12,TH/10,8,BLACK); textso(TH/10+2,12,String(TH),1); display.fillRect(1,22,W100/10,8,BLACK); textso(W100/10+2,22,String(W100),1); textso(1,32,String(casefan1),1); textso(24,32,String(cooltarget),1); //lezte reihe display.drawFastVLine(14,41,7,BLACK);display.fillRect(29,40,4,8,BLACK); textso(1,41,String(blau_A/10),1); textso(17,41,String(blau_ziel/10),1); textso(34,41,String(led[1]/10),1); textso(48,40,farben[led[0]],1); display.drawRect(0,setzen*10,83,11,BLACK); if (ONOFF==false){textso(62,32,"OFF",1);} if (ONOFF==true){textso(62,32,"ON!",1);} display.display(); } void textso(int xhier,int yhier,String was,int gros){display.setCursor(xhier,yhier);display.setTextSize(gros); display.print(was);} void picone(){ if(led[1]==0){led[0]=random(0,10);led[1]=dutywidth;fadespeed=random(10,60)*20;} } void negativation(void){ if (led[1]>=1){led[1]--;} } void machblau(void){ if (blau_A>blau_ziel){blau_A--;}else{blau_A++;} if (blau_B>blau_ziel){blau_B--;}else{blau_B++;} if (blau_A==blau_ziel){blau_ziel=random(0,20)*20;} } void wuselzuspeed(void){ if(casefan1 > cooltarget){casefan1--;}else{casefan1++;} if(spotfan > cooltarget){spotfan--;}else{spotfan++;} } void coloursetz(){ // led[2] //0=colour, 1=bright, (2red3gren4blue 5=stillbrighttime) if (led[0]==0){ led[2]=led[1]; led[3]=0; led[4]=0;} //red if (led[0]==1){ led[2]=round(led[1]/2); led[3]=0; led[4]=round(led[1]/3);} //pink if (led[0]==2){ led[2]=round(led[1]/2); led[3]=0; led[4]=round(led[1]/2);} //mangenta if (led[0]==3){ led[2]=round(led[1]/3); led[3]=0; led[4]=round(led[1]/2);} //purple if (led[0]==4){ led[2]=0; led[3]=0; led[4]=led[1];} //blue if (led[0]==5){ led[2]=0; led[3]=round(led[1]/4); led[4]=round(led[1]/2);} //cyanblue if (led[0]==6){ led[2]=0; led[3]=led[1]; led[4]=led[1];} //cyan if (led[0]==7){ led[2]=0; led[3]=led[1]; led[4]=0;} //green if (led[0]==8){ led[2]=round(led[1]/3); led[3]=round(led[1]/2); led[4]=0;} //yellow if (led[0]==9){ led[2]=round(led[1]/2); led[3]=round(led[1]/3); led[4]=0;} //orange if (led[0]==10){ led[2]=led[1]; led[3]=led[1]; led[4]=led[1];} //white }//kittens kant kount.. whatever fuzzelfurrmind.. just mostly not absolutlyworking if furrfurrheadwridedown :3 long maintime=millis();long beaty=micros(); long timez=micros(); long flash=micros(); void zeitreise(void){ while ((millis()- maintime) >= 2){onpress[10]++; drueckmich();picone();maintime = millis();} while ((micros()- beaty) >= fadespeed) {negativation();machblau();beaty=micros();} while ((micros()- timez) >= 100) { if(ONOFF==true){spotty();} timez = micros();} while ((micros()-flash) >= 3000) { malscreen();wuselzuspeed(); //3000 caused 2670yF capacitors parralel to turbine channel(glued on headsink, they running little hot) if(ONOFF==true){schaltzeugs();} flash = micros();} } uint8_t multiply=1; uint8_t often=5; uint32_t dutycach=dutywidth*multiply; void schaltzeugs(void) { noLED();noOUT(); //for (int16_t parmal=0; parmal <=often; parmal++) { for (uint32_t laag=0; laag <=(dutycach); laag++) { if (laag == 0) {noOUT();} if (laag <= (dutycach-1) && laag >=1) { if (laag == (dutycach-(TV*multiply))) { digitalWrite(Tvorne, HIGH);} if (laag == (dutycach-(TH*multiply))) { digitalWrite(Thinten, HIGH);} if (laag == (dutycach-(W100*multiply))) { digitalWrite(Stepup150Watt, HIGH);}} if (laag >=dutycach) {noOUT();} } }//} void spotty(void) { coloursetz();noLED();nocooling(); for (uint16_t wusch=0; wusch <=(dutycach); wusch++) { if (wusch == 0) {noLED();nocooling();} if (wusch <= (dutycach-1) && wusch >=1) { if (wusch == (dutycach-(led[2]*multiply))) { digitalWrite(rot, HIGH);} if (wusch == (dutycach-(led[3]*multiply))) { digitalWrite(grun, HIGH);} if (wusch == (dutycach-(led[4]*multiply))) { digitalWrite(blau, HIGH);} if (wusch == (dutycach-(blau_A*multiply))) { digitalWrite(blau1, HIGH);} if (wusch == (dutycach-(blau_B*multiply))) { digitalWrite(blau2, HIGH);} if (wusch == (dutycach-(casefan1*multiply))) { digitalWrite(fan1, HIGH);} if (wusch == (dutycach-(spotfan*multiply))) { digitalWrite(fan2, HIGH);}} if (wusch >=dutycach) { noLED(); nocooling();} }} void noLED(void) {digitalWrite(rot,LOW); digitalWrite(grun,LOW); digitalWrite(blau,LOW); digitalWrite(blau1,LOW); digitalWrite(blau2,LOW);} void nocooling(void) {digitalWrite(fan1,LOW); digitalWrite(fan2,LOW);} void noOUT(void) {digitalWrite(Tvorne, LOW); digitalWrite(Thinten, LOW); digitalWrite(Stepup150Watt, LOW);}