2016-10-01 14:37:18 +08:00
/*
HelloWorld . ino
Universal 8 bit 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
/*
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 , 8 x8 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_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_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* 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
2016-10-02 14:00:28 +08:00
//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
2016-10-01 14:37:18 +08:00
//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_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_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_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_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_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_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
// End of constructor list
// XBM file start
// variable name changed from
// static unsigned char u8g2_logo_97x51_bits[]
// to
// static const unsigned char u8g2_logo_97x51_bits[] U8X8_PROGMEM
# define u8g2_logo_97x51_width 97
# define u8g2_logo_97x51_height 51
static const unsigned char u8g2_logo_97x51_bits [ ] U8X8_PROGMEM = {
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x3c , 0x80 , 0x07 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xf8 , 0x00 ,
0x00 , 0x00 , 0x3c , 0x80 , 0x07 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xfe ,
0x03 , 0x00 , 0x00 , 0x3c , 0x80 , 0x07 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0xff , 0x03 , 0x00 , 0x00 , 0x3c , 0x80 , 0x07 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x80 , 0xcf , 0x07 , 0x00 , 0x00 , 0x3c , 0x80 , 0x07 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x80 , 0x83 , 0x07 , 0x00 , 0x00 , 0x3c , 0x80 , 0x07 , 0xf8 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x81 , 0x07 , 0x00 , 0x00 , 0x3c , 0x80 , 0x07 , 0xfc , 0x03 ,
0x1c , 0x00 , 0x3e , 0x1c , 0xc0 , 0x03 , 0x00 , 0x00 , 0x3c , 0x80 , 0x07 , 0xff ,
0x07 , 0x7f , 0x80 , 0xff , 0x3f , 0xe0 , 0x01 , 0x00 , 0x00 , 0x3c , 0x80 , 0x07 ,
0xff , 0x8f , 0xff , 0xc1 , 0xff , 0x3f , 0xf0 , 0x00 , 0x00 , 0x00 , 0x3c , 0x80 ,
0x87 , 0xff , 0xdf , 0xff , 0xc1 , 0xc3 , 0x07 , 0x7c , 0x00 , 0x00 , 0x00 , 0x3c ,
0x80 , 0x87 , 0x0f , 0xfe , 0xff , 0xe3 , 0x81 , 0x03 , 0x1e , 0x00 , 0x00 , 0x00 ,
0x3c , 0x80 , 0xc7 , 0x07 , 0xfc , 0xe3 , 0xe3 , 0x81 , 0x07 , 0x0f , 0x00 , 0x00 ,
0x00 , 0x3c , 0x80 , 0xc7 , 0x07 , 0xf8 , 0xc1 , 0xe7 , 0x81 , 0x87 , 0xff , 0x07 ,
0x00 , 0x00 , 0x3c , 0x80 , 0xc7 , 0x03 , 0xf0 , 0x80 , 0xe7 , 0xc3 , 0x87 , 0xff ,
0x07 , 0x00 , 0x00 , 0x3c , 0x80 , 0xc7 , 0x03 , 0x70 , 0x80 , 0xc7 , 0xe7 , 0x83 ,
0xff , 0x07 , 0x00 , 0x00 , 0x3c , 0x80 , 0xc7 , 0x03 , 0x78 , 0x80 , 0xc7 , 0xff ,
0x03 , 0x00 , 0x00 , 0x00 , 0x00 , 0x3c , 0x80 , 0xc7 , 0x03 , 0xf8 , 0xc0 , 0x87 ,
0xff , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x3c , 0x80 , 0xc7 , 0x07 , 0xfc , 0xc1 ,
0xc7 , 0x7f , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x3c , 0xc0 , 0x87 , 0x0f , 0xfe ,
0xff , 0xe3 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x78 , 0xc0 , 0x83 , 0xff ,
0xdf , 0xff , 0xe3 , 0x03 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xf8 , 0xf1 , 0x03 ,
0xff , 0x8f , 0xff , 0xe1 , 0xff , 0x07 , 0x00 , 0x00 , 0x00 , 0x00 , 0xf0 , 0xff ,
0x01 , 0xfe , 0x0f , 0xff , 0xc0 , 0xff , 0x0f , 0x00 , 0x00 , 0x00 , 0x00 , 0xe0 ,
0xff , 0x00 , 0xfc , 0x03 , 0x7c , 0xc0 , 0xff , 0x1f , 0x00 , 0x00 , 0x00 , 0x00 ,
0x80 , 0x3f , 0x00 , 0xf8 , 0x01 , 0x00 , 0xe0 , 0x01 , 0x1e , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xf0 , 0x00 , 0x1e , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xf0 , 0x00 , 0x1e , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x20 , 0xf0 , 0xc7 , 0x0f ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x60 , 0xe0 , 0xff ,
0x0f , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x60 , 0xc0 ,
0xff , 0x03 , 0x00 , 0x00 , 0x00 , 0x00 , 0xfc , 0xff , 0xff , 0xff , 0xff , 0xff ,
0x01 , 0xff , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xf8 , 0xff , 0xff , 0xff , 0xff ,
0xff , 0x03 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x60 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x60 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x60 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x60 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x60 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x60 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x60 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x40 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x40 , 0x24 , 0x20 , 0x00 ,
0x00 , 0x08 , 0x46 , 0x02 , 0x00 , 0x80 , 0xc0 , 0x40 , 0x00 , 0x0c , 0x6e , 0x6a ,
0xc0 , 0xa4 , 0x48 , 0x04 , 0xaa , 0xac , 0x8c , 0xaa , 0xac , 0x00 , 0x6a , 0xa4 ,
0xaa , 0x20 , 0xea , 0xa4 , 0x64 , 0x66 , 0xaa , 0x46 , 0x4a , 0x8a , 0x00 , 0x4c ,
0xa4 , 0xaa , 0x20 , 0xaa , 0xa2 , 0x44 , 0x2a , 0xaa , 0x28 , 0xaa , 0x4c , 0x00 ,
0xe8 , 0xa8 , 0x6c , 0xc4 , 0xa4 , 0x42 , 0xee , 0x2a , 0xcc , 0x26 , 0x6c , 0xe8 ,
0x00 , 0x06 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x06 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 } ;
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 . begin ( ) ;
}
void loop ( void ) {
u8g2 . firstPage ( ) ;
do {
u8g2 . setFont ( u8g2_font_ncenB14_tr ) ;
u8g2 . drawXBMP ( 0 , 0 , u8g2_logo_97x51_width , u8g2_logo_97x51_height , u8g2_logo_97x51_bits ) ;
} while ( u8g2 . nextPage ( ) ) ;
//delay(1000);
}