diff --git a/examples/page_buffer/FlipMode/FlipMode.ino b/examples/page_buffer/FlipMode/FlipMode.ino new file mode 100644 index 00000000..6a270657 --- /dev/null +++ b/examples/page_buffer/FlipMode/FlipMode.ino @@ -0,0 +1,128 @@ +/* + + FlipMode.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 +#include + +/* + Preconditions: + Uno with DOGS102 Shield +*/ + +// 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_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_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_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_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_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board +//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_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_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); +//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_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); + + + + +// End of constructor list + + + + + + + +void setup(void) { + u8g2.begin(); + u8g2.setFont(u8g2_font_6x10_tr); +} + + +void draw(const char *s) +{ + u8g2.firstPage(); + do { + u8g2.drawStr(0,15,"Hello World!"); + u8g2.drawStr(0,30,s); + u8g2.drawFrame(0,0,u8g2.getDisplayWidth(),u8g2.getDisplayHeight() ); + } while ( u8g2.nextPage() ); + delay(2000); +} + + +void loop(void) { + + + u8g2.setDisplayRotation(U8G2_R0); + u8g2.setFlipMode(0); + draw("R0,F0"); + u8g2.setFlipMode(1); + draw("R0,F1"); + + u8g2.setDisplayRotation(U8G2_R1); + u8g2.setFlipMode(0); + draw("R1,F0"); + u8g2.setFlipMode(1); + draw("R1,F1"); + + u8g2.setDisplayRotation(U8G2_R2); + u8g2.setFlipMode(0); + draw("R2,F0"); + u8g2.setFlipMode(1); + draw("R2,F1"); + + u8g2.setDisplayRotation(U8G2_R3); + u8g2.setFlipMode(0); + draw("R3,F0"); + u8g2.setFlipMode(1); + draw("R3,F1"); + +} + diff --git a/src/clib/u8x8_d_ld7032_60x32.c b/src/clib/u8x8_d_ld7032_60x32.c index de8cb194..516bec08 100644 --- a/src/clib/u8x8_d_ld7032_60x32.c +++ b/src/clib/u8x8_d_ld7032_60x32.c @@ -1,6 +1,7 @@ /* u8x8_d_ld7032_60x32.c + Note: Flip Mode is NOT supported Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) @@ -43,7 +44,7 @@ static const uint8_t u8x8_d_ld7032_60x32_init_seq[] = { U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ - U8X8_CA(0x002, 0x001), /* Dot Matrix Display ON */ + //U8X8_CA(0x002, 0x001), /* Dot Matrix Display ON */ U8X8_CA(0x014, 0x000), /* Stand-by OFF */ U8X8_CA(0x01a, 0x004), /* Dot Matrix Frame Rate, special value for this OLED from manual*/ U8X8_CA(0x01d, 0x000), /* Graphics Memory Writing Direction: reset default (right down, horizontal) */ @@ -58,7 +59,7 @@ static const uint8_t u8x8_d_ld7032_60x32_init_seq[] = { U8X8_CA(0x048, 0x003), /* Row overlap timing: Pre-Charge + Peak Delay + Peak boot Timing */ U8X8_CA(0x03f, 0x011), /* VCC_R_SEL: ??? */ U8X8_CA(0x03d, 0x000), /* VSS selection: 2.8V */ - U8X8_CA(0x002, 0x001), /* Dot Matrix Display ON */ + //U8X8_CA(0x002, 0x001), /* Dot Matrix Display ON */ U8X8_END_TRANSFER(), /* disable chip */ @@ -81,14 +82,14 @@ static const uint8_t u8x8_d_ld7032_60x32_powersave1_seq[] = { static const uint8_t u8x8_d_ld7032_60x32_flip0_seq[] = { U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ - + U8X8_CA(0x009, 0x000), /* Display Direction: reset default (x,y: min --> max) */ U8X8_END_TRANSFER(), /* disable chip */ U8X8_END() /* end of sequence */ }; static const uint8_t u8x8_d_ld7032_60x32_flip1_seq[] = { U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */ - + //U8X8_CA(0x009, 0x002), /* Display Direction: reset default (x,y: min --> max) */ U8X8_END_TRANSFER(), /* disable chip */ U8X8_END() /* end of sequence */ }; @@ -146,7 +147,7 @@ static uint8_t u8x8_d_ld7032_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, u8x8_cad_SendCmd(u8x8, 0x035 ); u8x8_cad_SendArg(u8x8, 0x007 ); u8x8_cad_SendCmd(u8x8, 0x036 ); - u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos) ); + u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)*8 ); u8x8_cad_SendCmd(u8x8, 0x037 ); u8x8_cad_SendArg(u8x8, 0x01f ); u8x8_cad_SendCmd(u8x8, 0x008 );