├── oled_test2 ├── buffer.ase ├── buffer.bmp ├── buffer.txt └── oled_test2.ino ├── oled_test3 ├── buffer.ase ├── buffer.bmp ├── buffer.txt └── oled_test3.ino ├── README.md ├── .gitattributes ├── .gitignore └── oled_test └── oled_test.ino /oled_test2/buffer.ase: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SonalPinto/Arduino_SSD1306_OLED/HEAD/oled_test2/buffer.ase -------------------------------------------------------------------------------- /oled_test2/buffer.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SonalPinto/Arduino_SSD1306_OLED/HEAD/oled_test2/buffer.bmp -------------------------------------------------------------------------------- /oled_test3/buffer.ase: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SonalPinto/Arduino_SSD1306_OLED/HEAD/oled_test3/buffer.ase -------------------------------------------------------------------------------- /oled_test3/buffer.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SonalPinto/Arduino_SSD1306_OLED/HEAD/oled_test3/buffer.bmp -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Interfacing the Arduino with an SSD1306 driven OLED Display 2 | 3 | Tutorial : [Part 1](http://robotcantalk.blogspot.com/2015/03/interfacing-arduino-with-ssd1306-driven.html), [Part 2](http://robotcantalk.blogspot.com/2015/03/interfacing-arduino-with-ssd1306-driven_9.html) 4 | 5 | ## oled_test 6 | Minimal code to interface the SSD1306 OLED with the Arduino Uno. 7 | 8 | ## oled_test2 9 | Using the SSD1306 OLED as a buffered graphic display with the I2C at 400Khz Fast-Mode. 10 | 11 | ## oled_test3 12 | Benchmarking the code with Wire.h 13 | 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # ========================= 18 | # Operating System Files 19 | # ========================= 20 | 21 | # OSX 22 | # ========================= 23 | 24 | .DS_Store 25 | .AppleDouble 26 | .LSOverride 27 | 28 | # Icon must end with two \r 29 | Icon 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /oled_test2/buffer.txt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File generated by LCD Assistant 3 | // http://en.radzio.dxp.pl/bitmap_converter/ 4 | //------------------------------------------------------------------------------ 5 | 6 | const unsigned char buffer [] = { 7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 8 | 0x00, 0xE0, 0xE0, 0x18, 0x18, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 9 | 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x18, 10 | 0x18, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 11 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 12 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 13 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 14 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 15 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 16 | 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 17 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 18 | 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 19 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 20 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 22 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 24 | 0x00, 0xFF, 0xFF, 0xFE, 0xFE, 0x06, 0x06, 0x06, 0x06, 0x1E, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x06, 25 | 0x06, 0x06, 0x06, 0x06, 0x06, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x1E, 0x06, 0x06, 0x06, 0x06, 0xFE, 26 | 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x7F, 0x7F, 0x87, 0x87, 0x00, 0x00, 0x00, 0x00, 0x60, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x60, 0x00, 0x00, 0x00, 0x00, 0x87, 34 | 0x87, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x0C, 0x0C, 0x0C, 35 | 0x0C, 0x00, 0x00, 0xFC, 0xFC, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xCC, 0xCC, 0x00, 0x00, 0xC0, 36 | 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x30, 0x30, 0x48, 0x86, 0x86, 0x48, 0x30, 0x30, 0x00, 0xC0, 37 | 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xCC, 0xCC, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 38 | 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 40 | 0xF8, 0x18, 0x18, 0x19, 0x19, 0x1E, 0x1E, 0x18, 0x18, 0x18, 0x18, 0x60, 0x60, 0x60, 0x60, 0x60, 41 | 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x1E, 0x19, 42 | 0x19, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x0C, 0x0C, 0x0C, 43 | 0x0C, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x3F, 44 | 0x3F, 0x0C, 0x0C, 0x03, 0x03, 0x00, 0x0C, 0x0C, 0x12, 0x61, 0x61, 0x12, 0x0C, 0x0C, 0x00, 0x03, 45 | 0x03, 0x0C, 0x0C, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 46 | 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x0C, 0x0C, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x60, 0x60, 0x7F, 48 | 0x7F, 0x60, 0x60, 0x60, 0x60, 0xE0, 0xE0, 0xF8, 0xF8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 49 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xF8, 0xF8, 0xE0, 0xE0, 0x60, 50 | 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x60, 0x60, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 54 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 55 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x60, 0x60, 0x60, 56 | 0x60, 0x60, 0x60, 0x60, 0x60, 0xFF, 0xFF, 0x7F, 0x7F, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0xE1, 57 | 0xE1, 0x61, 0x61, 0xE1, 0xE1, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x7F, 0x7F, 0xFF, 0xFF, 0x60, 58 | 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 59 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 60 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 62 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 63 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 64 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7F, 65 | 0x7F, 0x00, 0x00, 0x7F, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x00, 66 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 67 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 68 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 69 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 70 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 71 | }; 72 | -------------------------------------------------------------------------------- /oled_test3/buffer.txt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // File generated by LCD Assistant 3 | // http://en.radzio.dxp.pl/bitmap_converter/ 4 | //------------------------------------------------------------------------------ 5 | 6 | const unsigned char buffer [] = { 7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 8 | 0x00, 0xE0, 0xE0, 0x18, 0x18, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 9 | 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x18, 10 | 0x18, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 11 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 12 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 13 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 14 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 15 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 16 | 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 17 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 18 | 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 19 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 20 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 22 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 24 | 0x00, 0xFF, 0xFF, 0xFE, 0xFE, 0x06, 0x06, 0x06, 0x06, 0x1E, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x06, 25 | 0x06, 0x06, 0x06, 0x06, 0x06, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x1E, 0x06, 0x06, 0x06, 0x06, 0xFE, 26 | 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x7F, 0x7F, 0x87, 0x87, 0x00, 0x00, 0x00, 0x00, 0x60, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x60, 0x00, 0x00, 0x00, 0x00, 0x87, 34 | 0x87, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x0C, 0x0C, 0x0C, 35 | 0x0C, 0x00, 0x00, 0xFC, 0xFC, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xCC, 0xCC, 0x00, 0x00, 0xC0, 36 | 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x30, 0x30, 0x48, 0x86, 0x86, 0x48, 0x30, 0x30, 0x00, 0xC0, 37 | 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xCC, 0xCC, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 38 | 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 40 | 0xF8, 0x18, 0x18, 0x19, 0x19, 0x1E, 0x1E, 0x18, 0x18, 0x18, 0x18, 0x60, 0x60, 0x60, 0x60, 0x60, 41 | 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x1E, 0x19, 42 | 0x19, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x0C, 0x0C, 0x0C, 43 | 0x0C, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x3F, 44 | 0x3F, 0x0C, 0x0C, 0x03, 0x03, 0x00, 0x0C, 0x0C, 0x12, 0x61, 0x61, 0x12, 0x0C, 0x0C, 0x00, 0x03, 45 | 0x03, 0x0C, 0x0C, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 46 | 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x0C, 0x0C, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x60, 0x60, 0x7F, 48 | 0x7F, 0x60, 0x60, 0x60, 0x60, 0xE0, 0xE0, 0xF8, 0xF8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 49 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xF8, 0xF8, 0xE0, 0xE0, 0x60, 50 | 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x60, 0x60, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 54 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 55 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x60, 0x60, 0x60, 56 | 0x60, 0x60, 0x60, 0x60, 0x60, 0xFF, 0xFF, 0x7F, 0x7F, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0xE1, 57 | 0xE1, 0x61, 0x61, 0xE1, 0xE1, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x7F, 0x7F, 0xFF, 0xFF, 0x60, 58 | 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 59 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 60 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 62 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 63 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 64 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7F, 65 | 0x7F, 0x00, 0x00, 0x7F, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x00, 66 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 67 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 68 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 69 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 70 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 71 | }; 72 | -------------------------------------------------------------------------------- /oled_test/oled_test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //~ DEFINES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // Some defines for the SSD1306 controller driving a 128x64 resolution OLED display 5 | // PART - http://www.simplelabs.co.in/content/96-blue-i2c-oled-module 6 | // DATASHEET - https://www.adafruit.com/datasheets/SSD1306.pdf 7 | 8 | // The Slave Address (SLA) of the OLED controller - SSD1306 - is 0x3C 9 | // The LSB is supposed to be the mode. Since we are only going to WRITE to the OLED, the LSB is going to be 0 10 | // SLA (0x3C) + WRITE_MODE (0x00) = 0x78 (0b01111000) 11 | #define OLED_I2C_ADDRESS 0x3C 12 | 13 | // The SSD1306 datasheet (pg.20) says that a control byte has to be sent before sending a command 14 | // Control byte consists of 15 | // bit 7 : Co : Continuation bit - If 0, then it assumes all the next bytes are data (no more control bytes). 16 | // : You can send a stream of data, ie: gRAM dump - if Co=0 17 | // : For Command, you'd prolly wanna set this - one at a time. Hence, Co=1 for commands 18 | // : For Data stream, Co=0 :) 19 | // bit 6 : D/C# : Data/Command Selection bit, Data=1/Command=0 20 | // bit [5-0] : lower 6 bits have to be 0 21 | #define OLED_CONTROL_BYTE_CMD_SINGLE 0x80 22 | #define OLED_CONTROL_BYTE_CMD_STREAM 0x00 23 | #define OLED_CONTROL_BYTE_DATA_STREAM 0x40 24 | 25 | // Fundamental commands (pg.28) 26 | #define OLED_CMD_SET_CONTRAST 0x81 // follow with 0x7F 27 | #define OLED_CMD_DISPLAY_RAM 0xA4 28 | #define OLED_CMD_DISPLAY_ALLON 0xA5 29 | #define OLED_CMD_DISPLAY_NORMAL 0xA6 30 | #define OLED_CMD_DISPLAY_INVERTED 0xA7 31 | #define OLED_CMD_DISPLAY_OFF 0xAE 32 | #define OLED_CMD_DISPLAY_ON 0xAF 33 | 34 | // Addressing Command Table (pg.30) 35 | #define OLED_CMD_SET_MEMORY_ADDR_MODE 0x20 // follow with 0x00 = HORZ mode = Behave like a KS108 graphic LCD 36 | #define OLED_CMD_SET_COLUMN_RANGE 0x21 // can be used only in HORZ/VERT mode - follow with 0x00 + 0x7F = COL127 37 | #define OLED_CMD_SET_PAGE_RANGE 0x22 // can be used only in HORZ/VERT mode - follow with 0x00 + 0x07 = PAGE7 38 | 39 | // Hardware Config (pg.31) 40 | #define OLED_CMD_SET_DISPLAY_START_LINE 0x40 41 | #define OLED_CMD_SET_SEGMENT_REMAP 0xA1 42 | #define OLED_CMD_SET_MUX_RATIO 0xA8 // follow with 0x3F = 64 MUX 43 | #define OLED_CMD_SET_COM_SCAN_MODE 0xC8 44 | #define OLED_CMD_SET_DISPLAY_OFFSET 0xD3 // follow with 0x00 45 | #define OLED_CMD_SET_COM_PIN_MAP 0xDA // follow with 0x12 46 | 47 | // Timing and Driving Scheme (pg.32) 48 | #define OLED_CMD_SET_DISPLAY_CLK_DIV 0xD5 // follow with 0x80 49 | #define OLED_CMD_SET_PRECHARGE 0xD9 // follow with 0x22 50 | #define OLED_CMD_SET_VCOMH_DESELCT 0xDB // follow with 0x30 51 | 52 | // Charge Pump (pg.62) 53 | #define OLED_CMD_SET_CHARGE_PUMP 0x8D // follow with 0x14 54 | 55 | // NOP 56 | #define OLED_CMD_NOP 0xE3 57 | 58 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 59 | 60 | // Box pattern 61 | uint8_t pattern1[] = { 62 | 0x00,0x7E,0x42,0x42,0x42,0x42,0x7E,0x00, 63 | 0x00,0x7E,0x42,0x42,0x42,0x42,0x7E,0x00 64 | }; 65 | 66 | // Cross weave pattern 67 | uint8_t pattern2[] = { 68 | 0x81,0x42,0x24,0x18,0x18,0x24,0x42,0x81, 69 | 0x81,0x42,0x24,0x18,0x18,0x24,0x42,0x81 70 | }; 71 | 72 | void setup() { 73 | // Init the OLED controller 74 | OLED_init(); 75 | } 76 | 77 | void loop() { 78 | // I2C 79 | Wire.beginTransmission(OLED_I2C_ADDRESS); 80 | Wire.write(OLED_CONTROL_BYTE_CMD_STREAM); 81 | Wire.write(OLED_CMD_SET_COLUMN_RANGE); 82 | Wire.write(0x00); 83 | Wire.write(0x7F); 84 | Wire.write(OLED_CMD_SET_PAGE_RANGE); 85 | Wire.write(0); 86 | Wire.write(0x07); 87 | Wire.endTransmission(); 88 | 89 | for(uint16_t i=0;i<1024;i++){ 90 | Wire.beginTransmission(OLED_I2C_ADDRESS); 91 | Wire.write(OLED_CONTROL_BYTE_DATA_STREAM); 92 | for (uint8_t x=0; x<16; x++) { 93 | // Wire.write(0b11000001); 94 | // Wire.write(0x81); 95 | // Wire.write(0x02); 96 | Wire.write(pattern1[x]); 97 | // Wire.write(pattern2[x]); 98 | i++; 99 | } 100 | i--; 101 | Wire.endTransmission(); 102 | } 103 | 104 | delay(5000); 105 | 106 | } 107 | 108 | 109 | void OLED_init() { 110 | // Init the I2C interface (pins A4 and A5 on the Arduino Uno board) in Master Mode. 111 | Wire.begin(); 112 | // keywords: 113 | // SEG = COL = segment = column byte data on a page 114 | // Page = 8 pixel tall row. Has 128 SEGs and 8 COMs 115 | // COM = row 116 | 117 | // Begin the I2C comm with SSD1306's address (SLA+Write) 118 | Wire.beginTransmission(OLED_I2C_ADDRESS); 119 | 120 | // Tell the SSD1306 that a command stream is incoming 121 | Wire.write(OLED_CONTROL_BYTE_CMD_STREAM); 122 | 123 | // Follow instructions on pg.64 of the dataSheet for software configuration of the SSD1306 124 | // Turn the Display OFF 125 | Wire.write(OLED_CMD_DISPLAY_OFF); 126 | // Set mux ration tp select max number of rows - 64 127 | Wire.write(OLED_CMD_SET_MUX_RATIO); 128 | Wire.write(0x3F); 129 | // Set the display offset to 0 130 | Wire.write(OLED_CMD_SET_DISPLAY_OFFSET); 131 | Wire.write(0x00); 132 | // Display start line to 0 133 | Wire.write(OLED_CMD_SET_DISPLAY_START_LINE); 134 | 135 | // Mirror the x-axis. In case you set it up such that the pins are north. 136 | // Wire.write(0xA0); - in case pins are south - default 137 | Wire.write(OLED_CMD_SET_SEGMENT_REMAP); 138 | 139 | // Mirror the y-axis. In case you set it up such that the pins are north. 140 | // Wire.write(0xC0); - in case pins are south - default 141 | Wire.write(OLED_CMD_SET_COM_SCAN_MODE); 142 | 143 | // Default - alternate COM pin map 144 | Wire.write(OLED_CMD_SET_COM_PIN_MAP); 145 | Wire.write(0x12); 146 | // set contrast 147 | Wire.write(OLED_CMD_SET_CONTRAST); 148 | Wire.write(0x7F); 149 | // Set display to enable rendering from GDDRAM (Graphic Display Data RAM) 150 | Wire.write(OLED_CMD_DISPLAY_RAM); 151 | // Normal mode! 152 | Wire.write(OLED_CMD_DISPLAY_NORMAL); 153 | // Default oscillator clock 154 | Wire.write(OLED_CMD_SET_DISPLAY_CLK_DIV); 155 | Wire.write(0x80); 156 | // Enable the charge pump 157 | Wire.write(OLED_CMD_SET_CHARGE_PUMP); 158 | Wire.write(0x14); 159 | // Set precharge cycles to high cap type 160 | Wire.write(OLED_CMD_SET_PRECHARGE); 161 | Wire.write(0x22); 162 | // Set the V_COMH deselect volatage to max 163 | Wire.write(OLED_CMD_SET_VCOMH_DESELCT); 164 | Wire.write(0x30); 165 | // Horizonatal addressing mode - same as the KS108 GLCD 166 | Wire.write(OLED_CMD_SET_MEMORY_ADDR_MODE); 167 | Wire.write(0x00); 168 | // Turn the Display ON 169 | Wire.write(OLED_CMD_DISPLAY_ON); 170 | 171 | // End the I2C comm with the SSD1306 172 | Wire.endTransmission(); 173 | } 174 | 175 | 176 | -------------------------------------------------------------------------------- /oled_test2/oled_test2.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //~ DEFINES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // Some defines for the SSD1306 controller driving a 128x64 resolution OLED display 5 | // PART - http://www.simplelabs.co.in/content/96-blue-i2c-oled-module 6 | // DATASHEET - https://www.adafruit.com/datasheets/SSD1306.pdf 7 | 8 | // The Slave Address (SLA) of the OLED controller - SSD1306 - is 0x3C 9 | // The LSB is supposed to be the mode. Since we are only going to WRITE to the OLED, the LSB is going to be 0 10 | // SLA (0x3C) + WRITE_MODE (0x00) = 0x78 (0b01111000) 11 | #define OLED_I2C_ADDRESS 0x3C 12 | 13 | // The SSD1306 datasheet (pg.20) says that a control byte has to be sent before sending a command 14 | // Control byte consists of 15 | // bit 7 : Co : Continuation bit - If 0, then it assumes all the next bytes are data (no more control bytes). 16 | // : You can send a stream of data, ie: gRAM dump - if Co=0 17 | // : For Command, you'd prolly wanna set this - one at a time. Hence, Co=1 for commands 18 | // : For Data stream, Co=0 :) 19 | // bit 6 : D/C# : Data/Command Selection bit, Data=1/Command=0 20 | // bit [5-0] : lower 6 bits have to be 0 21 | #define OLED_CONTROL_BYTE_CMD_SINGLE 0x80 22 | #define OLED_CONTROL_BYTE_CMD_STREAM 0x00 23 | #define OLED_CONTROL_BYTE_DATA_STREAM 0x40 24 | 25 | // Fundamental commands (pg.28) 26 | #define OLED_CMD_SET_CONTRAST 0x81 // follow with 0x7F 27 | #define OLED_CMD_DISPLAY_RAM 0xA4 28 | #define OLED_CMD_DISPLAY_ALLON 0xA5 29 | #define OLED_CMD_DISPLAY_NORMAL 0xA6 30 | #define OLED_CMD_DISPLAY_INVERTED 0xA7 31 | #define OLED_CMD_DISPLAY_OFF 0xAE 32 | #define OLED_CMD_DISPLAY_ON 0xAF 33 | 34 | // Addressing Command Table (pg.30) 35 | #define OLED_CMD_SET_MEMORY_ADDR_MODE 0x20 // follow with 0x00 = HORZ mode = Behave like a KS108 graphic LCD 36 | #define OLED_CMD_SET_COLUMN_RANGE 0x21 // can be used only in HORZ/VERT mode - follow with 0x00 + 0x7F = COL127 37 | #define OLED_CMD_SET_PAGE_RANGE 0x22 // can be used only in HORZ/VERT mode - follow with 0x00 + 0x07 = PAGE7 38 | 39 | // Hardware Config (pg.31) 40 | #define OLED_CMD_SET_DISPLAY_START_LINE 0x40 41 | #define OLED_CMD_SET_SEGMENT_REMAP 0xA1 42 | #define OLED_CMD_SET_MUX_RATIO 0xA8 // follow with 0x3F = 64 MUX 43 | #define OLED_CMD_SET_COM_SCAN_MODE 0xC8 44 | #define OLED_CMD_SET_DISPLAY_OFFSET 0xD3 // follow with 0x00 45 | #define OLED_CMD_SET_COM_PIN_MAP 0xDA // follow with 0x12 46 | #define OLED_CMD_NOP 0xE3 // NOP 47 | 48 | // Timing and Driving Scheme (pg.32) 49 | #define OLED_CMD_SET_DISPLAY_CLK_DIV 0xD5 // follow with 0x80 50 | #define OLED_CMD_SET_PRECHARGE 0xD9 // follow with 0xF1 51 | #define OLED_CMD_SET_VCOMH_DESELCT 0xDB // follow with 0x30 52 | 53 | // Charge Pump (pg.62) 54 | #define OLED_CMD_SET_CHARGE_PUMP 0x8D // follow with 0x14 55 | 56 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 57 | 58 | // Used LCD Assistant to generate this starting splash screen for the buffer 59 | // 128x64 = 8192 bits = 1024 bytes 60 | static unsigned char buffer [1024] = { 61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 62 | 0x00, 0xE0, 0xE0, 0x18, 0x18, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 63 | 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x18, 64 | 0x18, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 65 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 66 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 67 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 68 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 69 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 70 | 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 71 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 72 | 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 73 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 74 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 75 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 76 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 77 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 78 | 0x00, 0xFF, 0xFF, 0xFE, 0xFE, 0x06, 0x06, 0x06, 0x06, 0x1E, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x06, 79 | 0x06, 0x06, 0x06, 0x06, 0x06, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x1E, 0x06, 0x06, 0x06, 0x06, 0xFE, 80 | 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 81 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 82 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 83 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 84 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 85 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 86 | 0x00, 0x7F, 0x7F, 0x87, 0x87, 0x00, 0x00, 0x00, 0x00, 0x60, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 87 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x60, 0x00, 0x00, 0x00, 0x00, 0x87, 88 | 0x87, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x0C, 0x0C, 0x0C, 89 | 0x0C, 0x00, 0x00, 0xFC, 0xFC, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xCC, 0xCC, 0x00, 0x00, 0xC0, 90 | 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x30, 0x30, 0x48, 0x86, 0x86, 0x48, 0x30, 0x30, 0x00, 0xC0, 91 | 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xCC, 0xCC, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 92 | 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 93 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 94 | 0xF8, 0x18, 0x18, 0x19, 0x19, 0x1E, 0x1E, 0x18, 0x18, 0x18, 0x18, 0x60, 0x60, 0x60, 0x60, 0x60, 95 | 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x1E, 0x19, 96 | 0x19, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x0C, 0x0C, 0x0C, 97 | 0x0C, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x3F, 98 | 0x3F, 0x0C, 0x0C, 0x03, 0x03, 0x00, 0x0C, 0x0C, 0x12, 0x61, 0x61, 0x12, 0x0C, 0x0C, 0x00, 0x03, 99 | 0x03, 0x0C, 0x0C, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 100 | 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x0C, 0x0C, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 101 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x60, 0x60, 0x7F, 102 | 0x7F, 0x60, 0x60, 0x60, 0x60, 0xE0, 0xE0, 0xF8, 0xF8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 103 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xF8, 0xF8, 0xE0, 0xE0, 0x60, 104 | 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x60, 0x60, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 105 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 106 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 107 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 108 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 109 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x60, 0x60, 0x60, 110 | 0x60, 0x60, 0x60, 0x60, 0x60, 0xFF, 0xFF, 0x7F, 0x7F, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0xE1, 111 | 0xE1, 0x61, 0x61, 0xE1, 0xE1, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x7F, 0x7F, 0xFF, 0xFF, 0x60, 112 | 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 113 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 114 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 115 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 116 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 117 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 118 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7F, 119 | 0x7F, 0x00, 0x00, 0x7F, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x00, 120 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 121 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 122 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 123 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 124 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 125 | }; 126 | 127 | unsigned int frame; 128 | 129 | void setup() { 130 | // Init the OLED controller 131 | OLED_init(); 132 | 133 | // Customary delay 134 | delay(250); 135 | } 136 | 137 | void loop() { 138 | // Collect the current time. This is to ensure maximum frame time will be 40ms 139 | frame=millis(); 140 | 141 | // Set the GDDRAM to (Row0, Col0), ie: top-left and establish range as the whole screen - 128x64 142 | Wire.beginTransmission(OLED_I2C_ADDRESS); 143 | Wire.write(OLED_CONTROL_BYTE_CMD_STREAM); 144 | // column 0 to 127 145 | Wire.write(OLED_CMD_SET_COLUMN_RANGE); 146 | Wire.write(0x00); 147 | Wire.write(0x7F); 148 | // page 0 to 7 149 | Wire.write(OLED_CMD_SET_PAGE_RANGE); 150 | Wire.write(0x00); 151 | Wire.write(0x07); 152 | Wire.endTransmission(); 153 | 154 | for(uint16_t i=0;i<1024;i++){ 155 | Wire.beginTransmission(OLED_I2C_ADDRESS); 156 | Wire.write(OLED_CONTROL_BYTE_DATA_STREAM); 157 | for (uint8_t x=0; x<16; x++) { 158 | Wire.write(buffer[i]); 159 | i++; 160 | } 161 | i--; 162 | Wire.endTransmission(); 163 | } 164 | 165 | // Frame Guard. Ensure that the frame lasted at least 40ms 166 | while((millis()-frame)<40){}; 167 | } 168 | 169 | 170 | void OLED_init() { 171 | // Init the I2C interface (pins A4 and A5 on the Arduino Uno board) in Master Mode. 172 | Wire.begin(); 173 | 174 | // Set the I2C to HS mode - 400KHz! 175 | // TWBR = (CPU_CLK / I2C_CLK) -16 /2 176 | // TWBR = ((16,000,000 / 400,000) - 16) / 2 = 12 177 | TWBR=12; 178 | 179 | // keywords: 180 | // SEG = COL = segment = column byte data on a page 181 | // Page = 8 pixel tall row. Has 128 SEGs and 8 COMs 182 | // COM = row 183 | 184 | // Begin the I2C comm with SSD1306's address (SLA+Write) 185 | Wire.beginTransmission(OLED_I2C_ADDRESS); 186 | 187 | // Tell the SSD1306 that a command stream is incoming 188 | Wire.write(OLED_CONTROL_BYTE_CMD_STREAM); 189 | 190 | // Follow instructions on pg.64 of the dataSheet for software configuration of the SSD1306 191 | // Turn the Display OFF 192 | Wire.write(OLED_CMD_DISPLAY_OFF); 193 | // Set mux ration tp select max number of rows - 64 194 | Wire.write(OLED_CMD_SET_MUX_RATIO); 195 | Wire.write(0x3F); 196 | // Set the display offset to 0 197 | Wire.write(OLED_CMD_SET_DISPLAY_OFFSET); 198 | Wire.write(0x00); 199 | // Display start line to 0 200 | Wire.write(OLED_CMD_SET_DISPLAY_START_LINE); 201 | 202 | // Mirror the x-axis. In case you set it up such that the pins are north. 203 | // Wire.write(0xA0); - in case pins are south - default 204 | Wire.write(OLED_CMD_SET_SEGMENT_REMAP); 205 | 206 | // Mirror the y-axis. In case you set it up such that the pins are north. 207 | // Wire.write(0xC0); - in case pins are south - default 208 | Wire.write(OLED_CMD_SET_COM_SCAN_MODE); 209 | 210 | // Default - alternate COM pin map 211 | Wire.write(OLED_CMD_SET_COM_PIN_MAP); 212 | Wire.write(0x12); 213 | // set contrast 214 | Wire.write(OLED_CMD_SET_CONTRAST); 215 | Wire.write(0x7F); 216 | // Set display to enable rendering from GDDRAM (Graphic Display Data RAM) 217 | Wire.write(OLED_CMD_DISPLAY_RAM); 218 | // Normal mode! 219 | Wire.write(OLED_CMD_DISPLAY_NORMAL); 220 | // Default oscillator clock 221 | Wire.write(OLED_CMD_SET_DISPLAY_CLK_DIV); 222 | Wire.write(0x80); 223 | // Enable the charge pump 224 | Wire.write(OLED_CMD_SET_CHARGE_PUMP); 225 | Wire.write(0x14); 226 | // Set precharge cycles to high cap type 227 | Wire.write(OLED_CMD_SET_PRECHARGE); 228 | Wire.write(0x22); 229 | // Set the V_COMH deselect volatage to max 230 | Wire.write(OLED_CMD_SET_VCOMH_DESELCT); 231 | Wire.write(0x30); 232 | // Horizonatal addressing mode - same as the KS108 GLCD 233 | Wire.write(OLED_CMD_SET_MEMORY_ADDR_MODE); 234 | Wire.write(0x00); 235 | // Turn the Display ON 236 | Wire.write(OLED_CMD_DISPLAY_ON); 237 | 238 | // End the I2C comm with the SSD1306 239 | Wire.endTransmission(); 240 | } 241 | -------------------------------------------------------------------------------- /oled_test3/oled_test3.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //~ DEFINES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // Some defines for the SSD1306 controller driving a 128x64 resolution OLED display 5 | // PART - http://www.simplelabs.co.in/content/96-blue-i2c-oled-module 6 | // DATASHEET - https://www.adafruit.com/datasheets/SSD1306.pdf 7 | 8 | // The Slave Address (SLA) of the OLED controller - SSD1306 - is 0x3C 9 | // The LSB is supposed to be the mode. Since we are only going to WRITE to the OLED, the LSB is going to be 0 10 | // SLA (0x3C) + WRITE_MODE (0x00) = 0x78 (0b01111000) 11 | #define OLED_I2C_ADDRESS 0x3C 12 | 13 | // The SSD1306 datasheet (pg.20) says that a control byte has to be sent before sending a command 14 | // Control byte consists of 15 | // bit 7 : Co : Continuation bit - If 0, then it assumes all the next bytes are data (no more control bytes). 16 | // : You can send a stream of data, ie: gRAM dump - if Co=0 17 | // : For Command, you'd prolly wanna set this - one at a time. Hence, Co=1 for commands 18 | // : For Data stream, Co=0 :) 19 | // bit 6 : D/C# : Data/Command Selection bit, Data=1/Command=0 20 | // bit [5-0] : lower 6 bits have to be 0 21 | #define OLED_CONTROL_BYTE_CMD_SINGLE 0x80 22 | #define OLED_CONTROL_BYTE_CMD_STREAM 0x00 23 | #define OLED_CONTROL_BYTE_DATA_STREAM 0x40 24 | 25 | // Fundamental commands (pg.28) 26 | #define OLED_CMD_SET_CONTRAST 0x81 // follow with 0x7F 27 | #define OLED_CMD_DISPLAY_RAM 0xA4 28 | #define OLED_CMD_DISPLAY_ALLON 0xA5 29 | #define OLED_CMD_DISPLAY_NORMAL 0xA6 30 | #define OLED_CMD_DISPLAY_INVERTED 0xA7 31 | #define OLED_CMD_DISPLAY_OFF 0xAE 32 | #define OLED_CMD_DISPLAY_ON 0xAF 33 | 34 | // Addressing Command Table (pg.30) 35 | #define OLED_CMD_SET_MEMORY_ADDR_MODE 0x20 // follow with 0x00 = HORZ mode = Behave like a KS108 graphic LCD 36 | #define OLED_CMD_SET_COLUMN_RANGE 0x21 // can be used only in HORZ/VERT mode - follow with 0x00 + 0x7F = COL127 37 | #define OLED_CMD_SET_PAGE_RANGE 0x22 // can be used only in HORZ/VERT mode - follow with 0x00 + 0x07 = PAGE7 38 | 39 | // Hardware Config (pg.31) 40 | #define OLED_CMD_SET_DISPLAY_START_LINE 0x40 41 | #define OLED_CMD_SET_SEGMENT_REMAP 0xA1 42 | #define OLED_CMD_SET_MUX_RATIO 0xA8 // follow with 0x3F = 64 MUX 43 | #define OLED_CMD_SET_COM_SCAN_MODE 0xC8 44 | #define OLED_CMD_SET_DISPLAY_OFFSET 0xD3 // follow with 0x00 45 | #define OLED_CMD_SET_COM_PIN_MAP 0xDA // follow with 0x12 46 | #define OLED_CMD_NOP 0xE3 // NOP 47 | 48 | // Timing and Driving Scheme (pg.32) 49 | #define OLED_CMD_SET_DISPLAY_CLK_DIV 0xD5 // follow with 0x80 50 | #define OLED_CMD_SET_PRECHARGE 0xD9 // follow with 0x22 51 | #define OLED_CMD_SET_VCOMH_DESELCT 0xDB // follow with 0x30 52 | 53 | // Charge Pump (pg.62) 54 | #define OLED_CMD_SET_CHARGE_PUMP 0x8D // follow with 0x14 55 | 56 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 57 | 58 | // Used LCD Assistant to generate this starting splash screen for the buffer 59 | // 128x64 = 8192 bits = 1024 bytes 60 | static unsigned char buffer [1024] = { 61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 62 | 0x00, 0xE0, 0xE0, 0x18, 0x18, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 63 | 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x18, 64 | 0x18, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 65 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 66 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 67 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 68 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 69 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 70 | 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 71 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 72 | 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 73 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 74 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 75 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 76 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 77 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 78 | 0x00, 0xFF, 0xFF, 0xFE, 0xFE, 0x06, 0x06, 0x06, 0x06, 0x1E, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x06, 79 | 0x06, 0x06, 0x06, 0x06, 0x06, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x1E, 0x06, 0x06, 0x06, 0x06, 0xFE, 80 | 0xFE, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 81 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 82 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 83 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 84 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 85 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 86 | 0x00, 0x7F, 0x7F, 0x87, 0x87, 0x00, 0x00, 0x00, 0x00, 0x60, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 87 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x60, 0x00, 0x00, 0x00, 0x00, 0x87, 88 | 0x87, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xF0, 0x0C, 0x0C, 0x0C, 89 | 0x0C, 0x00, 0x00, 0xFC, 0xFC, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xCC, 0xCC, 0x00, 0x00, 0xC0, 90 | 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x30, 0x30, 0x48, 0x86, 0x86, 0x48, 0x30, 0x30, 0x00, 0xC0, 91 | 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, 0xCC, 0xCC, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 92 | 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 93 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 94 | 0xF8, 0x18, 0x18, 0x19, 0x19, 0x1E, 0x1E, 0x18, 0x18, 0x18, 0x18, 0x60, 0x60, 0x60, 0x60, 0x60, 95 | 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x1E, 0x19, 96 | 0x19, 0x18, 0x18, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x0C, 0x0C, 0x0C, 97 | 0x0C, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x3F, 98 | 0x3F, 0x0C, 0x0C, 0x03, 0x03, 0x00, 0x0C, 0x0C, 0x12, 0x61, 0x61, 0x12, 0x0C, 0x0C, 0x00, 0x03, 99 | 0x03, 0x0C, 0x0C, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x0F, 100 | 0x0F, 0x00, 0x00, 0x0F, 0x0F, 0x0C, 0x0C, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 101 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x60, 0x60, 0x7F, 102 | 0x7F, 0x60, 0x60, 0x60, 0x60, 0xE0, 0xE0, 0xF8, 0xF8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 103 | 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xF8, 0xF8, 0xE0, 0xE0, 0x60, 104 | 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x60, 0x60, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 105 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 106 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 107 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 108 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 109 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x60, 0x60, 0x60, 110 | 0x60, 0x60, 0x60, 0x60, 0x60, 0xFF, 0xFF, 0x7F, 0x7F, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0xE1, 111 | 0xE1, 0x61, 0x61, 0xE1, 0xE1, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x7F, 0x7F, 0xFF, 0xFF, 0x60, 112 | 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 113 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 114 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 115 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 116 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 117 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 118 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7F, 119 | 0x7F, 0x00, 0x00, 0x7F, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x00, 120 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 121 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 122 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 123 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 124 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 125 | }; 126 | 127 | unsigned long start_time, end_time; 128 | unsigned int frame=-1; 129 | unsigned int frame_cntr=0; 130 | 131 | void setup() { 132 | Serial.begin(19200); 133 | Serial.println("RDY"); 134 | 135 | // Init the OLED controller 136 | OLED_init(); 137 | 138 | // Customary delay 139 | delay(250); 140 | } 141 | 142 | void loop() { 143 | // if(frame==-1){ 144 | // frame=millis(); 145 | // } 146 | start_time = micros(); 147 | 148 | Wire.beginTransmission(OLED_I2C_ADDRESS); 149 | Wire.write(OLED_CONTROL_BYTE_CMD_STREAM); 150 | Wire.write(OLED_CMD_SET_COLUMN_RANGE); 151 | Wire.write(0x00); 152 | Wire.write(0x7F); 153 | Wire.write(OLED_CMD_SET_PAGE_RANGE); 154 | Wire.write(0x00); 155 | Wire.write(0x07); 156 | Wire.endTransmission(); 157 | 158 | for(uint16_t i=0;i<1024;i++){ 159 | Wire.beginTransmission(OLED_I2C_ADDRESS); 160 | Wire.write(OLED_CONTROL_BYTE_DATA_STREAM); 161 | for (uint8_t x=0; x<16; x++) { 162 | Wire.write(buffer[i]); 163 | i++; 164 | } 165 | i--; 166 | Wire.endTransmission(); 167 | } 168 | 169 | end_time = micros(); 170 | Serial.println("Frame Time: "); 171 | Serial.println(end_time-start_time); 172 | while(1){}; 173 | 174 | // Frame Guard 175 | // while((millis()-frame)<40){ }; 176 | 177 | // frame_cntr++; 178 | // if((millis()-frame)>=1000){ 179 | // Serial.println("Frame Rate: "); 180 | // Serial.println(frame_cntr); 181 | // // while(1){}; 182 | // frame_cntr=0; 183 | // frame=millis(); 184 | // }; 185 | } 186 | 187 | 188 | void OLED_init() { 189 | // Init the I2C interface (pins A4 and A5 on the Arduino Uno board) in Master Mode. 190 | Wire.begin(); 191 | 192 | // Set the I2C to HS mode - 400KHz! 193 | // TWBR = (CPU_CLK / I2C_CLK) -16 /2 194 | // TWBR = ((16,000,000 / 400,000) - 16) / 2 = 12 195 | TWBR=12; 196 | 197 | // keywords: 198 | // SEG = COL = segment = column byte data on a page 199 | // Page = 8 pixel tall row. Has 128 SEGs and 8 COMs 200 | // COM = row 201 | 202 | // Begin the I2C comm with SSD1306's address (SLA+Write) 203 | Wire.beginTransmission(OLED_I2C_ADDRESS); 204 | 205 | // Tell the SSD1306 that a command stream is incoming 206 | Wire.write(OLED_CONTROL_BYTE_CMD_STREAM); 207 | 208 | // Follow instructions on pg.64 of the dataSheet for software configuration of the SSD1306 209 | // Turn the Display OFF 210 | Wire.write(OLED_CMD_DISPLAY_OFF); 211 | // Set mux ration tp select max number of rows - 64 212 | Wire.write(OLED_CMD_SET_MUX_RATIO); 213 | Wire.write(0x3F); 214 | // Set the display offset to 0 215 | Wire.write(OLED_CMD_SET_DISPLAY_OFFSET); 216 | Wire.write(0x00); 217 | // Display start line to 0 218 | Wire.write(OLED_CMD_SET_DISPLAY_START_LINE); 219 | 220 | // Mirror the x-axis. In case you set it up such that the pins are north. 221 | // Wire.write(0xA0); - in case pins are south - default 222 | Wire.write(OLED_CMD_SET_SEGMENT_REMAP); 223 | 224 | // Mirror the y-axis. In case you set it up such that the pins are north. 225 | // Wire.write(0xC0); - in case pins are south - default 226 | Wire.write(OLED_CMD_SET_COM_SCAN_MODE); 227 | 228 | // Default - alternate COM pin map 229 | Wire.write(OLED_CMD_SET_COM_PIN_MAP); 230 | Wire.write(0x12); 231 | // set contrast 232 | Wire.write(OLED_CMD_SET_CONTRAST); 233 | Wire.write(0x7F); 234 | // Set display to enable rendering from GDDRAM (Graphic Display Data RAM) 235 | Wire.write(OLED_CMD_DISPLAY_RAM); 236 | // Normal mode! 237 | Wire.write(OLED_CMD_DISPLAY_NORMAL); 238 | // Default oscillator clock 239 | Wire.write(OLED_CMD_SET_DISPLAY_CLK_DIV); 240 | Wire.write(0x80); 241 | // Enable the charge pump 242 | Wire.write(OLED_CMD_SET_CHARGE_PUMP); 243 | Wire.write(0x14); 244 | // Set precharge cycles to high cap type 245 | Wire.write(OLED_CMD_SET_PRECHARGE); 246 | Wire.write(0x22); 247 | // Set the V_COMH deselect volatage to max 248 | Wire.write(OLED_CMD_SET_VCOMH_DESELCT); 249 | Wire.write(0x30); 250 | // Horizonatal addressing mode - same as the KS108 GLCD 251 | Wire.write(OLED_CMD_SET_MEMORY_ADDR_MODE); 252 | Wire.write(0x00); 253 | // Turn the Display ON 254 | Wire.write(OLED_CMD_DISPLAY_ON); 255 | 256 | // End the I2C comm with the SSD1306 257 | Wire.endTransmission(); 258 | } 259 | --------------------------------------------------------------------------------