diff --git a/README.md b/README.md index 6105fd8f..f6ae006e 100644 --- a/README.md +++ b/README.md @@ -8,5 +8,5 @@ Description: https://github.com/olikraus/u8g2/wiki Issue Tracker: https://github.com/olikraus/u8g2/issues -Download (2.24.2): https://github.com/olikraus/U8g2_Arduino/archive/master.zip +Download (2.24.3): https://github.com/olikraus/U8g2_Arduino/archive/master.zip diff --git a/examples/page_buffer/ClipWindow/ClipWindow.ino b/examples/page_buffer/ClipWindow/ClipWindow.ino new file mode 100644 index 00000000..1c288019 --- /dev/null +++ b/examples/page_buffer/ClipWindow/ClipWindow.ino @@ -0,0 +1,282 @@ +/* + + ClipWindow.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 +#include + +#ifdef U8X8_HAVE_HW_SPI +#include +#endif +#ifdef U8X8_HAVE_HW_I2C +#include +#endif + + +/* + U8glib 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. +*/ + +// 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_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_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_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_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); +//U8G2_SSD1317_96X96_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_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); +//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_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_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_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_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_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=*/ 17, /*cs=*/ 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=*/ 17, /*cs=*/ 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=*/ 17, /*cs=*/ 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=*/ 16); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high +//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_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 + + + + +// End of constructor list + + +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_uint_t x = 0; + +void loop(void) { + if ( x == 0 ) + x = 40; + else + x--; + + u8g2.setFont(u8g2_font_ncenB10_tr); + u8g2.firstPage(); + do { + + /* assign a clip window and draw some text into it */ + u8g2.setClipWindow(35, 11, 74, 27); /* upper left and lower right position */ + u8g2.drawStr(x,23,"U8g2 U8g2"); + + /* remove clip window, draw to complete screen */ + u8g2.setMaxClipWindow(); + u8g2.drawFrame(34, 10, 40, 18); + + } while ( u8g2.nextPage() ); + delay(10); +} + diff --git a/examples/page_buffer/FPS/FPS.ino b/examples/page_buffer/FPS/FPS.ino index 75f19147..6c5ce610 100644 --- a/examples/page_buffer/FPS/FPS.ino +++ b/examples/page_buffer/FPS/FPS.ino @@ -238,6 +238,17 @@ U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI Uno Clip=2.7 Box=2.9 @=1.8 Pix=2.2 issue 586, before optimization U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI Uno Clip=23.4 Box=40.8 @=4.4 Pix=8.1 issue 586, after optimization + + 28 Oct 2018, Arduino 1.8.4, 8 Bit Mode + U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI Uno Clip=34.0 Box=88.4 @=4.5 Pix=8.2 issue 364, clip window + + U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C Uno Clip=28.4 Box=39.2 @=10.0 Pix=14.9 I2C default + U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C Uno Clip=32.9 Box=48.3 @=10.5 Pix=16.1 I2C default, u8g2.setBusClock(600000UL) + + U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI Uno Clip=33.9 Box=88.2 @=4.5 Pix=8.2 SPI default speed + U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI Uno Clip=32.8 Box=80.6 @=4.5 Pix=8.2 SPI default speed u8g2.setBusClock(6000000UL); + U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI Uno Clip=33.9 Box=88.2 @=4.5 Pix=8.2 SPI default speed u8g2.setBusClock(9000000UL); + */ diff --git a/examples/page_buffer/HelloWorld/HelloWorld.ino b/examples/page_buffer/HelloWorld/HelloWorld.ino index 91cb02ca..0f89884f 100644 --- a/examples/page_buffer/HelloWorld/HelloWorld.ino +++ b/examples/page_buffer/HelloWorld/HelloWorld.ino @@ -30,7 +30,25 @@ 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. - + + 27 Oct 2018: + + U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2 + make -f Makefile.184.uno + + text + 8732 default, all active + 8500 -232 -2.65% no U8G2_WITH_CLIP_WINDOW_SUPPORT + 8316 -416 -4.76% no U8G2_WITH_FONT_ROTATION + 8606 -126 -1.44% no U8G2_WITH_UNICODE + 8692 -40 -0.45% no U8G2_WITH_INTERSECTION + 8328 -404 -4.62% no U8G2_WITH_INTERSECTION no U8G2_WITH_CLIP_WINDOW_SUPPORT + 8718 -14 -4.86% no U8G2_WITH_HVLINE_SPEED_OPTIMIZATION + 8026 -706 -8.08% no U8G2_WITH_FONT_ROTATION no U8G2_WITH_INTERSECTION no U8G2_WITH_CLIP_WINDOW_SUPPORT + + Some flags depend on each other: `U8G2_WITH_INTERSECTION` is required for `U8G2_WITH_CLIP_WINDOW_SUPPORT`, so `U8G2_WITH_INTERSECTION` is partly active as long + as `U8G2_WITH_CLIP_WINDOW_SUPPORT` is requested. + */ #include @@ -60,7 +78,7 @@ //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_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 diff --git a/examples/page_buffer/Shennong/Shennong.ino b/examples/page_buffer/Shennong/Shennong.ino index 9e8599e4..f9807997 100644 --- a/examples/page_buffer/Shennong/Shennong.ino +++ b/examples/page_buffer/Shennong/Shennong.ino @@ -273,7 +273,7 @@ // To read the short story with all glyphs you need at least a font with _gb2312b postfix // However, a font with _gb2312b postfix is very large and will not always fit on // the target controller. For testing you can use _chinese1 extenstion, but then -// many gylphs are skipped. +// many gylphs are skipped and not visible. // // wqy fonts are available in different sizes, here are only wqy12, wqy14 and wqy16 listed @@ -392,7 +392,7 @@ void setup(void) { /* select a font */ - u8g2.setFont(u8g2_font_wqy12_t_chinese1); // two unknown glyphs + // u8g2.setFont(u8g2_font_wqy12_t_chinese1); // two unknown glyphs //u8g2.setFont(u8g2_font_wqy12_t_chinese3); // two unknown glyphs //u8g2.setFont(u8g2_font_wqy12_t_gb2312a); // ";" is missing diff --git a/extras/ChangeLog b/extras/ChangeLog index 49e89fe3..1f92194d 100644 --- a/extras/ChangeLog +++ b/extras/ChangeLog @@ -200,6 +200,11 @@ https://github.com/olikraus/u8g2 ChangeLog * Added contributed 7-segment font, https://github.com/olikraus/u8g2/wiki/fntgrpu8g#7segments_26x42 (issue 634) * Added several fonts from fontstruct.com, https://github.com/olikraus/u8g2/wiki/fntgrpfontstruct (issue 687)# This also includes several outline fonts. - + 2018-10-28 v2.24.3 olikraus@gmail.com + * Added clip window support (issue 364) + * Added setBusClock() proc to change the I2C/SPI bus clock speed (Arduino only, issue 705) + * Added sleep mode for ST7920 (issue 245) + * Added support for SSD0323 (issue 720) + diff --git a/library.properties b/library.properties index bf135e97..6327ee8e 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=U8g2 -version=2.24.2 +version=2.24.3 author=oliver maintainer=oliver sentence=Monochrome LCD, OLED and eInk Library. Display controller: SSD1305, SSD1306, SSD1309, SSD1322, SSD1325, SSD1327, SSD1329, SSD1606, SSD1607, SH1106, SH1107, SH1108, SH1122, T6963, RA8835, LC7981, PCD8544, PCF8812, HX1230, UC1601, UC1604, UC1608, UC1610, UC1611, UC1701, ST7565, ST7567, ST7588, ST75256, NT7534, IST3020, ST7920, LD7032, KS0108, SED1520, SBN1661, IL3820, MAX7219. Interfaces: I2C, SPI, Parallel. diff --git a/src/U8g2lib.h b/src/U8g2lib.h index 57f72b9d..65ca3978 100644 --- a/src/U8g2lib.h +++ b/src/U8g2lib.h @@ -63,6 +63,9 @@ class U8G2 : public Print u8x8_t *getU8x8(void) { return u8g2_GetU8x8(&u8g2); } u8g2_t *getU8g2(void) { return &u8g2; } + uint32_t getBusClock(void) { return u8g2_GetU8x8(&u8g2)->bus_clock; } + void setBusClock(uint32_t clock_speed) { u8g2_GetU8x8(&u8g2)->bus_clock = clock_speed; } + void setI2CAddress(uint8_t adr) { u8g2_SetI2CAddress(&u8g2, adr); } @@ -144,6 +147,12 @@ class U8G2 : public Print /* u8g2 */ +#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT + void setMaxClipWindow(void) { u8g2_SetMaxClipWindow(&u8g2); } + void setClipWindow(u8g2_uint_t clip_x0, u8g2_uint_t clip_y0, u8g2_uint_t clip_x1, u8g2_uint_t clip_y1) { + u8g2_SetClipWindow(&u8g2, clip_x0, clip_y0, clip_x1, clip_y1 ); } +#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */ + u8g2_uint_t getDisplayHeight(void) { return u8g2_GetDisplayHeight(&u8g2); } u8g2_uint_t getDisplayWidth(void) { return u8g2_GetDisplayWidth(&u8g2); } diff --git a/src/U8x8lib.cpp b/src/U8x8lib.cpp index 4b08ae76..62cda512 100644 --- a/src/U8x8lib.cpp +++ b/src/U8x8lib.cpp @@ -556,6 +556,7 @@ extern "C" uint8_t u8x8_byte_arduino_hw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t a break; case U8X8_MSG_BYTE_INIT: + u8x8->bus_clock = u8x8->display_info->sck_clock_hz; /* disable chipselect */ u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level); @@ -608,7 +609,7 @@ extern "C" uint8_t u8x8_byte_arduino_hw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t a } #if ARDUINO >= 10600 - SPI.beginTransaction(SPISettings(u8x8->display_info->sck_clock_hz, MSBFIRST, internal_spi_mode)); + SPI.beginTransaction(SPISettings(u8x8->bus_clock, MSBFIRST, internal_spi_mode)); #else SPI.begin(); @@ -674,6 +675,7 @@ extern "C" uint8_t u8x8_byte_arduino_2nd_hw_spi(U8X8_UNUSED u8x8_t *u8x8, U8X8_U break; case U8X8_MSG_BYTE_INIT: + u8x8->bus_clock = u8x8->display_info->sck_clock_hz; /* disable chipselect */ u8x8_gpio_SetCS(u8x8, u8x8->display_info->chip_disable_level); /* no wait required here */ @@ -704,7 +706,7 @@ extern "C" uint8_t u8x8_byte_arduino_2nd_hw_spi(U8X8_UNUSED u8x8_t *u8x8, U8X8_U } #if ARDUINO >= 10600 - SPI1.beginTransaction(SPISettings(u8x8->display_info->sck_clock_hz, MSBFIRST, internal_spi_mode)); + SPI1.beginTransaction(SPISettings(u8x8->bus_clock, MSBFIRST, internal_spi_mode)); #else SPI1.begin(); @@ -975,6 +977,7 @@ extern "C" uint8_t u8x8_byte_arduino_hw_i2c(U8X8_UNUSED u8x8_t *u8x8, U8X8_UNUSE Wire.write((uint8_t *)arg_ptr, (int)arg_int); break; case U8X8_MSG_BYTE_INIT: + u8x8->bus_clock = u8x8->display_info->i2c_bus_clock_100kHz * 100000UL; #if defined(ESP8266) || defined(ARDUINO_ARCH_ESP8266) || defined(ESP_PLATFORM) || defined(ARDUINO_ARCH_ESP32) /* for ESP8266/ESP32, Wire.begin has two more arguments: clock and data */ if ( u8x8->pins[U8X8_PIN_I2C_CLOCK] != U8X8_PIN_NONE && u8x8->pins[U8X8_PIN_I2C_DATA] != U8X8_PIN_NONE ) @@ -996,10 +999,7 @@ extern "C" uint8_t u8x8_byte_arduino_hw_i2c(U8X8_UNUSED u8x8_t *u8x8, U8X8_UNUSE #if ARDUINO >= 10600 /* not sure when the setClock function was introduced, but it is there since 1.6.0 */ /* if there is any error with Wire.setClock() just remove this function call */ - if ( u8x8->display_info->i2c_bus_clock_100kHz >= 4 ) - { - Wire.setClock(400000L); - } + Wire.setClock(u8x8->bus_clock); #endif Wire.beginTransmission(u8x8_GetI2CAddress(u8x8)>>1); break; @@ -1022,6 +1022,7 @@ extern "C" uint8_t u8x8_byte_arduino_2nd_hw_i2c(U8X8_UNUSED u8x8_t *u8x8, U8X8_U Wire1.write((uint8_t *)arg_ptr, (int)arg_int); break; case U8X8_MSG_BYTE_INIT: + u8x8->bus_clock = u8x8->display_info->i2c_bus_clock_100kHz * 100000UL; Wire1.begin(); break; case U8X8_MSG_BYTE_SET_DC: @@ -1030,10 +1031,7 @@ extern "C" uint8_t u8x8_byte_arduino_2nd_hw_i2c(U8X8_UNUSED u8x8_t *u8x8, U8X8_U #if ARDUINO >= 10600 /* not sure when the setClock function was introduced, but it is there since 1.6.0 */ /* if there is any error with Wire.setClock() just remove this function call */ - if ( u8x8->display_info->i2c_bus_clock_100kHz >= 4 ) - { - Wire1.setClock(400000L); - } + Wire1.setClock(u8x8->bus_clock); #endif Wire1.beginTransmission(u8x8_GetI2CAddress(u8x8)>>1); break; diff --git a/src/U8x8lib.h b/src/U8x8lib.h index 4c888978..6bfe519e 100644 --- a/src/U8x8lib.h +++ b/src/U8x8lib.h @@ -156,9 +156,12 @@ class U8X8 : public Print public: uint8_t tx, ty; - U8X8(void) { home(); } + U8X8(void) { home(); } u8x8_t *getU8x8(void) { return &u8x8; } + uint32_t getBusClock(void) { return u8x8.bus_clock; } + void setBusClock(uint32_t clock_speed) { u8x8.bus_clock = clock_speed; } + void setI2CAddress(uint8_t adr) { u8x8_SetI2CAddress(&u8x8, adr); } uint8_t getCols(void) { return u8x8_GetCols(&u8x8); } diff --git a/src/clib/u8g2.h b/src/clib/u8g2.h index 2d586e2d..1d04e0e3 100644 --- a/src/clib/u8g2.h +++ b/src/clib/u8g2.h @@ -72,27 +72,14 @@ //#define U8G2_16BIT -/* - The following macro enables a special check and optimization - in the HVLine procedure for lines with one pixel length. - It enabled, it will consume about 60 bytes in flash memory of the AVR and - there will be a speed improvement of about 20% for any single pixel draw. -*/ -#define U8G2_WITH_ONE_PIXEL_OPTIMIZATION - +/* U8g2 feature selection, see also https://github.com/olikraus/u8g2/wiki/u8g2optimization */ /* The following macro enables the HVLine speed optimization. It will consume about 40 bytes more in flash memory of the AVR. HVLine procedures are also used by the text drawing functions. */ -#define U8G2_HVLINE_SPEED_OPTIMIZATION - -/* - The following macro enables all four drawing directions for glyphs and strings. - If this macro is not defined, than a string can be drawn only in horizontal direction. -*/ -#define U8G2_WITH_FONT_ROTATION +#define U8G2_WITH_HVLINE_SPEED_OPTIMIZATION /* The following macro activates the early intersection check with the current visible area. @@ -103,6 +90,22 @@ */ #define U8G2_WITH_INTERSECTION + +/* + Enable clip window support: + void u8g2_SetMaxClipWindow(u8g2_t *u8g2) + void u8g2_SetClipWindow(u8g2_t *u8g2, u8g2_uint_t clip_x0, u8g2_uint_t clip_y0, u8g2_uint_t clip_x1, u8g2_uint_t clip_y1 ) + Setting a clip window will restrict all drawing to this window. + Clip window support requires about 200 bytes flash memory on AVR systems +*/ +#define U8G2_WITH_CLIP_WINDOW_SUPPORT + +/* + The following macro enables all four drawing directions for glyphs and strings. + If this macro is not defined, than a string can be drawn only in horizontal direction. +*/ +#define U8G2_WITH_FONT_ROTATION + /* U8glib V2 contains support for unicode plane 0 (Basic Multilingual Plane, BMP). The following macro activates this support. Deactivation would save some ROM. @@ -130,24 +133,6 @@ #define U8G2_WITH_UNICODE -/* - Internal performance test for the effect of enabling U8G2_WITH_INTERSECTION - Should not be defined for production code -*/ -//#define U8G2_WITH_HVLINE_COUNT - -/* - Defining the following variable adds the clipping and check procedures agains the display boundaries. - Clipping procedures are mandatory for the picture loop (u8g2_FirstPage/NextPage). - Clipping procedures will also allow strings to exceed the display boundaries. - On the other side, without clipping, all the setting of pixels must happen within the display boundaries. - - WARNING: Adding a comment in front of the following macro or removing the following line - may lead to memory faults if you write any pixel outside the display boundary. -*/ -#define U8G2_WITH_CLIPPING - - /*==========================================*/ @@ -194,6 +179,7 @@ typedef struct u8g2_struct u8g2_t; typedef struct u8g2_cb_struct u8g2_cb_t; typedef void (*u8g2_update_dimension_cb)(u8g2_t *u8g2); +typedef void (*u8g2_update_page_win_cb)(u8g2_t *u8g2); typedef void (*u8g2_draw_l90_cb)(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir); typedef void (*u8g2_draw_ll_hvline_cb)(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir); @@ -276,7 +262,8 @@ typedef struct _u8g2_kerning_t u8g2_kerning_t; struct u8g2_cb_struct { - u8g2_update_dimension_cb update; + u8g2_update_dimension_cb update_dimension; + u8g2_update_page_win_cb update_page_win; u8g2_draw_l90_cb draw_l90; }; @@ -300,24 +287,33 @@ struct u8g2_struct u8g2_uint_t pixel_curr_row; /* u8g2.tile_curr_row*8 */ /* the following variables are set by the update dimension callback */ - /* this is clipbox after rotation for the hvline procedures */ + /* this is the clipbox after rotation for the hvline procedures */ //u8g2_uint_t buf_x0; /* left corner of the buffer */ //u8g2_uint_t buf_x1; /* right corner of the buffer (excluded) */ u8g2_uint_t buf_y0; u8g2_uint_t buf_y1; - /* display dimensions in pixel for the user, calculated in u8g2_update_dimension_common(), used in u8g2_draw_hv_line_2dir() */ + /* display dimensions in pixel for the user, calculated in u8g2_update_dimension_common() */ u8g2_uint_t width; u8g2_uint_t height; /* ths is the clip box for the user to check if a specific box has an intersection */ /* use u8g2_IsIntersection from u8g2_intersection.c to test against this intersection */ - /* boundary values are part of the box so that they can be used with u8g2_IsIntersection */ + /* actually, this window describes the positon of the current page */ u8g2_uint_t user_x0; /* left corner of the buffer */ u8g2_uint_t user_x1; /* right corner of the buffer (excluded) */ u8g2_uint_t user_y0; /* upper edge of the buffer */ u8g2_uint_t user_y1; /* lower edge of the buffer (excluded) */ +#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT + /* clip window */ + u8g2_uint_t clip_x0; /* left corner of the clip window */ + u8g2_uint_t clip_x1; /* right corner of the clip window (excluded) */ + u8g2_uint_t clip_y0; /* upper edge of the clip window */ + u8g2_uint_t clip_y1; /* lower edge of the clip window (excluded) */ +#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */ + + /* information about the current font */ const uint8_t *font; /* current font for all text procedures */ // removed: const u8g2_kerning_t *kerning; /* can be NULL */ @@ -327,6 +323,11 @@ struct u8g2_struct u8g2_font_decode_t font_decode; /* new font decode structure */ u8g2_font_info_t font_info; /* new font info structure */ +#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT + /* 1 of there is an intersection between user_?? and clip_?? box */ + uint8_t is_page_clip_window_intersection; +#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */ + uint8_t font_height_mode; int8_t font_ref_ascent; int8_t font_ref_descent; @@ -341,16 +342,6 @@ struct u8g2_struct // the following variable should be renamed to is_buffer_auto_clear uint8_t is_auto_page_clear; /* set to 0 to disable automatic clear of the buffer in firstPage() and nextPage() */ -#ifdef U8G2_WITH_HVLINE_COUNT - unsigned long hv_cnt; -#endif /* U8G2_WITH_HVLINE_COUNT */ - -// removed, there is now the new index table -//#ifdef __unix__ -// uint16_t last_unicode; -// const uint8_t *last_font_data; -//#endif - }; #define u8g2_GetU8x8(u8g2) ((u8x8_t *)(u8g2)) @@ -419,6 +410,9 @@ extern const u8g2_cb_t u8g2_cb_mirror; */ +void u8g2_SetMaxClipWindow(u8g2_t *u8g2); +void u8g2_SetClipWindow(u8g2_t *u8g2, u8g2_uint_t clip_x0, u8g2_uint_t clip_y0, u8g2_uint_t clip_x1, u8g2_uint_t clip_y1 ); + void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, u8g2_draw_ll_hvline_cb ll_hvline_cb, const u8g2_cb_t *u8g2_cb); void u8g2_SetDisplayRotation(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb); diff --git a/src/clib/u8g2_buffer.c b/src/clib/u8g2_buffer.c index f8b71f01..87f16888 100644 --- a/src/clib/u8g2_buffer.c +++ b/src/clib/u8g2_buffer.c @@ -100,7 +100,8 @@ void u8g2_SendBuffer(u8g2_t *u8g2) void u8g2_SetBufferCurrTileRow(u8g2_t *u8g2, uint8_t row) { u8g2->tile_curr_row = row; - u8g2->cb->update(u8g2); + u8g2->cb->update_dimension(u8g2); + u8g2->cb->update_page_win(u8g2); } void u8g2_FirstPage(u8g2_t *u8g2) diff --git a/src/clib/u8g2_hvline.c b/src/clib/u8g2_hvline.c index 19b2377a..a98374e2 100644 --- a/src/clib/u8g2_hvline.c +++ b/src/clib/u8g2_hvline.c @@ -33,38 +33,51 @@ Calltree + void u8g2_DrawHVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) u8g2->cb->draw_l90 - void u8g2_draw_hv_line_4dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) - void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) - void u8g2_draw_pixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y) + u8g2_draw_hv_line_2dir + u8g2->ll_hvline(u8g2, x, y, len, dir); + */ #include "u8g2.h" #include - - - -#ifdef U8G2_WITH_CLIPPING +/*==========================================================*/ +/* intersection procedure */ /* Description: - clip range from a (included) to b (excluded) agains c (included) to d (excluded) + clip range from pos a (included) with line len (a+len excluded) agains c (included) to d (excluded) Assumptions: - a <= b (violation is checked and handled correctly) + len > 0 c <= d (this is not checked) will return 0 if there is no intersection and if a > b - optimized clipping: c is set to 0 */ -//static uint8_t u8g2_clip_intersection(u8g2_uint_t *ap, u8g2_uint_t *bp, u8g2_uint_t c, u8g2_uint_t d) -static uint8_t u8g2_clip_intersection(u8g2_uint_t *ap, u8g2_uint_t *bp, u8g2_uint_t d) + +static uint8_t u8g2_clip_intersection2(u8g2_uint_t *ap, u8g2_uint_t *len, u8g2_uint_t c, u8g2_uint_t d) { u8g2_uint_t a = *ap; - u8g2_uint_t b = *bp; - + u8g2_uint_t b; + b = a; + b += *len; + + /* + Description: + clip range from a (included) to b (excluded) agains c (included) to d (excluded) + Assumptions: + a <= b (violation is checked and handled correctly) + c <= d (this is not checked) + will return 0 if there is no intersection and if a > b + + optimized clipping: c is set to 0 --> 27 Oct 2018: again removed the c==0 assumption + + replaced by uint8_t u8g2_clip_intersection2 + */ + /* handle the a>b case correctly. If code and time is critical, this could */ /* be removed completly (be aware about memory curruption for wrong */ /* arguments) or return 0 for a>b (will lead to skipped lines for wrong */ @@ -78,12 +91,10 @@ static uint8_t u8g2_clip_intersection(u8g2_uint_t *ap, u8g2_uint_t *bp, u8g2_uin { b = d; b--; - *bp = b; } else { - a = 0; - *ap = a; + a = c; } } @@ -91,18 +102,24 @@ static uint8_t u8g2_clip_intersection(u8g2_uint_t *ap, u8g2_uint_t *bp, u8g2_uin if ( a >= d ) return 0; - if ( b <= 0 ) // was b <= c, could be replaced with b == 0 + if ( b <= c ) return 0; - //if ( a < c ) // never true with c == 0 - // *ap = c; + if ( a < c ) + a = c; if ( b > d ) - *bp = d; - + b = d; + + *ap = a; + b -= a; + *len = b; return 1; } +/*==========================================================*/ +/* draw procedures */ + /* x,y Upper left position of the line within the pixel buffer len length of the line in pixel, len must not be 0 @@ -112,121 +129,92 @@ static uint8_t u8g2_clip_intersection(u8g2_uint_t *ap, u8g2_uint_t *bp, u8g2_uin will clip the line and call u8g2_draw_low_level_hv_line() */ -static void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) +void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) { - u8g2_uint_t a; - register u8g2_uint_t w, h; - - h = u8g2->pixel_buf_height; // this must be the real buffer height - w = u8g2->pixel_buf_width; // this could be replaced by u8g2->u8x8.display_info->pixel_width - - - if ( dir == 0 ) - { - if ( y >= h ) - return; - a = x; - a += len; - if ( u8g2_clip_intersection(&x, &a, w) == 0 ) - return; - len = a; - len -= x; - } - else - { - if ( x >= w ) - return; - a = y; - a += len; - if ( u8g2_clip_intersection(&y, &a, h) == 0 ) - return; - len = a; - len -= y; - } - - u8g2->ll_hvline(u8g2, x, y, len, dir); -} - -#endif - -/* - x,y Upper left position of the line (full screen coordinates) - len length of the line in pixel, len must not be 0 - dir 0: horizontal line (left to right) - 1: vertical line (top to bottom) - 2: horizontal line (right to left) - 3: vertical line (bottom to top) - - This function will remove directions 2 and 3. Instead 0 and 1 are used. -*/ -void u8g2_draw_hv_line_4dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) -{ -#ifdef U8G2_WITH_HVLINE_COUNT - u8g2->hv_cnt++; -#endif /* U8G2_WITH_HVLINE_COUNT */ + /* clipping happens before the display rotation */ /* transform to pixel buffer coordinates */ - y -= u8g2->tile_curr_row*8; - - /* additional optimization for one pixel draw */ - /* requires about 60 bytes on the ATMega flash memory */ - /* 20% improvement for single pixel draw test in FPS.ino */ -#ifdef U8G2_WITH_ONE_PIXEL_OPTIMIZATION - if ( len == 1 ) - { - if ( x < u8g2->pixel_buf_width && y < u8g2->pixel_buf_height ) - u8g2->ll_hvline(u8g2, x, y, len, dir); - return; - } -#endif + y -= u8g2->pixel_curr_row; - if ( dir == 2 ) - { - x -= len; - x++; - } - else if ( dir == 3 ) - { - y -= len; - y++; - } - dir &= 1; -#ifdef U8G2_WITH_CLIPPING - u8g2_draw_hv_line_2dir(u8g2, x, y, len, dir); -#else u8g2->ll_hvline(u8g2, x, y, len, dir); -#endif } + /* This is the toplevel function for the hv line draw procedures. This function should be called by the user. + + "dir" may have 4 directions: 0 (left to right), 1, 2, 3 (down up) */ void u8g2_DrawHVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) { /* Make a call to the callback function (e.g. u8g2_draw_l90_r0). */ /* The callback may rotate the hv line */ /* after rotation this will call u8g2_draw_hv_line_4dir() */ - if ( len != 0 ) - u8g2->cb->draw_l90(u8g2, x, y, len, dir); + +#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT + if ( u8g2->is_page_clip_window_intersection != 0 ) +#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */ + if ( len != 0 ) + { + + /* convert to two directions */ + if ( len > 1 ) + { + if ( dir == 2 ) + { + x -= len; + x++; + } + else if ( dir == 3 ) + { + y -= len; + y++; + } + } + dir &= 1; + + /* clip against the user window */ + if ( dir == 0 ) + { + if ( y < u8g2->user_y0 ) + return; + if ( y >= u8g2->user_y1 ) + return; + if ( u8g2_clip_intersection2(&x, &len, u8g2->user_x0, u8g2->user_x1) == 0 ) + return; + } + else + { + if ( x < u8g2->user_x0 ) + return; + if ( x >= u8g2->user_x1 ) + return; + if ( u8g2_clip_intersection2(&y, &len, u8g2->user_y0, u8g2->user_y1) == 0 ) + return; + } + + + u8g2->cb->draw_l90(u8g2, x, y, len, dir); + } } void u8g2_DrawHLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len) { -#ifdef U8G2_WITH_INTERSECTION - if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 ) - return; -#endif /* U8G2_WITH_INTERSECTION */ +// #ifdef U8G2_WITH_INTERSECTION +// if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 ) +// return; +// #endif /* U8G2_WITH_INTERSECTION */ u8g2_DrawHVLine(u8g2, x, y, len, 0); } void u8g2_DrawVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len) { -#ifdef U8G2_WITH_INTERSECTION - if ( u8g2_IsIntersection(u8g2, x, y, x+1, y+len) == 0 ) - return; -#endif /* U8G2_WITH_INTERSECTION */ +// #ifdef U8G2_WITH_INTERSECTION +// if ( u8g2_IsIntersection(u8g2, x, y, x+1, y+len) == 0 ) +// return; +// #endif /* U8G2_WITH_INTERSECTION */ u8g2_DrawHVLine(u8g2, x, y, len, 1); } diff --git a/src/clib/u8g2_intersection.c b/src/clib/u8g2_intersection.c index 8f24b75a..7079eea4 100644 --- a/src/clib/u8g2_intersection.c +++ b/src/clib/u8g2_intersection.c @@ -44,7 +44,7 @@ #endif -#ifdef U8G2_WITH_INTERSECTION +#if defined(U8G2_WITH_INTERSECTION) || defined(U8G2_WITH_CLIP_WINDOW_SUPPORT) #ifdef OLD_VERSION_WITH_SYMETRIC_BOUNDARIES diff --git a/src/clib/u8g2_ll_hvline.c b/src/clib/u8g2_ll_hvline.c index 639dad17..2c8a9c7f 100644 --- a/src/clib/u8g2_ll_hvline.c +++ b/src/clib/u8g2_ll_hvline.c @@ -59,7 +59,7 @@ */ -#ifdef U8G2_HVLINE_SPEED_OPTIMIZATION +#ifdef U8G2_WITH_HVLINE_SPEED_OPTIMIZATION /* x,y Upper left position of the line within the local buffer (not the display!) @@ -75,6 +75,9 @@ void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, uint8_t *ptr; uint8_t bit_pos, mask; uint8_t or_mask, xor_mask; +#ifdef __unix + uint8_t *max_ptr = u8g2->tile_buf_ptr + u8g2_GetU8x8(u8g2)->display_info->tile_width*u8g2->tile_buf_height*8; +#endif //assert(x >= u8g2->buf_x0); //assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8); @@ -106,6 +109,9 @@ void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, { do { +#ifdef __unix + assert(ptr < max_ptr); +#endif *ptr |= or_mask; *ptr ^= xor_mask; ptr++; @@ -116,6 +122,9 @@ void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, { do { +#ifdef __unix + assert(ptr < max_ptr); +#endif *ptr |= or_mask; *ptr ^= xor_mask; @@ -144,7 +153,7 @@ void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, -#else /* U8G2_HVLINE_SPEED_OPTIMIZATION */ +#else /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */ /* x,y position within the buffer @@ -212,7 +221,7 @@ void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, } -#endif /* U8G2_HVLINE_SPEED_OPTIMIZATION */ +#endif /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */ /*=================================================*/ /* @@ -220,7 +229,7 @@ void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, ST7920 */ -#ifdef U8G2_HVLINE_SPEED_OPTIMIZATION +#ifdef U8G2_WITH_HVLINE_SPEED_OPTIMIZATION /* x,y Upper left position of the line within the local buffer (not the display!) @@ -288,7 +297,7 @@ void u8g2_ll_hvline_horizontal_right_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_ } } -#else /* U8G2_HVLINE_SPEED_OPTIMIZATION */ +#else /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */ /* @@ -356,4 +365,4 @@ void u8g2_ll_hvline_horizontal_right_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_ } } -#endif /* U8G2_HVLINE_SPEED_OPTIMIZATION */ +#endif /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */ diff --git a/src/clib/u8g2_setup.c b/src/clib/u8g2_setup.c index 815b6126..6f64e490 100644 --- a/src/clib/u8g2_setup.c +++ b/src/clib/u8g2_setup.c @@ -35,6 +35,33 @@ #include "u8g2.h" #include +#include + + +/*============================================*/ + + +#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT + +void u8g2_SetMaxClipWindow(u8g2_t *u8g2) +{ + u8g2->clip_x0 = 0; + u8g2->clip_y0 = 0; + u8g2->clip_x1 = (u8g2_uint_t)~(u8g2_uint_t)0; + u8g2->clip_y1 = (u8g2_uint_t)~(u8g2_uint_t)0; + + u8g2->cb->update_page_win(u8g2); +} + +void u8g2_SetClipWindow(u8g2_t *u8g2, u8g2_uint_t clip_x0, u8g2_uint_t clip_y0, u8g2_uint_t clip_x1, u8g2_uint_t clip_y1 ) +{ + u8g2->clip_x0 = clip_x0; + u8g2->clip_y0 = clip_y0; + u8g2->clip_x1 = clip_x1; + u8g2->clip_y1 = clip_y1; + u8g2->cb->update_page_win(u8g2); +} +#endif /*============================================*/ /* @@ -62,7 +89,12 @@ void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, u8g2_ u8g2->is_auto_page_clear = 1; u8g2->cb = u8g2_cb; - u8g2->cb->update(u8g2); + u8g2->cb->update_dimension(u8g2); +#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT + u8g2_SetMaxClipWindow(u8g2); /* assign a clip window and call the update() procedure */ +#else + u8g2->cb->update_page_win(u8g2); +#endif u8g2_SetFontPosBaseline(u8g2); /* issue 195 */ @@ -78,7 +110,8 @@ void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, u8g2_ void u8g2_SetDisplayRotation(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb) { u8g2->cb = u8g2_cb; - u8g2->cb->update(u8g2); + u8g2->cb->update_dimension(u8g2); + u8g2->cb->update_page_win(u8g2); } @@ -94,13 +127,14 @@ void u8g2_SetDisplayRotation(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb) static void u8g2_update_dimension_common(u8g2_t *u8g2) { + const u8x8_display_info_t *display_info = u8g2_GetU8x8(u8g2)->display_info; u8g2_uint_t t; t = u8g2->tile_buf_height; t *= 8; u8g2->pixel_buf_height = t; - t = u8g2_GetU8x8(u8g2)->display_info->tile_width; + t = display_info->tile_width; #ifndef U8G2_16BIT if ( t >= 32 ) t = 31; @@ -114,8 +148,8 @@ static void u8g2_update_dimension_common(u8g2_t *u8g2) t = u8g2->tile_buf_height; /* handle the case, where the buffer is larger than the (remaining) part of the display */ - if ( t + u8g2->tile_curr_row > u8g2_GetU8x8(u8g2)->display_info->tile_height ) - t = u8g2_GetU8x8(u8g2)->display_info->tile_height - u8g2->tile_curr_row; + if ( t + u8g2->tile_curr_row > display_info->tile_height ) + t = display_info->tile_height - u8g2->tile_curr_row; t *= 8; u8g2->buf_y0 = u8g2->pixel_curr_row; @@ -124,31 +158,66 @@ static void u8g2_update_dimension_common(u8g2_t *u8g2) #ifdef U8G2_16BIT - u8g2->width = u8g2_GetU8x8(u8g2)->display_info->pixel_width; - u8g2->height = u8g2_GetU8x8(u8g2)->display_info->pixel_height; + u8g2->width = display_info->pixel_width; + u8g2->height = display_info->pixel_height; #else u8g2->width = 240; - if ( u8g2_GetU8x8(u8g2)->display_info->pixel_width <= 240 ) - u8g2->width = u8g2_GetU8x8(u8g2)->display_info->pixel_width; - u8g2->height = u8g2_GetU8x8(u8g2)->display_info->pixel_height; + if ( display_info->pixel_width <= 240 ) + u8g2->width = display_info->pixel_width; + u8g2->height = display_info->pixel_height; #endif } +/*==========================================================*/ +/* apply clip window */ + +#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT +static void u8g2_apply_clip_window(u8g2_t *u8g2) +{ + /* check aganst the current user_??? window */ + if ( u8g2_IsIntersection(u8g2, u8g2->clip_x0, u8g2->clip_y0, u8g2->clip_x1, u8g2->clip_y1) == 0 ) + { + u8g2->is_page_clip_window_intersection = 0; + } + else + { + u8g2->is_page_clip_window_intersection = 1; + + if ( u8g2->user_x0 < u8g2->clip_x0 ) + u8g2->user_x0 = u8g2->clip_x0; + if ( u8g2->user_x1 > u8g2->clip_x1 ) + u8g2->user_x1 = u8g2->clip_x1; + if ( u8g2->user_y0 < u8g2->clip_y0 ) + u8g2->user_y0 = u8g2->clip_y0; + if ( u8g2->user_y1 > u8g2->clip_y1 ) + u8g2->user_y1 = u8g2->clip_y1; + } +} +#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */ + +/*==========================================================*/ + + void u8g2_update_dimension_r0(u8g2_t *u8g2) { - u8g2_update_dimension_common(u8g2); + u8g2_update_dimension_common(u8g2); +} +void u8g2_update_page_win_r0(u8g2_t *u8g2) +{ u8g2->user_x0 = 0; u8g2->user_x1 = u8g2->pixel_buf_width; /* pixel_buf_width replaced with width */ u8g2->user_y0 = u8g2->buf_y0; u8g2->user_y1 = u8g2->buf_y1; -// printf("x0=%d x1=%d y0=%d y1=%d\n", -// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1); +#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT + u8g2_apply_clip_window(u8g2); +#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */ } + void u8g2_update_dimension_r1(u8g2_t *u8g2) { u8g2_update_dimension_common(u8g2); @@ -156,20 +225,28 @@ void u8g2_update_dimension_r1(u8g2_t *u8g2) u8g2->height = u8g2_GetU8x8(u8g2)->display_info->pixel_width; u8g2->width = u8g2_GetU8x8(u8g2)->display_info->pixel_height; +} + +void u8g2_update_page_win_r1(u8g2_t *u8g2) +{ u8g2->user_x0 = u8g2->buf_y0; u8g2->user_x1 = u8g2->buf_y1; u8g2->user_y0 = 0; u8g2->user_y1 = u8g2->height; /* pixel_buf_width replaced with height (which is the real pixel width) */ - //printf("x0=%d x1=%d y0=%d y1=%d\n", - // u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1); +#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT + u8g2_apply_clip_window(u8g2); +#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */ } void u8g2_update_dimension_r2(u8g2_t *u8g2) { u8g2_update_dimension_common(u8g2); +} +void u8g2_update_page_win_r2(u8g2_t *u8g2) +{ u8g2->user_x0 = 0; u8g2->user_x1 = u8g2->width; /* pixel_buf_width replaced with width */ @@ -180,10 +257,12 @@ void u8g2_update_dimension_r2(u8g2_t *u8g2) u8g2->user_y0 = u8g2->height - u8g2->buf_y1; u8g2->user_y1 = u8g2->height - u8g2->buf_y0; -// printf("x0=%d x1=%d y0=%d y1=%d\n", -// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1); +#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT + u8g2_apply_clip_window(u8g2); +#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */ } + void u8g2_update_dimension_r3(u8g2_t *u8g2) { u8g2_update_dimension_common(u8g2); @@ -191,6 +270,10 @@ void u8g2_update_dimension_r3(u8g2_t *u8g2) u8g2->height = u8g2_GetU8x8(u8g2)->display_info->pixel_width; u8g2->width = u8g2_GetU8x8(u8g2)->display_info->pixel_height; +} + +void u8g2_update_page_win_r3(u8g2_t *u8g2) +{ /* there are ases where the height is not a multiple of 8. */ /* in such a case u8g2->buf_y1 might be heigher than u8g2->width */ u8g2->user_x0 = 0; @@ -201,17 +284,22 @@ void u8g2_update_dimension_r3(u8g2_t *u8g2) u8g2->user_y0 = 0; u8g2->user_y1 = u8g2->height; /* pixel_buf_width replaced with height (pixel_width) */ -// printf("x0=%d x1=%d y0=%d y1=%d\n", -// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1); +#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT + u8g2_apply_clip_window(u8g2); +#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */ } + /*============================================*/ -extern void u8g2_draw_hv_line_4dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir); +extern void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir); void u8g2_draw_l90_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) { - u8g2_draw_hv_line_4dir(u8g2, x, y, len, dir); +#ifdef __unix + assert( dir <= 1 ); +#endif + u8g2_draw_hv_line_2dir(u8g2, x, y, len, dir); } void u8g2_draw_l90_mirrorr_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) @@ -227,14 +315,17 @@ void u8g2_draw_l90_mirrorr_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_u { xx--; } - u8g2_draw_hv_line_4dir(u8g2, xx, y, len, dir); + u8g2_draw_hv_line_2dir(u8g2, xx, y, len, dir); } - - +/* dir = 0 or 1 */ void u8g2_draw_l90_r1(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) { u8g2_uint_t xx, yy; + +#ifdef __unix + assert( dir <= 1 ); +#endif yy = x; @@ -243,14 +334,21 @@ void u8g2_draw_l90_r1(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t le xx--; dir ++; - dir &= 3; - u8g2_draw_hv_line_4dir(u8g2, xx, yy, len, dir); + if ( dir == 2 ) + { + xx -= len; + xx++; + dir = 0; + } + + u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir); } void u8g2_draw_l90_r2(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) { u8g2_uint_t xx, yy; + /* yy = u8g2->height; yy -= y; yy--; @@ -259,9 +357,36 @@ void u8g2_draw_l90_r2(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t le xx -= x; xx--; - dir +=2; - dir &= 3; - u8g2_draw_hv_line_4dir(u8g2, xx, yy, len, dir); + if ( dir == 0 ) + { + xx -= len; + xx++; + } + else if ( dir == 1 ) + { + yy -= len; + yy++; + } + */ + + yy = u8g2->height; + yy -= y; + + xx = u8g2->width; + xx -= x; + + if ( dir == 0 ) + { + yy--; + xx -= len; + } + else if ( dir == 1 ) + { + xx--; + yy -= len; + } + + u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir); } void u8g2_draw_l90_r3(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) @@ -272,22 +397,33 @@ void u8g2_draw_l90_r3(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t le yy = u8g2->width; yy -= x; - yy--; - dir +=3; - dir &= 3; - u8g2_draw_hv_line_4dir(u8g2, xx, yy, len, dir); + if ( dir == 0 ) + { + yy--; + yy -= len; + yy++; + dir = 1; + } + else + { + yy--; + dir = 0; + } + + + u8g2_draw_hv_line_2dir(u8g2, xx, yy, len, dir); } /*============================================*/ -const u8g2_cb_t u8g2_cb_r0 = { u8g2_update_dimension_r0, u8g2_draw_l90_r0 }; -const u8g2_cb_t u8g2_cb_r1 = { u8g2_update_dimension_r1, u8g2_draw_l90_r1 }; -const u8g2_cb_t u8g2_cb_r2 = { u8g2_update_dimension_r2, u8g2_draw_l90_r2 }; -const u8g2_cb_t u8g2_cb_r3 = { u8g2_update_dimension_r3, u8g2_draw_l90_r3 }; +const u8g2_cb_t u8g2_cb_r0 = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_l90_r0 }; +const u8g2_cb_t u8g2_cb_r1 = { u8g2_update_dimension_r1, u8g2_update_page_win_r1, u8g2_draw_l90_r1 }; +const u8g2_cb_t u8g2_cb_r2 = { u8g2_update_dimension_r2, u8g2_update_page_win_r2, u8g2_draw_l90_r2 }; +const u8g2_cb_t u8g2_cb_r3 = { u8g2_update_dimension_r3, u8g2_update_page_win_r3, u8g2_draw_l90_r3 }; -const u8g2_cb_t u8g2_cb_mirror = { u8g2_update_dimension_r0, u8g2_draw_l90_mirrorr_r0 }; +const u8g2_cb_t u8g2_cb_mirror = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_l90_mirrorr_r0 }; /*============================================*/ /* setup for the null device */ diff --git a/src/clib/u8x8.h b/src/clib/u8x8.h index b656dfff..21c2cf06 100644 --- a/src/clib/u8x8.h +++ b/src/clib/u8x8.h @@ -321,6 +321,7 @@ struct u8x8_struct u8x8_msg_cb cad_cb; u8x8_msg_cb byte_cb; u8x8_msg_cb gpio_and_delay_cb; + uint32_t bus_clock; /* can be used by the byte function to store the clock speed of the bus */ const uint8_t *font; uint16_t encoding; /* encoding result for utf8 decoder in next_cb */ uint8_t x_offset; /* copied from info struct, can be modified in flip mode */ diff --git a/src/clib/u8x8_d_ssd1305.c b/src/clib/u8x8_d_ssd1305.c index 8291dd56..ef3c8d5d 100644 --- a/src/clib/u8x8_d_ssd1305.c +++ b/src/clib/u8x8_d_ssd1305.c @@ -247,7 +247,7 @@ static const u8x8_display_info_t u8x8_ssd1305_128x32_adafruit_display_info = /* write_pulse_width_ns = */ 150, /* SSD1306: cycle time is 300ns, so use 300/2 = 150 */ /* tile_width = */ 16, /* tile_hight = */ 4, - /* default_x_offset = */ 0, + /* default_x_offset = */ 4, /* flipmode_x_offset = */ 0, /* pixel_width = */ 128, /* pixel_height = */ 32 diff --git a/src/clib/u8x8_d_st75256.c b/src/clib/u8x8_d_st75256.c index 6aa0794b..4c9685a5 100644 --- a/src/clib/u8x8_d_st75256.c +++ b/src/clib/u8x8_d_st75256.c @@ -883,8 +883,8 @@ static const u8x8_display_info_t u8x8_st75256_256x160_display_info = /* write_pulse_width_ns = */ 70, /* tile_width = */ 32, /* tile_hight = */ 20, - /* default_x_offset = */ 0, /* x offset in flipmode 0 */ - /* flipmode_x_offset = */ 0, /* */ + /* default_x_offset = */ 0, + /* flipmode_x_offset = */ 1, /* x offset is used as y offset in flipmode */ /* pixel_width = */ 256, /* pixel_height = */ 160 }; @@ -931,8 +931,8 @@ static const uint8_t u8x8_d_st75256_256x160_init_seq[] = { U8X8_C( 0x030 ), /* select 00 commands */ - U8X8_CAA(0x75, 0, 0x4f), /* row range */ - U8X8_CAA(0x15, 0, 255), /* col range */ + U8X8_CAA(0x75, 0, 0x28), /* row range */ + U8X8_CAA(0x15, 0, 0xFF), /* col range */ //U8X8_C( 0x030 ), /* select 00 commands */ U8X8_CA( 0xbc, 0x02 ), /* data scan dir */ @@ -977,14 +977,14 @@ uint8_t u8x8_d_st75256_jlx256160(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, voi u8x8_cad_SendCmd(u8x8, 0x030 ); /* select command set */ u8x8_cad_SendCmd(u8x8, 0x075 ); /* row */ - if ( u8x8->x_offset == 0 ) /* 0 means flip mode 1 */ + if ( u8x8->x_offset == 1 ) /* 1 means flip mode 1 */ u8x8_cad_SendArg(u8x8, 1+(((u8x8_tile_t *)arg_ptr)->y_pos)); else u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); u8x8_cad_SendArg(u8x8, 0x04f); //u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)); u8x8_cad_SendCmd(u8x8, 0x015 ); /* col */ - u8x8_cad_SendArg(u8x8, x+u8x8->x_offset); + u8x8_cad_SendArg(u8x8, x+u8x8->display_info->default_x_offset); u8x8_cad_SendArg(u8x8, 255); u8x8_cad_SendCmd(u8x8, 0x05c ); diff --git a/src/clib/u8x8_d_st7920.c b/src/clib/u8x8_d_st7920.c index 79fe0d66..a9eae771 100644 --- a/src/clib/u8x8_d_st7920.c +++ b/src/clib/u8x8_d_st7920.c @@ -71,6 +71,9 @@ static const uint8_t u8x8_d_st7920_powersave1_seq[] = { U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ U8X8_C(0x038), /* 8 Bit interface (DL=1), basic instruction set (RE=0) */ U8X8_C(0x008), /* display off */ + U8X8_C(0x034), /* 8 Bit interface (DL=1), extended instruction set (RE=1) */ + U8X8_C(0x001), /* Standby mode */ + U8X8_END_TRANSFER(), /* disable chip */ U8X8_END() /* end of sequence */ };