A simple barmeter(click for bar meter using u8g2 lib) #include <Arduino.h> #include <U8g2lib.h> #include <SPI.h> // JDN for 1.3 SPI 128x64 display based on SH1106 display chip // Beer license 2020 Jens Dalsgaard Nielsen // http://jensd.dk/edu/doc/esp32/mono-oleds.html // https://github.com/olikraus/u8g2/wiki/u8g2reference U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2 (U8G2_R0, 5, 22, 17); void setup() { u8g2.begin(); } void barMeter(int x1, int y1, int w, int h, float vall) { int m; // clip to be in interval [0-1] to be safe // its up to you to scale bef call if (1.0 < vall) vall = 1.0; else if (vall < 0.0) vall = 0.0; u8g2.setDrawColor(1); u8g2.drawFrame(x1, y1, w, h); x1++; y1++; h -= 2; w -= 2; u8g2.setDrawColor(0); u8g2.drawBox(x1, y1, w, h); // clear interior u8g2.setDrawColor(1); m = round(h * vall); y1 += (h - m); h = m; u8g2.drawBox(x1, y1, w, h); } int i = 0; void loop() { u8g2.clearBuffer(); /* upper right x,y width, height, val [0.0 - 1.0] */ barMeter( 1, 1, 10, 30, 0.5 + 0.5 * sin(i) ); barMeter( 20, 1, 5, 20, 0.5 + 0.5 * sin(i) ); u8g2.sendBuffer(); delay(100); i += 1; } Tilde (vippe) example - a small game#include <Arduino.h> #include <U8g2lib.h> #include <SPI.h> #include "GY521.h" // http://jensd.dk/edu/doc/esp32/mono-oleds.html // https://github.com/olikraus/u8g2/wiki/u8g2reference /* NodeMCU ESP32S OLED ___________________________ GND GND 3.3V VDD VSPI MOSI SDA VSPI SCK SCK VSPI SS CS GPIO 17 RES GPIO16 DC */ //#define BUG1 #define SPI_CS 5 #define SPI_DC 16 #define SPI_RESET 17 //U8G2_R0 rotation U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, SPI_CS, SPI_DC, SPI_RESET); #define MPU6050Addr 0x68 GY521 MPU6050sensor(MPU6050Addr); float ax, ay, az, gxe, gye, gze, temp; int xP = 63, yP = 31; void initMPU6050() { delay(100); while (MPU6050sensor.wakeup() == false) { Serial.print(millis()); Serial.println("\tCould not connect to GY521"); delay(1000); } MPU6050sensor.setAccelSensitivity(0); // 2g MPU6050sensor.setGyroSensitivity(0); // 250 degrees/s MPU6050sensor.setThrottle(); Serial.println("start..."); MPU6050sensor.axe = 0; MPU6050sensor.aye = 0; MPU6050sensor.aze = 0; MPU6050sensor.gxe = 0; MPU6050sensor.gye = 0; MPU6050sensor.gze = 0; } #define DEADZONE 0.1 #define XMAX 125 #define XMIN 1 #define YMAX 61 #define YMIN 1 void updPixel(float ax, float ay, int *x, int *y) { if (ay < -DEADZONE) (*x)++; if (ay > DEADZONE) (*x)--; if (ax < -DEADZONE) (*y)++; if (ax > DEADZONE) (*y)--; if (*x < XMIN) *x = XMIN; if (*y < YMIN) *y = YMIN; if (XMAX <= *x ) *x = XMAX - 1; if (YMAX <= *y ) *y = YMAX - 1; #ifdef BUG1 Serial.print("xpos: "); Serial.println(*x); Serial.print("ypos: "); Serial.println(*y); #endif } void readMPU6050() { MPU6050sensor.read(); // initiate samplig ax = MPU6050sensor.getAccelX(); ay = MPU6050sensor.getAccelY(); az = MPU6050sensor.getAccelZ(); gxe = MPU6050sensor.getGyroX(); gye = MPU6050sensor.getGyroY(); gze = MPU6050sensor.getGyroZ(); temp = MPU6050sensor.getTemperature(); #ifdef BUG1 Serial.println(">>>"); Serial.print("ax: "); Serial.println(ax); Serial.print("ay: "); Serial.println(ay); #endif } void debugDmp() { Serial.print("ax "); Serial.println(ax); Serial.print("ay "); Serial.println(ay); Serial.println(xP); Serial.println(yP); } int chkForCenter() { if ((60 <= xP) && (xP <= 70) && (28 <= yP) && (yP <= 36)) return 1; else return 0; } void setup() { Serial.begin(115200); Wire.begin(); initMPU6050(); u8g2.begin(); u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font } void loop() { u8g2.clearBuffer(); readMPU6050(); updPixel(ax, ay, &xP, &yP); //u8g2.drawPixel(xP, yP); if (chkForCenter() ) { u8g2.drawBox(xP - 1, yP - 1, 4, 4); } else { u8g2.drawBox(xP, yP, 2, 2); } u8g2.drawCircle(64,32,5); u8g2.sendBuffer(); debugDmp(); delay(50); } Barmeter og GY521/GY87 og OLED all i one#include <Arduino.h> #include <U8g2lib.h> #include <SPI.h> #include "GY521.h" // http://jensd.dk/edu/doc/esp32/mono-oleds.html // https://github.com/olikraus/u8g2/wiki/u8g2reference U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2 (U8G2_R0, 5, 16, 17); GY521 MPU6050sensor(0x68); void barMeter(int x1, int y1, int w, int h, float vall) { int m; // clip to be in interval [0-1] to be safe // its up to you to scale bef call if (1.0 < vall) vall = 1.0; else if (vall < 0.0) vall = 0.0; u8g2.setDrawColor(1); u8g2.drawFrame(x1, y1, w, h); x1++; y1++; h -= 2; w -= 2; u8g2.setDrawColor(0); u8g2.drawBox(x1, y1, w, h); // clear interior u8g2.setDrawColor(1); m = round(h * vall); y1 += (h - m); h = m; u8g2.drawBox(x1, y1, w, h); } void barSMeter(int x1, int y1, int w, int h, float vall) { int m; int hlp, yM; // clip to be in interval [0-1] to be safe // its up to you to scale bef call if (1.0 < vall) vall = 1.0; else if (vall < 0.0) vall = 0.0; u8g2.setDrawColor(1); u8g2.drawFrame(x1, y1, w, h); x1++; y1++; h -= 2; w -= 2; u8g2.setDrawColor(0); u8g2.drawBox(x1, y1, w, h); // clear interior u8g2.setDrawColor(1); yM = y1 + h / 2; if (0.5 < vall) { h = round(h * (vall - 0.5)); y1 = yM - h; } else { h = round(h * (0.5 - vall) ); y1 = yM; } if (h < 1) h = 1; /* m = round(h * vall); y1 += (h - m); h = m; */ u8g2.drawBox(x1, y1, w, h); } float ax, ay, az, gxe, gye, gze, temp; void initMPU6050() { delay(100); while (MPU6050sensor.wakeup() == false) { Serial.print(millis()); Serial.println("\tCould not connect to GY521"); delay(1000); } MPU6050sensor.setAccelSensitivity(0); // 2g MPU6050sensor.setGyroSensitivity(0); // 250 degrees/s MPU6050sensor.setThrottle(); Serial.println("start..."); /*MPU6050sensor.axe = 0; MPU6050sensor.aye = 0; MPU6050sensor.aze = 0; MPU6050sensor.gxe = 0; MPU6050sensor.gye = 0; MPU6050sensor.gze = 0; */ } void printMPU6050() { static int counter = 0; if (counter % 10 == 0) { Serial.println("\n\tACCELEROMETER\t\tGYROSCOPE\t\tTEMPERATURE"); Serial.println("\tax\tay\taz\tgx\tgy\tgz\tT"); counter = 1; } Serial.print(counter); Serial.print('\t'); Serial.print(ax); Serial.print('\t'); Serial.print(ay); Serial.print('\t'); Serial.print(az); Serial.print('\t'); Serial.print(gxe); Serial.print('\t'); Serial.print(gye); Serial.print('\t'); Serial.print(gze); Serial.print('\t'); Serial.print(temp); Serial.println(); counter++; } void readMPU6050() { MPU6050sensor.read(); // initiate samplig ax = MPU6050sensor.getAccelX(); ay = MPU6050sensor.getAccelY(); az = MPU6050sensor.getAccelZ(); gxe = MPU6050sensor.getGyroX(); gye = MPU6050sensor.getGyroY(); gze = MPU6050sensor.getGyroZ(); temp = MPU6050sensor.getTemperature(); } void printOLED() { char ar[100]; barMeter(0, 0, 10, 60, 0.5 + 0.5 * ax); barSMeter(15, 0, 10, 60, 0.5 + 0.5 * ay); barMeter(30, 0, 10, 60, 0.5 + 0.5 * az); sprintf(ar, "%5.2f", ax); u8g2.drawStr(64, 10, ar); sprintf(ar, "%5.2f", ay); u8g2.drawStr(64, 30, ar); sprintf(ar, "%5.2f", az); u8g2.drawStr(64, 50, ar); } void setup() { Serial.begin(115200); Wire.begin(); initMPU6050(); // set callibration values from calibration sketch. u8g2.begin(); u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font } void loop() { u8g2.clearBuffer(); readMPU6050(); printMPU6050(); printOLED(); u8g2.sendBuffer(); delay(100); } A simple clock instrument(click for clock instrument like an old fashioned multimeter) #include <Arduino.h> #include <U8g2lib.h> #include <SPI.h> // JDN for 1.3 SPI 128x64 display based on SH1106 display chip // http://jensd.dk/edu/doc/esp32/mono-oleds.html // https://github.com/olikraus/u8g2/wiki/u8g2reference U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2 (U8G2_R0, 5, 22, 17); void setup() { u8g2.begin(); } const float pii = 3.14159265358; // input 0->1 void analogCircInstrument(int x, int y, float v, int r) { float lx, ly; if (1.0 < v) v = 1.0; else if (v < 0.0) v = 0.0; u8g2.drawCircle(x, y, r + 1, U8G2_DRAW_UPPER_RIGHT); u8g2.drawCircle(x, y, r + 1, U8G2_DRAW_UPPER_LEFT); u8g2.drawLine(x - r, y, x + r, y); v *= pii; // 0->1 => 0->pi lx = x - cos(v) * r; ly = y - sin(v) * r; u8g2.drawLine(x, y, round(lx), round(ly)); } const int centrumX = 31, centrumY = 32, rad = 10; float xxx = 0; void loop() { u8g2.clearBuffer(); analogCircInstrument(centrumX, centrumY, xxx, 10); analogCircInstrument(centrumX + 25, centrumY, xxx, 6); u8g2.sendBuffer(); xxx += 0.1; delay(100); if (1.0 < xxx ) xxx = 0; } ui8g2 draw elementsSimple system to draw elements based on description in an array.
(click for draw elements using U8g2 lib) #include <Arduino.h> #include <U8g2lib.h> #include <SPI.h> // JDN for 1.3 SPI 128x64 display based on SH1106 display chip // http://jensd.dk/edu/doc/esp32/mono-oleds.html // https://github.com/olikraus/u8g2/wiki/u8g2reference U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2 (U8G2_R0, 5, 22, 17); void setup() { u8g2.begin(); } /* IDEA IS YOU CAN SAVE TIME AND MANY CALLS AND JUSTR DEFINE IMAGE DRAWING * * * * First element - value 10 - below is number of elements to be drawn * in the array * The rest is description of each element * Look down in switch-case to see * format * nr-1 : element type: 1 drawLine, 2: drawCicle,.. See case-switch below * nr-2: color ; 1: color, 2 black * nr-3 .. : the parameters to call as specified in https://github.com/olikraus/u8g2/wiki/u8g2reference * */ /* n = 0 rad, neg angle */ int fig1[] = {10, 1, 1, 10, 5, 10, 15, // drawLine(10,5 , 10,15) 1, 1, 10, 5, 15, 5, // drawLine(10,5 , 15,15) 1, 1, 10, 5, 5, 5, // drawLine(10,5 , 5, 5) 1, 1, 10, 15, 5, 25, // drawLine(10,15 , 5,25) 1, 1, 10, 15, 15, 25, // drawLine(10,15 , 11,15) 2, 1, 64, 32, 20, U8G2_DRAW_ALL, // drawCirle (64,32,20,U8G_DRAW_ALL) 3, 1, 64, 32, 30, 10, U8G2_DRAW_ALL,// drawEllipse(64,32,30,20,U8G_DRAW_ALL) 4, 1, 64, 32, 15, 10, // drawFrame(64,32,15,10) 5, 1, 0, 0, 8, 8, // drawBox(0,0,8,8) 6, 1, 10, 10, 20, 20, 10, 40, // drawTriangle(10, 10, 20, 20, 10, 40) 7, 1, 127, 63 // drawPixel(127,63) }; /* * first parameter is pointer to elemn array * x and y is relative positioning so you can locate * your drawing relative on the display */ void drawElements(int *a, int x, int y) { int nr = *a; a++; u8g2.setDrawColor(*(a + 1)); for (int i = 0; i < nr; i++) { switch ( *a) { case 1: u8g2.drawLine(*(a + 2) + x, *(a + 3) + y, *(a + 4) + x, *(a + 5) + y); a += 6; // advance to next element drawLine fills 6 break; case 2: u8g2.drawCircle( *(a + 2) + x , *(a + 3) + y, *(a + 4), *(a + 5)); // U8G2_DRAW_ALL); a += 6; break; case 3: u8g2.drawEllipse(*(a + 2) + x, *(a + 3) + y, *(a + 4), *(a + 5) , *(a + 6) ); a += 7; case 4: u8g2.drawFrame(*(a + 2) + x, *(a + 3) + y, *(a + 4), *(a + 5) ); a += 6; break; case 5: u8g2.drawBox(*(a + 2) + x, *(a + 3) + y, *(a + 4), *(a + 5) ); a += 6; break; case 6: u8g2.drawTriangle(*(a + 2) + x, *(a + 3) + y, *(a + 4) + x, *(a + 5) + y, *(a + 6) + x, *(a + 7) + y); a += 8; break; case 7: u8g2.drawPixel(*(a + 2) + x, *(a + 3)); a += 4; break; default: return; } } } void loop() { u8g2.clearBuffer(); drawElements(fig1, 0, 4); u8g2.sendBuffer(); delay(1000); } An analog watch#include <Arduino.h> #include <U8g2lib.h> #include <SPI.h> // JDN for 1.3 SPI 128x64 display based on SH1106 display chip // http://jensd.dk/edu/doc/esp32/mono-oleds.html // https://github.com/olikraus/u8g2/wiki/u8g2reference U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2 (U8G2_R0, 5, 22, 17); void setup() { u8g2.begin(); } const float pii = 3.14159265358; // draw line, angle - v - in range 0-60 for 0-360deg void pointer(int x, int y, int v, int rad) { float lx, ly, vv; vv = 2 * pii * v / 60.0; lx = sin(vv) * rad + x; ly = -cos(vv) * rad + y; u8g2.drawLine(x, y, round(lx), round(ly)); } void analogWatch(int x, int y, int hh, int mm, int r) { u8g2.drawCircle(x, y, r + 1, U8G2_DRAW_ALL); pointer(x , y , mm, r - 1); // min pointer(x , y , hh, r - 5); // hour } const int centrumX = 31, centrumY = 32, rad = 15; int timeInMin = 0; void loop() { u8g2.clearBuffer(); // timeInMIn/2 to get hour count analogWatch(centrumX, centrumY, timeInMin / 12, timeInMin % 60, rad); analogWatch(centrumX+40, centrumY, timeInMin / 12, timeInMin % 60, rad); u8g2.sendBuffer(); timeInMin += 1; delay(100); if (12 * 60 <= timeInMin ) timeInMin = timeInMin % (60 * 12); } A simple U8g2 logo program(click for U8g2Logo using U8g2 lib - look for JDN) /* U8g2Logo.ino Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <Arduino.h> #include <U8g2lib.h> #ifdef U8X8_HAVE_HW_SPI #include <SPI.h> #endif #ifdef U8X8_HAVE_HW_I2C #include <Wire.h> #endif /* U8g2lib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ //JDN //U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2 (U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2 (U8G2_R0, 5, 22, 17); //JDN // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the "every 2nd line skipped" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the "every 2nd line skipped" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_PIMORONI_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_128X128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_128X32_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_WS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1316_128X32_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16); // Feather HUZZAH ESP8266, E=clock=14, RW=data=13, RS=CS //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX19296_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_WO256X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160M_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_ALT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75320_JLX320240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1611_CG160160_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_ST7511_AVD_320X240_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Enable U8g2 16Bit Mode and connect RD pin with 3.3V/5V // End of constructor list //#define MINI_LOGO void setup(void) { /* U8g2 Project: SSD1306 Test Board */ //pinMode(10, OUTPUT); //pinMode(9, OUTPUT); //digitalWrite(10, 0); //digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); /* U8g2 Project: LC7981 Test Board, connect RW to GND */ //pinMode(17, OUTPUT); //digitalWrite(17, 0); /* U8g2 Project: Pax Instruments Shield: Enable Backlight */ //pinMode(6, OUTPUT); //digitalWrite(6, 0); u8g2.begin(); u8g2.setPowerSave(0); u8g2.setFlipMode(0); } void drawLogo(void) { uint8_t mdy = 0; if ( u8g2.getDisplayHeight() < 59 ) mdy = 5; u8g2.setFontMode(1); // Transparent u8g2.setDrawColor(1); #ifdef MINI_LOGO u8g2.setFontDirection(0); u8g2.setFont(u8g2_font_inb16_mf); u8g2.drawStr(0, 22, "U"); u8g2.setFontDirection(1); u8g2.setFont(u8g2_font_inb19_mn); u8g2.drawStr(14,8,"8"); u8g2.setFontDirection(0); u8g2.setFont(u8g2_font_inb16_mf); u8g2.drawStr(36,22,"g"); u8g2.drawStr(48,22,"\xb2"); u8g2.drawHLine(2, 25, 34); u8g2.drawHLine(3, 26, 34); u8g2.drawVLine(32, 22, 12); u8g2.drawVLine(33, 23, 12); #else u8g2.setFontDirection(0); u8g2.setFont(u8g2_font_inb24_mf); u8g2.drawStr(0, 30-mdy, "U"); u8g2.setFontDirection(1); u8g2.setFont(u8g2_font_inb30_mn); u8g2.drawStr(21,8-mdy,"8"); u8g2.setFontDirection(0); u8g2.setFont(u8g2_font_inb24_mf); u8g2.drawStr(51,30-mdy,"g"); u8g2.drawStr(67,30-mdy,"\xb2"); u8g2.drawHLine(2, 35-mdy, 47); u8g2.drawHLine(3, 36-mdy, 47); u8g2.drawVLine(45, 32-mdy, 12); u8g2.drawVLine(46, 33-mdy, 12); #endif } void drawURL(void) { #ifndef MINI_LOGO u8g2.setFont(u8g2_font_4x6_tr); if ( u8g2.getDisplayHeight() < 59 ) { u8g2.drawStr(89,20-5,"github.com"); u8g2.drawStr(73,29-5,"/olikraus/u8g2"); } else { u8g2.drawStr(1,54,"github.com/olikraus/u8g2"); } #endif } void loop(void) { u8g2.firstPage(); do { drawLogo(); drawURL(); } while ( u8g2.nextPage() ); delay(4000); } start on a pong program//JDN pong 01 #include <Arduino.h> #include <U8g2lib.h> #ifdef U8X8_HAVE_HW_SPI #include <SPI.h> #endif #ifdef U8X8_HAVE_HW_I2C #include <Wire.h> #endif //JDN //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2 (U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2 (U8G2_R0, 5, 22, 17); //JDN static int x = 1, dir = 1; void pongDraw() { u8g2.drawLine(x, 10, x, 20); } void setup(void) { u8g2.begin(); } /* void loop(void) { u8g2.firstPage(); do { pongDraw(); } while ( u8g2.nextPage() ); if (0 > x) // comming to an end dir = 1; else if (128 <= x) // pr the other end dir = -1; x += dir; delay(1); } */ void loop() { u8g2.clearBuffer(); pongDraw(); u8g2.sendBuffer(); x += dir; if (0 > x) // comming to an end dir = 1; else if (128 <= x) // pr the other end dir = -1; delay(1); } start on a tripple watch#include <Arduino.h> #include <U8g2lib.h> #include <SPI.h> // JDN for 1.3 SPI 128x64 display based on SH1106 display chip // http://jensd.dk/edu/doc/esp32/mono-oleds.html // https://github.com/olikraus/u8g2/wiki/u8g2reference U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2 (U8G2_R0, 5, 22, 17); void setup() { u8g2.begin(); } const float pii = 3.14159265358; // draw line, angle - v - in range 0-60 for 0-360deg void pointer(int x, int y, int v, int rad) { float lx, ly, vv; vv = 2 * pii * v / 60.0; lx = sin(vv) * rad + x; ly = -cos(vv) * rad + y; u8g2.drawLine(x, y, round(lx), round(ly)); } void analogWatch(int x, int y, int hh, int mm, int r) { u8g2.drawCircle(x, y, r + 1, U8G2_DRAW_ALL); pointer(x , y , mm, r - 1); // min pointer(x , y , hh, r - 5); // hour } const int centrumX = 31, centrumY = 32, rad = 15; int timeInMin = 0; void loop() { u8g2.clearBuffer(); // timeInMIn/2 to get hour count analogWatch(centrumX, centrumY, timeInMin / 12, timeInMin % 60, rad); analogWatch(centrumX+40, centrumY, timeInMin / 12, timeInMin % 60, rad); u8g2.sendBuffer(); timeInMin += 1; delay(100); if (12 * 60 <= timeInMin ) timeInMin = timeInMin % (60 * 12); } IMU acc oled demo#include <Arduino.h> #include <U8g2lib.h> #include <SPI.h> #include "GY521.h" // http://jensd.dk/edu/doc/esp32/mono-oleds.html // https://github.com/olikraus/u8g2/wiki/u8g2reference // JensD 2020 (C) beer license U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2 (U8G2_R0, 5, 16, 17); GY521 MPU6050sensor(0x68); void barMeter(int x1, int y1, int w, int h, float vall) { int m; // clip to be in interval [0-1] to be safe // its up to you to scale bef call if (1.0 < vall) vall = 1.0; else if (vall < 0.0) vall = 0.0; u8g2.setDrawColor(1); u8g2.drawFrame(x1, y1, w, h); x1++; y1++; h -= 2; w -= 2; u8g2.setDrawColor(0); u8g2.drawBox(x1, y1, w, h); // clear interior u8g2.setDrawColor(1); m = round(h * vall); y1 += (h - m); h = m; u8g2.drawBox(x1, y1, w, h); } void barSMeter(int x1, int y1, int w, int h, float vall) { int m; int hlp, yM; // clip to be in interval [0-1] to be safe // its up to you to scale bef call if (1.0 < vall) vall = 1.0; else if (vall < 0.0) vall = 0.0; u8g2.setDrawColor(1); u8g2.drawFrame(x1, y1, w, h); x1++; y1++; h -= 2; w -= 2; u8g2.setDrawColor(0); u8g2.drawBox(x1, y1, w, h); // clear interior u8g2.setDrawColor(1); yM = y1 + h / 2; if (0.5 < vall) { h = round(h * (vall - 0.5)); y1 = yM - h; } else { h = round(h * (0.5 - vall) ); y1 = yM; } if (h < 1) h = 1; /* m = round(h * vall); y1 += (h - m); h = m; */ u8g2.drawBox(x1, y1, w, h); } float ax, ay, az, gxe, gye, gze, temp; void initMPU6050() { delay(100); while (MPU6050sensor.wakeup() == false) { Serial.print(millis()); Serial.println("\tCould not connect to GY521"); delay(1000); } MPU6050sensor.setAccelSensitivity(0); // 2g MPU6050sensor.setGyroSensitivity(0); // 250 degrees/s MPU6050sensor.setThrottle(); Serial.println("start..."); /*MPU6050sensor.axe = 0; MPU6050sensor.aye = 0; MPU6050sensor.aze = 0; MPU6050sensor.gxe = 0; MPU6050sensor.gye = 0; MPU6050sensor.gze = 0; */ } void printMPU6050() { static int counter = 0; if (counter % 10 == 0) { Serial.println("\n\tACCELEROMETER\t\tGYROSCOPE\t\tTEMPERATURE"); Serial.println("\tax\tay\taz\tgx\tgy\tgz\tT"); counter = 1; } Serial.print(counter); Serial.print('\t'); Serial.print(ax); Serial.print('\t'); Serial.print(ay); Serial.print('\t'); Serial.print(az); Serial.print('\t'); Serial.print(gxe); Serial.print('\t'); Serial.print(gye); Serial.print('\t'); Serial.print(gze); Serial.print('\t'); Serial.print(temp); Serial.println(); counter++; } void readMPU6050() { MPU6050sensor.read(); // initiate samplig ax = MPU6050sensor.getAccelX(); ay = MPU6050sensor.getAccelY(); az = MPU6050sensor.getAccelZ(); gxe = MPU6050sensor.getGyroX(); gye = MPU6050sensor.getGyroY(); gze = MPU6050sensor.getGyroZ(); temp = MPU6050sensor.getTemperature(); } void printOLED() { char ar[100]; barMeter(0, 0, 10, 60, 0.5 + 0.5 * ax); barSMeter(15, 0, 10, 60, 0.5 + 0.5 * ay); barMeter(30, 0, 10, 60, 0.5 + 0.5 * az); sprintf(ar, "%5.2f", ax); u8g2.drawStr(64, 10, ar); sprintf(ar, "%5.2f", ay); u8g2.drawStr(64, 30, ar); sprintf(ar, "%5.2f", az); u8g2.drawStr(64, 50, ar); } void setup() { Serial.begin(115200); Wire.begin(); initMPU6050(); // set callibration values from calibration sketch. u8g2.begin(); u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font } void loop() { u8g2.clearBuffer(); readMPU6050(); printMPU6050(); printOLED(); u8g2.sendBuffer(); delay(100); } start on a pong or snake program//JDN pong 01 #include <Arduino.h> #include <U8g2lib.h> #ifdef U8X8_HAVE_HW_SPI #include <SPI.h> #endif #ifdef U8X8_HAVE_HW_I2C #include <Wire.h> #endif //JDN //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2 (U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2 (U8G2_R0, 5, 22, 17); //JDN static int x = 0, y=0,dirx=1,diry=1; void pongDraw() { u8g2.drawPixel(x, y); } void setup(void) { u8g2.begin(); } /* void loop(void) { u8g2.firstPage(); do { pongDraw(); } while ( u8g2.nextPage() ); if (0 > x) // comming to an end dir = 1; else if (128 <= x) // pr the other end dir = -1; x += dir; delay(1); } */ void loop() { u8g2.clearBuffer(); pongDraw(); u8g2.sendBuffer(); x += dirx; if (0 > x) // comming to an end dirx = 1; else if (128 <= x) // pr the other end dirx = -1; y += diry; if (0 > y) // comming to an end diry = 1; else if (64 <= y) // pr the other end diry = -1; delay(1); } start on a snake w tail program(click for pong/snake w tail ) //JDN snake #include <Arduino.h> #include <U8g2lib.h> #ifdef U8X8_HAVE_HW_SPI #include <SPI.h> #endif #ifdef U8X8_HAVE_HW_I2C #include <Wire.h> #endif //JDN //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2 (U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2 (U8G2_R0, 5, 22, 17); //JDN static int x = 0, y = 0, dirx = 1, diry = 1; static int x2 = 0, y2 = 0, dir2x = 1, dir2y = 1; static int lgt = 0; void delTail() { if (45 < lgt) { u8g2.setDrawColor(0); u8g2.drawPixel(x2, y2); // draww black == delete pixel x2 += dir2x; if (0 > x2) // comming to an end dir2x = 1; else if (128 <= x2) // pr the other end dir2x = -1; y2 += dir2y; if (0 > y2) // comming to an end dir2y = 1; else if (64 <= y2) // pr the other end dir2y = -1; u8g2.setDrawColor(1); // set color back to white } else { lgt++; } } void drawHead() { u8g2.drawPixel(x, y); x += dirx; if (0 > x) // comming to an end dirx = 1; else if (128 <= x) // pr the other end dirx = -1; y += diry; if (0 > y) // comming to an end diry = 1; else if (64 <= y) // pr the other end diry = -1; } void pongDraw() { delTail(); drawHead(); } void setup(void) { u8g2.begin(); } void loop() { //u8g2.clearBuffer(); // dont clear bq then we miss the tail pongDraw(); u8g2.sendBuffer(); delay(1); } Simple drawing text in u8x8(click for helloworld using u8x8lib) #include <Arduino.h> #include <U8x8lib.h> #ifdef U8X8_HAVE_HW_SPI #include <SPI.h> #endif /* JDN NODEMCU ESP32 USING SPI pin ---- connected to til ... GND GND (stel) VCC 3.3V eller Vin CLK GPIO18 MOSI GPIO23 RES GPIO17 DC GPIO22 CS GPIO5 * */ //JDN // U8X8_SH1106_128X64_NONAME_4W_HW_SPI u8x8 (/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); U8X8_SH1106_128X64_NONAME_4W_HW_SPI u8x8 (5, 22, 17); //JDN void setup(void) { u8x8.begin(); u8x8.setPowerSave(0); u8x8.setFont(u8x8_font_chroma48medium8_r); } // for 8x8 font 16 columns, 8 rows int x = 0, y = 0; void loop(void) { u8x8.drawString(x, y, "Hello World!"); y++;; if (7 <= y) { y++; delay(2000); while (y--) { u8x8.drawString(x, y, "------------"); delay(100); } delay(2000); u8x8.clearDisplay(); y=0; } // u8x8.refreshDisplay(); // only required for SSD1606/7 delay(1000); }
Jens Dalsgaard Nielsen . CC BY-SA 4.0 ,2023-08-08 13:45:55 CEST
|