//pins TFT ::VCC on 3.3V ::LED on 3.3V ::GND on GND :: CS on PB1 :: Reset on PB0 :: not>DC/RS on PA4 MISO on A6 150Ohm>D882>GND from12V #define N01 PB9 #define N02 PB8 #define N03 PB7 #define N04 PB6 #define N05 PB5 #define N06 PA10 #define N07 PA9 #define N08 PA8 #define N09 PB15 #define N10 PB14 #define N11 PB13 #define N12 PB12 #define N13 PC13 #define N14 PC14 #define N15 PC15 #define N16 PA2 #define N17 PA3 #define N18 PB1 #define N19 PB10 #define N20 PB11 #define tasterM PA0 #define x PA0 #define moduls 20 #define steps 60 #define swap(a, b) { int16_t t = a; a = b; b = t; } Adafruit_ILI9341_STM tft = Adafruit_ILI9341_STM(PA6,PA4,PB0); // Use hardware SPI //like cats :3 so a cute OLED bootpicture const unsigned char PROGMEM cat [] = // width 66px height 46 { 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, // ## 0x00, 0x00, 0x0F, 0x0E, 0x18, 0x60, 0x00, 0x00, 0x00, // #### ### ## ## 0x00, 0x00, 0x04, 0x94, 0xF9, 0xE0, 0x00, 0x00, 0x00, // # # # # ##### #### 0x00, 0x00, 0x02, 0x67, 0xB7, 0x40, 0x00, 0x00, 0x00, // # ## #### ## ### # 0x00, 0x3F, 0xFC, 0x22, 0x26, 0x40, 0x00, 0x00, 0x00, // ############ # # # ## # 0x01, 0xE0, 0x04, 0x62, 0x2C, 0x60, 0x00, 0x00, 0x00, // #### # ## # # ## ## 0x07, 0x00, 0x00, 0x02, 0x38, 0x3F, 0xF8, 0x00, 0x00, // ### # ### ########### 0x3C, 0x00, 0x00, 0x02, 0x10, 0x00, 0x0F, 0x80, 0x00, // #### # # ##### 0x60, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, // ## ##### #### 0xDF, 0xE0, 0x7F, 0xE0, 0x01, 0xFE, 0x00, 0x1C, 0x00, // ## ######## ########## ######## ### 0xF0, 0x30, 0xFF, 0xF0, 0x07, 0xFF, 0x00, 0x07, 0x00, // #### ## ############ ########### ### 0x80, 0x18, 0xFF, 0xF0, 0x0F, 0xFF, 0x00, 0x01, 0x80, // # ## ############ ############ ## 0xC0, 0x31, 0xFF, 0xF8, 0x1F, 0xFF, 0x83, 0xFC, 0xC0, // ## ## ############## ############## ######## ## 0x41, 0x19, 0xFF, 0xF8, 0x1F, 0xFF, 0x82, 0x07, 0xC0, // # # ## ############## ############## # ##### 0x61, 0xF1, 0xFF, 0xF8, 0x1F, 0xFF, 0xCE, 0x00, 0x40, // ## ##### ############## ############### ### # 0x20, 0x81, 0xFF, 0xFC, 0x1F, 0xFF, 0xC7, 0xC0, 0x40, // # # ############### ############### ##### # 0x30, 0x71, 0xFF, 0xFC, 0x3F, 0xFF, 0xC0, 0x40, 0xC0, // ## ### ############### ################ # ## 0x10, 0x39, 0x3F, 0xE4, 0x3F, 0xFF, 0xC1, 0x80, 0x80, // # ### # ######### # ################ ## # 0x18, 0x41, 0x00, 0x04, 0x3F, 0xFE, 0x66, 0x00, 0x80, // ## # # # ############# ## ## # 0x0E, 0x01, 0xFF, 0xE4, 0x3F, 0xF0, 0x23, 0x01, 0x80, // ### ############ # ########## # ## ## 0x03, 0x01, 0xC0, 0x3C, 0x20, 0x00, 0x20, 0x03, 0x00, // ## ### #### # # ## 0x01, 0x81, 0x00, 0x08, 0x3F, 0x00, 0x20, 0x02, 0x00, // ## # # ###### # # 0x00, 0x80, 0x00, 0x00, 0x31, 0xFE, 0x60, 0x06, 0x00, // # ## ######## ## ## 0x00, 0xC0, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x0C, 0x00, // ## #### ## 0x00, 0x70, 0x0F, 0xE0, 0x00, 0x00, 0xC0, 0x18, 0x00, // ### ####### ## ## 0x00, 0x1C, 0x38, 0x11, 0xE7, 0xF0, 0x00, 0x30, 0x00, // ### ### # #### ####### ## 0x00, 0x04, 0x60, 0xF1, 0xC3, 0x9C, 0x00, 0x60, 0x00, // # ## #### ### ### ### ## 0x00, 0x0C, 0xC1, 0x80, 0x80, 0xC6, 0x40, 0xC0, 0x00, // ## ## ## # ## ## # ## 0x00, 0x10, 0x83, 0x00, 0x00, 0x60, 0x67, 0x80, 0x00, // # # ## ## ## #### 0x00, 0xE0, 0x06, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, // ### ## #### 0x01, 0x80, 0x04, 0x00, 0x80, 0x80, 0x30, 0x00, 0x00, // ## # # # ## 0x00, 0xFF, 0x80, 0x20, 0x81, 0xF0, 0x0E, 0x00, 0x00, // ######### # # ##### ### 0x00, 0x18, 0x60, 0x11, 0xC6, 0x18, 0x03, 0xC0, 0x00, // ## ## # ### ## ## #### 0x00, 0x60, 0x00, 0x1F, 0x7C, 0x0C, 0x3C, 0x60, 0x00, // ## ##### ##### ## #### ## 0x00, 0x7F, 0x80, 0x14, 0x28, 0x04, 0x07, 0xC0, 0x00, // ######## # # # # # ##### 0x00, 0x43, 0xF0, 0x18, 0x1E, 0x34, 0x01, 0x00, 0x00, // # ###### ## #### ## # # 0x00, 0x02, 0x1C, 0x00, 0x02, 0x1C, 0x3D, 0x00, 0x00, // # ### # ### #### # 0x00, 0x06, 0x00, 0x00, 0x03, 0x10, 0x67, 0x80, 0x00, // ## ## # ## #### 0x00, 0x01, 0xC0, 0x00, 0x01, 0xB0, 0x34, 0x00, 0x00, // ### ## ## ## # 0x00, 0x00, 0x78, 0x00, 0x00, 0xE7, 0xF8, 0x00, 0x00, // #### ### ######## 0x00, 0x00, 0x0E, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, // ### ### 0x00, 0x00, 0x03, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, // ## # 0x00, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, // # # 0x00, 0x00, 0x01, 0x80, 0x00, 0x60, 0x00, 0x00, 0x00, // ## ## 0x00, 0x00, 0x00, 0x80, 0x00, 0x40, 0x00, 0x00, 0x00, // # # 0x00, 0x00, 0x00, 0x80, 0x00, 0x40, 0x00, 0x00, 0x00, // # # }; #define graphsize 135 uint32_t rainbow[129] = {0xff0000,0xff0d00,0xff1a00,0xff2700,0xff3300,0xff4000,0xff4d00,0xff5a00,0xff6400,0xff6d00,0xff7700,0xff8100,0xff8a00,0xff9400,0xff9900,0xff9e00,0xffa300,0xffa700,0xffac00,0xffb100,0xffb600,0xffbb00,0xffbf00,0xffc400,0xffc900,0xffce00,0xffd200,0xffd700,0xfcde00,0xfae400,0xf7eb00,0xf4f200,0xf2f800,0xefff00,0xeaff00,0xe6ff00,0xe1ff00,0xddff00,0xd8ff00,0xd4ff00,0xcfff00,0xc7ff00,0xbfff00,0xb7ff00,0xafff00,0xa7ff00,0x9fff00,0x97ff00,0x8eff00,0x84ff00,0x7bff00,0x72ff00,0x68ff00,0x5fff00,0x51ff06,0x44ff0b,0x36ff11,0x29ff17,0x1bff1d,0x0eff22,0x00ff28,0x00ff3a,0x00ff4b,0x00ff5d,0x00ff6e,0x00ff80,0x00ff91,0x00ffa3,0x00ffab,0x00ffb3,0x00ffbb,0x00ffc3,0x00ffcb,0x00ffd3,0x00ffdb,0x00ffe0,0x00ffe6,0x00ffeb,0x00fff0,0x00fff6,0x00fffb,0x00f6fc,0x00edfc,0x00e4fd,0x00dbfd,0x00d2fe,0x00c9fe,0x00c0ff,0x00b6ff,0x00adff,0x00a3ff,0x009aff,0x0090ff,0x0087ff,0x007dff,0x0968ff,0x1253ff,0x1c3fff,0x252aff,0x2e15ff,0x3700ff,0x3c00ff,0x4000ff,0x4500ff,0x4a00ff,0x4f00ff,0x5300ff,0x5800ff,0x6200ff,0x6b00ff,0x7500ff,0x7f00ff,0x8900ff,0x9200ff,0x9c00ff,0x9f00ff,0xa300ff,0xa600ff,0xa900ff,0xad00ff,0xb000ff,0xa800f4,0xa000e8,0x9800dd,0x9100d1,0x8900c6,0x8100ba,0x7900af}; uint8_t r,g,b;boolean updatez=false; void setup(){ delay(100); pinMode(N01,OUTPUT);pinMode(N02,OUTPUT);pinMode(N03,OUTPUT);pinMode(N04,OUTPUT);pinMode(N05,OUTPUT);pinMode(N06,OUTPUT);pinMode(N07,OUTPUT);pinMode(N08,OUTPUT);pinMode(N09,OUTPUT);pinMode(N10,OUTPUT); pinMode(N11,OUTPUT);pinMode(N12,OUTPUT);pinMode(N13,OUTPUT);pinMode(N14,OUTPUT);pinMode(N15,OUTPUT);pinMode(N16,OUTPUT);pinMode(N17,OUTPUT);pinMode(N18,OUTPUT);pinMode(N19,OUTPUT);pinMode(N20,OUTPUT);delay(600);displaystart();} void displaystart(void) {tft.begin(); tft.fillScreen(ILI9341_BLACK); tft.setRotation(3);wuselbitmap(30,50,cat,66,46,0,"vertikal",100,true); textso(11,59,"marderchen",1,0x0fff);textso(14,68,"device =^.^=",1,0xf0ff);} int8_t onpress[18],toleranz=50;int16_t fasty=18,wert,fcount1,auch; uint16_t cach[moduls+1][steps+1],modul[moduls][4],dutyout[steps+1],modulz=6,stepz;; uint16_t dasist[]={3700,3400,3150,2900,2700,2550,2400},fadefine=200;//measure values oh just many taster you want with one GPIO and resistors void loop(){zeitreise();} long maintime=millis(),flink=micros(),setz=millis(); void zeitreise(void){ while ((millis()- maintime) >=20) { drueckmich(); maintime = millis();} while ((millis()- setz) >=fasty) { for(uint8_t kk=0;kk0){modul[kk][0]--;}//wiederhol :%modulator value :duty start value if(modul[kk][0]<=0){modul[kk][0]=random(400,800);modul[kk][1]=random(2,16);modul[kk][2]=100;} cach[kk][stepz]=0;dutyout[kk]=0; if(stepz%modul[kk][1]==0){cach[kk][stepz]=modul[kk][2];dutyout[kk]=modul[kk][2];} } stepz++;if(stepz>=steps){stepz=0;displayzeig();auch++;} if(auch > 20){auch=random(8,16);fasty=random(10,24);} setz = millis();} while ((micros()- flink) >= 20) { schalte(); flink=micros();}} void displayzeig(void){ for(uint8_t rf=0;rf=2) {onpress[14]=0; wert=analogRead(tasterM); if (wert>(dasist[0]-toleranz)&&wert<(dasist[0]+toleranz)&& onpress[0] ==0) {onpress[0]=1;} if (onpress[0]==1){onpress[1]++;}if(onpress[1]>=10){onpress[1]=0;onpress[0]=0;} if (wert>(dasist[1]-toleranz)&&wert<(dasist[1]+toleranz)&& onpress[2] ==0) {onpress[2]=1;} if (onpress[2]==1){onpress[3]++;}if(onpress[3]>=15){onpress[3]=0;onpress[2]=0;} if (wert>(dasist [2]-toleranz)&&wert<(dasist[2]+toleranz)&& onpress[4] ==0) {onpress[4] =1;} if (onpress[4]==1){onpress[5]++;}if(onpress[5]>=10){onpress[5]=0;onpress[4]=0;} if (wert>(dasist[3]-toleranz)&&wert<(dasist[3]+toleranz)&& onpress[6] ==0) {onpress[6] =1;} if (onpress[6]==1){onpress[7]++;}if(onpress[7]>=20){onpress[7]=0;onpress[6]=0;} if (wert>(dasist[4]-toleranz)&&wert<(dasist[4]+toleranz)&& onpress[8] ==0) {onpress[8] =1;} if (onpress[8]==1){onpress[9]++;}if(onpress[9]>=10){onpress[9]=0;onpress[8]=0;} if (wert>(dasist[5]-toleranz)&&wert<(dasist[5]+toleranz)&& onpress[10] ==0) {onpress[10] =1;} if (onpress[10]==1){onpress[11]++;}if(onpress[11]>=10){onpress[11]=0;onpress[10]=0;} // if(updatez==true){displayzeig();updatez=false;} for(uint8_t durchgeh=0;durchgeh<12;durchgeh+=2){if(onpress[durchgeh]==1){updatez=true;}} }} void schalte(void) { if (fcount1 < fadefine && fcount1>=1) { if (fcount1 == ((fadefine)-dutyout[0])) { digitalWrite(N01,HIGH);} if (fcount1 == ((fadefine)-dutyout[1])) { digitalWrite(N02,HIGH);} if (fcount1 == ((fadefine)-dutyout[2])) { digitalWrite(N03,HIGH);} if (fcount1 == ((fadefine)-dutyout[3])) { digitalWrite(N04,HIGH);} if (fcount1 == ((fadefine)-dutyout[4])) { digitalWrite(N05,HIGH);} if (fcount1 == ((fadefine)-dutyout[5])) { digitalWrite(N06,HIGH);} if (fcount1 == ((fadefine)-dutyout[6])) { digitalWrite(N07,HIGH);} if (fcount1 == ((fadefine)-dutyout[7])) { digitalWrite(N08,HIGH);} if (fcount1 == ((fadefine)-dutyout[8])) { digitalWrite(N09,HIGH);} if (fcount1 == ((fadefine)-dutyout[9])) { digitalWrite(N10,HIGH);} if (fcount1 == ((fadefine)-dutyout[10])) { digitalWrite(N11,HIGH);} if (fcount1 == ((fadefine)-dutyout[11])) { digitalWrite(N12,HIGH);} if (fcount1 == ((fadefine)-dutyout[12])) { digitalWrite(N13,HIGH);} if (fcount1 == ((fadefine)-dutyout[13])) { digitalWrite(N14,HIGH);} if (fcount1 == ((fadefine)-dutyout[14])) { digitalWrite(N15,HIGH);} if (fcount1 == ((fadefine)-dutyout[15])) { digitalWrite(N16,HIGH);} if (fcount1 == ((fadefine)-dutyout[16])) { digitalWrite(N17,HIGH);} if (fcount1 == ((fadefine)-dutyout[17])) { digitalWrite(N18,HIGH);} if (fcount1 == ((fadefine)-dutyout[18])) { digitalWrite(N19,HIGH);} if (fcount1 == ((fadefine)-dutyout[19])) { digitalWrite(N20,HIGH);} if (fcount1 >= (fadefine)) {aus();}} fcount1++;if(fcount1>fadefine){fcount1=0;aus();}} void aus(void) { digitalWrite(N01,LOW);digitalWrite(N02,LOW);digitalWrite(N03,LOW);digitalWrite(N04,LOW);digitalWrite(N05,LOW);digitalWrite(N06,LOW);digitalWrite(N07,LOW);digitalWrite(N08,LOW);digitalWrite(N09,LOW);digitalWrite(N10,LOW); digitalWrite(N11,LOW);digitalWrite(N12,LOW);digitalWrite(N13,LOW);digitalWrite(N14,LOW);digitalWrite(N15,LOW);digitalWrite(N16,LOW);digitalWrite(N17,LOW);digitalWrite(N18,LOW);digitalWrite(N19,LOW);digitalWrite(N20,LOW);} void writegraph(void){} int weniger=0; //thanks to adafruit for PROGMAN algoritm void wuselbitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t cpos,String way,int16_t scal,boolean reverse) { //scal = 1 /100) int16_t istcol=0;int16_t i, j, byteWidth = (w + 7) / 8; for(j=0; j> (i & 7))) { if (reverse ==false ) { tft.fillRect(x+(((i-w/2)*scal/100)-((w*(scal/100))/2)), y+(((j-h/2)*scal/100)-((h*(scal/100))/2)),scal/50,scal/50, tft.color565(r,g,b));} if (reverse ==true) { tft.drawPixel(x-(((i-w/2)*(scal/100))-((w*(scal/100))/2)), y+(((j-h/2)*(scal/100))-((h*(scal/100))/2)), tft.color565(r,g,b));} }}} } void textso(int xhier,int yhier,String was,int gros,int16_t colz){tft.setTextColor(colz);tft.setCursor(xhier,yhier);tft.setTextSize(gros); tft.print(was);} void zahlso(int xda,int yda,int mich,int grosz,int16_t colc){String michauch=""; tft.setTextSize(grosz); tft.setCursor(xda,yda); tft.setTextColor(colc); if (mich <9) {michauch+="0";} if (mich <99) {michauch+="0";} if (mich <999) {michauch+="0";} michauch+=mich; tft.println(michauch);} //kote by marderchen =^.^= use if you want :3 STM32F103C8T6 93 chip board used void wuselfillrect(int16_t eckex, int16_t eckey,int16_t breit, int16_t hoch,uint32_t colorspeed,boolean colormove) { for( int ry = eckex; ry < (hoch); ry++) { wuselline(eckex,eckey+ry,eckex+breit,eckey+ry,colorspeed,colormove);}} void wuselrect(int16_t eckex, int16_t eckey,int16_t breit, int16_t hoch,uint32_t colorspeed,boolean colormove) { wuselline(eckex+breit,eckey,eckex,eckey,colorspeed,colormove); wuselline(eckex+breit,eckey,eckex+breit,eckey+hoch,colorspeed,colormove); wuselline(eckex+breit,eckey+hoch,eckex,eckey+hoch,colorspeed,colormove); wuselline(eckex,eckey+hoch,eckex,eckey,colorspeed,colormove);} int rainbowcolor,rainbowcolor2,colorslows,colorslows2; //Bresenham's algorithm - thx wikpedia (and adafruit) but the marderchenmod void wuselline(int16_t x0, int16_t y0,int16_t x1, int16_t y1,uint32_t colorspeed,boolean colormove) { //if colormove =false, colorspeed = color ( 0xFF205B etc.) int16_t steep = abs(y1 - y0) > abs(x1 - x0); if (steep) {swap(x0, y0);swap(x1, y1);} if (x0 > x1) {swap(x0, x1);swap(y0, y1);} int16_t dx, dy;dx = x1 - x0;dy = abs(y1 - y0); int16_t err = dx / 2;int16_t ystep; if (y0 < y1) {ystep = 1;} else {ystep = -1;} for (; x0<=x1; x0++) {colorslows2++; if (colorslows2 >1) {rainbowcolor +=colorspeed; colorslows2=0;} if (rainbowcolor >=128) { rainbowcolor =0;} if (steep) { if (colormove == true) { colory(rainbow[rainbowcolor]); tft.drawPixel(y0, x0, tft.color565(r,g,b));}if (colormove == false) { colory(colorspeed); tft.drawPixel(y0, x0,tft.color565(r,g,b));} } else { if (colormove == true) { colory(rainbow[rainbowcolor]); tft.drawPixel(x0, y0, tft.color565(r,g,b));}if (colormove == false) { colory(colorspeed); tft.drawPixel(x0, y0, tft.color565(r,g,b));}} err -= dy;if (err < 0) {y0 += ystep;err += dx;}}} void colory(uint32_t colorz) { String hexcolor = String(colorz); int number = hexcolor.toInt(); r = number >> 16; g = number >> 8 & 0xFF; b = number & 0xFF;}