//adjustable turbine driver 3x IRF1404 //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 []= { 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, // ############################# ############################################## }; #define Tvorne PC13 #define Thinten PC14 #define Stepup150Watt PC15 #define blau PA0 //later #define grun PA1 #define rot PA2 #define T1 PB5 #define T2 PB6 #define T3 PB7 #define T4 PB8 #define T5 PB9 uint8_t contraent=25; 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 leds[7]; int8_t onpress[11]; uint16_t dutywidth=400; uint8_t steps=6; uint32_t TV,TH,W100; uint8_t setzen; void setup() { pinMode(rot, OUTPUT); pinMode(grun, OUTPUT); pinMode(blau, 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 >2) {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;} 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; } if(digitalRead(T1)==HIGH || digitalRead(T2)==HIGH || digitalRead(T3)==HIGH || digitalRead(T4)==HIGH || digitalRead(T5) ==HIGH){malscreen();} 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--;} } void malscreen(){ display.clearDisplay();//84 48 display.fillRect(4,40-(TV/10),10,TV/10,BLACK); textso(0,41,String(TV),1); display.fillRect(32,40-(TH/10),10,TH/10,BLACK); textso(28,41,String(TH),1); display.fillRect(60,40-(W100/10),10,W100/10,BLACK); textso(56,41,String(W100),1); display.drawRect(setzen*28+2,0,14,41,BLACK); if (ONOFF==false){textso(20,0,"OFF",2);} if (ONOFF==true){textso(20,0,"ON",2); display.fillRect(20,0,6,40,BLACK);display.fillRect(48,0,6,40,BLACK);display.fillRect(76,0,6,40,BLACK);} display.display(); } void textso(int xhier,int yhier,String was,int gros){display.setCursor(xhier,yhier);display.setTextSize(gros); display.print(was);} long maintime=millis();long beaty=micros(); long timez=micros(); long flash=micros(); void zeitreise(void){ while ((millis()- maintime) >= 2){onpress[10]++; drueckmich();maintime = millis();} while ((micros()- beaty) >= 100) {beaty=micros();} while ((micros()- timez) >= 300) {timez = micros();} while ((micros()-flash) >= 3000) { 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) {noLED();noOUT();} if (laag <= (dutycach-1) && laag >=1) { if (laag == (dutycach-(leds[2]*multiply))) { digitalWrite(rot, HIGH);} if (laag == (dutycach-(leds[3]*multiply))) { digitalWrite(grun, HIGH);} if (laag == (dutycach-(leds[4]*multiply))) { digitalWrite(blau, HIGH);} 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) { noLED(); noOUT();} } }//} void noLED(void) {digitalWrite(rot,LOW); digitalWrite(grun,LOW); digitalWrite(blau,LOW);} void noOUT(void) {digitalWrite(Tvorne, LOW); digitalWrite(Thinten, LOW); digitalWrite(Stepup150Watt, LOW);}