diff --git a/reaktionstesterclean.ino b/reaktionstesterclean.ino index 7d2c147..854ec94 100644 --- a/reaktionstesterclean.ino +++ b/reaktionstesterclean.ino @@ -3,6 +3,37 @@ #include #include +// Bonus code +class pixeldraw { + private: + LiquidCrystal_I2C* lcd; + void constructbuf(int x, int y, byte* buf) { + buf[y] = B10000 >> x; + return buf; + } + public: + pixeldraw(LiquidCrystal_I2C* _lcd) { + lcd = _lcd; + } + + void setpix(int _x, int _y) { + // calculate cell x and y + int cellx = _x/5; + int celly = _y/8; + int x = _x%5; // calculate modulo + int y = _y%8; // calculate modulo + + byte buf[8] = { // load from cellbuf + 0,0,0,0,0,0,0,0 + }; + constructbuf(x,y,buf); + lcd->createChar(cellx+(celly*16), buf); + lcd->clear(); + lcd->setCursor(cellx, celly); + lcd->write(byte(cellx+(celly*16))); + } +}; + int led = 7; // pin Nummern für jwl. Komponente int bt = 8; long highscore = 999999; // speichert highscore in einer Variable @@ -19,6 +50,13 @@ void setup() { lcd.init(); // LCD initialisieren lcd.clear(); lcd.backlight(); // backlight an machen + pixeldraw drawer(&lcd); + for (int y=0;y<(8*8);y++) { + for (int x=0;x<(16*5);x++) { + drawer.setpix(x, y); + delay(1); + } + } } void loop() {