#include #include #include #include #define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET); #define NUMFLAKES 10 #define XPOS 0 #define YPOS 1 #define DELTAY 2 #define LOGO16_GLCD_HEIGHT 16 #define LOGO16_GLCD_WIDTH 16 static const unsigned char PROGMEM logo16_glcd_bmp[] = { B00000000, B11000000, B00000001, B11000000, B00000001, B11000000, B00000011, B11100000, B11110011, B11100000, B11111110, B11111000, B01111110, B11111111, B00110011, B10011111, B00011111, B11111100, B00001101, B01110000, B00011011, B10100000, B00111111, B11100000, B00111111, B11110000, B01111100, B11110000, B01110000, B01110000, B00000000, B00110000 }; #if (SSD1306_LCDHEIGHT != 64) #error("Height incorrect, please fix Adafruit_SSD1306.h!"); #endif //i/os--------- #define rechts PB12 #define links PB13 #define slinks PB14 #define srechts PB15 #define tisch PA8 #define grun PA9 #define rot PA10 #define blau PA2 #define heat PA1 #define temp PB0 //end i/os void setup() { pinMode(rechts, INPUT); pinMode(links, INPUT); pinMode(slinks, INPUT); pinMode(srechts, INPUT); pinMode(tisch, INPUT); pinMode(blau, OUTPUT); pinMode(rot, OUTPUT); pinMode(grun, OUTPUT); pinMode(heat, OUTPUT); Serial.begin(9600); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64) display.clearDisplay(); // text display unverändertes display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0,0); display.println("Power"); display.drawRect(32, 0, 96, 34, WHITE); //ramen x,y,w,h display.setTextColor(WHITE); display.setTextSize(4); display.setCursor(103,3); display.println("%"); //display.println(0xDEADBEEF, HEX); display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0,45); display.println("0%^^^^^^^50%^^^^^100%"); display.display(); } int clinks = 0; int prozi =0; int woo = 80; int wooo = 0; int woooo = 0; int wis = 0; int bb = 0; int rr = 0; int gg = 0; int clicklinks =0; int clickrechts =0; int drucklinks =0; int druckrechts =0; int auftisch =0; int sets =1; int sets1 =0; int sets2 =25; int sets3 =50; int sets4 =75; int sets5 =100; int barb = 21; int count0 =10; int count1 =0; int count2 =0; int count3 =0; int count4 =0; int count5 =0; int count6 =0; int count7 =0; int count8 =0; int dutyaus = 0; int dutytime = 0; int watt1 = 0; int watt2 =0; int boost =0; long fcount = micros(); int tempy = 0; void loop() { sw(); clinks = digitalRead(links); if (rr == 0) { digitalWrite(rot, LOW);} if (rr == 1) { digitalWrite(rot, HIGH);} if (bb == 0) { digitalWrite(blau, LOW);} if (bb == 1) { digitalWrite(blau, HIGH);} if (gg == 0) { digitalWrite(grun, LOW);} if (gg == 1) { digitalWrite(grun, HIGH);} if (digitalRead(links) == HIGH) { clicklinks =2;} if (digitalRead(links) == LOW) { clicklinks =0;} if (digitalRead(rechts) == HIGH) { clickrechts =2;} if (digitalRead(rechts) == LOW) { clickrechts =0;} if (digitalRead(slinks) == HIGH) { drucklinks =2;} if (digitalRead(slinks) == LOW) { drucklinks =0;} if (digitalRead(srechts) == HIGH) { druckrechts =2;} if (digitalRead(srechts) == LOW) { druckrechts =0;} if (digitalRead(tisch) == HIGH) { auftisch =2;} if (digitalRead(tisch) == LOW) { auftisch =0;} display.fillRect(0, 37, 128, 7, BLACK); // settuings if (count0 > 1 ) { count0--; } if (count0 <= 1 && clickrechts == 2) {sets++; count0 =10; } if (count3 > 1 ) { count3--;} if (sets == 0) {sw(); prozi =sets1; wooo =0; bar(); if (drucklinks ==2 && prozi <= 98 && count3 <= 1) {sw(); sets1++; pfl(); count3 =10; setc();} if (druckrechts ==2 && prozi > 0 && count3 <= 1) {sw(); sets1--; pfr(); count3 =10; setc();}} if (sets == 1) {sw(); prozi = sets2; wooo =24; bar(); if (drucklinks ==2 && prozi <= 98 && count3 <= 1) {sw(); sets2++; pfl(); count3 =5; setc();} if (druckrechts ==2 && prozi > 10 && count3 <= 1) {sw(); sets2--; pfr(); count3 =5; setc();}} if (sets == 2) {sw(); prozi = sets3; wooo =48; bar(); if (drucklinks ==2 && prozi <= 98 && count3 <= 1) {sw(); sets3++; pfl(); count3 =5; setc();} if (druckrechts ==2 && prozi > 10 && count3 <= 1) {sw(); sets3--; pfr(); count3 =5; setc();}} if (sets == 3) {sw(); prozi = sets4; wooo =72; bar(); if (drucklinks ==2 && prozi <= 98 && count3 <= 1) {sw(); sets4++; pfl(); count3 =5; setc();} if (druckrechts ==2 && prozi > 10 && count3 <= 1) {sw(); sets4--; pfr(); count3 =5; setc();}} if (sets == 4) {sw(); prozi = sets5; wooo =96; bar(); if (drucklinks ==2 && prozi < 100 && count3 <= 1) {sw(); sets5++; pfl(); bar(); count3 =2; setc();} if (druckrechts ==2 && prozi > 10 && count3 <= 1) {sw(); sets5--; pfr(); count3 =2; setc();}} if (sets == 5) {sets =0;} if (drucklinks ==0 ) {noc();} if (druckrechts ==0) {noc();} //blink standby if (auftisch ==2) { count1++; if (count1 == 2) {digitalWrite(blau, HIGH); } if (count1 == 3) {digitalWrite(blau, LOW); } if (count1 == 100) {digitalWrite(blau, HIGH); display.invertDisplay(true); } if (count1 == 102) {digitalWrite(rot, HIGH); } if (count1 == 104) {digitalWrite(rot, LOW); } if (count1 == 105) {digitalWrite(grun, HIGH); } if (count1 == 106) {digitalWrite(blau, LOW); } if (count1 == 107) {digitalWrite(grun, LOW); display.invertDisplay(false); } if (count1 == 205) {digitalWrite(grun, HIGH); } if (count1 == 206) {digitalWrite(rot, HIGH); } if (count1 == 207) {digitalWrite(grun, LOW); } if (count1 == 208) {digitalWrite(blau, HIGH); } if (count1 == 209) {digitalWrite(rot, LOW); } if (count1 == 210) {digitalWrite(blau, LOW); } if (count1 >= 310) {count1 =0; } } //heizen+blink if (clicklinks == 0) {count2 =0;} if (count2 <= 31 && clicklinks ==2) {count2++; count4++;} display.fillRect(prozi / 0.875, 38, 14, 5, WHITE); display.setTextSize(4); if (prozi >= 0 && prozi < 10) {woo = 80;} if (prozi == 100) {woo = 34;} if (prozi < 100 && prozi > 9) {woo = 56;} display.setCursor(woo,3); display.setTextColor(WHITE); display.println(prozi); display.setTextSize(1); display.setCursor(0,8); if (count0 >=2) { display.setTextColor(BLACK, WHITE); display.println(count0); } if (count0 <= 1) { display.setTextColor(WHITE, BLACK); display.println(count0); } display.setCursor(12,8); display.setTextColor(BLACK, WHITE); display.println(count1); display.setCursor(0,16); display.println(count5); tempy = analogRead(temp) /42; if (tempy >= 0 && tempy <= 9) { display.setCursor(0,24); display.print("0"); display.print(tempy); display.print(" C"); } if (tempy >= 10 && tempy <= 99) { display.setCursor(0,24); display.print(tempy); display.print(" C"); } //blinkheiz if (clicklinks == 0) { digitalWrite(heat, LOW ); count5 =0;display.display();} if (clicklinks == 2) { dampf(); count2++; if (count2 == 1 | count2 == 5 | count2 == 10 | count2 == 15 | count2 == 20) { digitalWrite(grun, HIGH);} if (count2 == 3 | count2 == 8 | count2 == 13 | count2 == 18 | count2 == 23) { digitalWrite(grun, LOW);} if (count2 == 25 | count2 == 30 | count2 == 35 | count2 == 40 | count2 == 45) { digitalWrite(blau, HIGH);} if (count2 == 28 | count2 == 33 | count2 == 38 | count2 == 43 | count2 == 48) { digitalWrite(blau, LOW);} if (count2 >= 50) {count2 =0; digitalWrite(grun, LOW); digitalWrite(blau, LOW); } } } //endloop //platzsparfunktionen void dampf(void){ count5++; if (prozi <= 29) { boost =30;} if (prozi >= 30) boost = (100 - prozi); if (count5 >= (boost + 2)) {dutyaus = ((100 - prozi ))* (1000 / watt1); dutytime =100000 /watt1; } // prozi * 6;} //watt1 0-100 watt2 * if (count5 <= boost) {digitalWrite(rot, HIGH ); digitalWrite(heat, HIGH );} proziact(); if ((micros()-fcount) >= dutyaus) { digitalWrite(rot, HIGH ); digitalWrite(heat, HIGH );} if ((micros()-fcount) >= dutytime) { fcount = micros(); digitalWrite(heat, LOW ); count6++; } if (count6 >=2) { digitalWrite(rot, HIGH ); count6 = 0;} } void proziact(void) { count7++; if ((prozi >= 4) && (prozi % 2) == 0) { watt1 = 2; } else {watt1 = 1;} if (count7 >= 200){ digitalWrite(heat, LOW ); display.display(); count7 = 0;} } void bar(void){ display.fillRect(0, 53, 128, 11, BLACK); display.setTextColor(WHITE); display.setTextSize(1); display.setCursor(2,55); if (sets1 <=8) {display.print(" ");} display.print(sets1); display.print("% "); display.print(sets2); display.print("% "); display.print(sets3); display.print("% "); display.print(sets4); if (sets5 <=99) {display.print("% ");} if (sets5 == 100) { display.print("% ");} display.print(sets5); display.print("% "); if (prozi >= 100 && sets ==4) {barb =27; } if (prozi <=99) {barb =21;} if (sets == 4 && prozi <= 99) {wooo = 102;} display.drawRect(wooo, 53, barb, 11, WHITE); } void pfl(void){ display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(prozi / 0.875 +6,37); display.println("->"); } void pfr(void){ display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(prozi / 0.875 -4,37); display.println("<-"); } void sw(void) { display.fillRect(34, 1, 68, 32, BLACK); } void setc(void) { count8 =0; if (prozi >= 80) { digitalWrite(rot, HIGH); } if (prozi <= 79) { digitalWrite(rot, LOW); } if (prozi >= 90) { digitalWrite(blau, HIGH); } if (prozi <= 89) { digitalWrite(blau, LOW); } if (prozi <= 49) { digitalWrite(grun, HIGH); } if (prozi >= 50) { digitalWrite(grun, LOW); } } void noc(void) { if (count8 == 3) { digitalWrite(blau, LOW); digitalWrite(grun, LOW); digitalWrite(rot, LOW); } } /* * MEOW! STM32 program (main actions) * by marderchen =^.^= working fine but currently uses 32/65Kbyte cach from STM32F103C8T6 so enough place for bitmapsdata, better font,...) * do what you want! * ___ * _.-| | / |\__/,| (`\ { | | -- |^ ^ |__ _) ) "-.|___| \ _.( Y ) ` / .--'-`-. _((_ `^--' /__< \ ....-+|______|__.-||__)`-' (((/ (((/ CATS are awesome! */