2016-01-03 23:31:20 +08:00
/*
2016-06-26 16:41:50 +08:00
U8g2Logo . ino
2016-01-03 23:31:20 +08:00
2016-01-04 00:10:50 +08:00
Universal 8 bit Graphics Library ( https : //github.com/olikraus/u8g2/)
2016-01-03 23:31:20 +08:00
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>
2016-06-26 16:41:50 +08:00
# ifdef U8X8_HAVE_HW_SPI
# include <SPI.h>
# endif
# ifdef U8X8_HAVE_HW_I2C
# include <Wire.h>
# endif
2016-01-03 23:31:20 +08:00
/*
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 frame buffer example .
*/
2016-05-11 12:09:51 +08:00
// Please UNCOMMENT one of the contructor lines below
// U8g2 Contructor List (Frame Buffer)
2016-05-12 02:25:14 +08:00
// The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp
2016-05-26 14:31:29 +08:00
// Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected
2016-05-11 12:09:51 +08:00
//U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
2016-06-12 12:49:23 +08:00
//U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition)
2016-01-03 23:31:20 +08:00
//U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_F_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8);
2016-05-26 14:31:29 +08:00
//U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display
2016-01-03 23:31:20 +08:00
//U8G2_SSD1306_128X64_NONAME_F_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_F_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8);
2016-05-15 21:25:34 +08:00
//U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED
//U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED
//U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED
2016-06-22 05:28:39 +08:00
//U8G2_LD7032_60X32_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board
2016-06-25 13:45:09 +08:00
//U8G2_LD7032_60X32_F_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED!
2016-05-26 16:33:09 +08:00
//U8G2_UC1701_EA_DOGS102_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_UC1701_EA_DOGS102_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
2016-05-26 14:31:29 +08:00
//U8G2_ST7920_192X32_F_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_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE);
//U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE);
2016-06-25 03:58:12 +08:00
//U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8);
//U8G2_ST7920_128X64_F_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8);
2016-05-26 16:33:09 +08:00
//U8G2_ST7565_EA_DOGM128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_ST7565_EA_DOGM128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_ST7565_NHD_C12832_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_ST7565_NHD_C12832_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
2016-05-11 12:09:51 +08:00
// End of constructor list
2016-01-03 23:31:20 +08:00
//#define MINI_LOGO
void setup ( void ) {
pinMode ( 9 , OUTPUT ) ;
digitalWrite ( 9 , 0 ) ; // default output in I2C mode for the SSD1306 test shield: set the i2c adr to 0
u8g2 . begin ( ) ;
}
void drawLogo ( void )
{
u8g2 . setFontMode ( 1 ) ; // Transparent
# 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 , " U " ) ;
u8g2 . setFontDirection ( 1 ) ;
u8g2 . setFont ( u8g2_font_inb30_mn ) ;
u8g2 . drawStr ( 21 , 8 , " 8 " ) ;
u8g2 . setFontDirection ( 0 ) ;
u8g2 . setFont ( u8g2_font_inb24_mf ) ;
u8g2 . drawStr ( 51 , 30 , " g " ) ;
u8g2 . drawStr ( 67 , 30 , " \xb2 " ) ;
u8g2 . drawHLine ( 2 , 35 , 47 ) ;
u8g2 . drawHLine ( 3 , 36 , 47 ) ;
u8g2 . drawVLine ( 45 , 32 , 12 ) ;
u8g2 . drawVLine ( 46 , 33 , 12 ) ;
# endif
}
void drawURL ( void )
{
# ifndef MINI_LOGO
u8g2 . setFont ( u8g2_font_4x6_tr ) ;
if ( u8g2 . getDisplayHeight ( ) < 59 )
{
u8g2 . drawStr ( 89 , 20 , " github.com " ) ;
u8g2 . drawStr ( 73 , 29 , " /olikraus/u8g2 " ) ;
}
else
{
u8g2 . drawStr ( 1 , 54 , " github.com/olikraus/u8g2 " ) ;
}
# endif
}
void loop ( void ) {
u8g2 . clearBuffer ( ) ;
drawLogo ( ) ;
drawURL ( ) ;
u8g2 . sendBuffer ( ) ;
delay ( 1000 ) ;
}