Skip to content

Latest commit

 

History

History
166 lines (117 loc) · 5.89 KB

README.md

File metadata and controls

166 lines (117 loc) · 5.89 KB

 OLED

SSD1306_OLED_PICO

Table of contents

Overview

  • Name : SSD1306_OLED_RPI
  • Description :
  1. Library to support the I2C OLED Display Module driven by the SSD1306 controller for the Raspberry PI PICO rp2040
  2. Invert color, rotate, sleep, scroll and contrast control.
  3. 10 fonts included, fonts can easily be added or removed.
  4. Graphics class included.
  5. Bitmaps supported.
  6. Can support both I2C ports. IC20 or IC21 selected by user.
  7. Tested on 128X64 & 128X32 display size. Should work for 96X16 display size.
  8. Polymorphic print class included to print many data types.
  • Author: Gavin Lyons

  • Developed on Toolchain:

    1. Raspberry pi PICO RP2040
    2. SDK(1.4.0) C++20
    3. compiler G++ for arm-none-eabi((15:10.3-2021.07-4)
    4. CMAKE(VERSION 3.18) , VScode(1.84.2)
    5. Linux Mint 21.2

Test

There are 9 example files included. User picks the one they want by editing the CMakeLists.txt :: add_executable(${PROJECT_NAME} section. Comment in one path and one path only.

Filename File Function Screen Size
HELLO Basic use case 128x64
HELLO_128_32 Basic use case 128x32
BITMAP Shows use of bitmaps 128x64
CLOCK_DEMO A basic clock Demo 128x64
FUNCTIONS Test OLED functionality: scroll, rotate etc 128x64
SPEED_TEST Frame rate per second test 128x64
TEXT Tests Text & fonts 128x64
GRAPHICS Tests graphics 128x64
I2C_TEST I2C interface testing 128x64

Software

API

The API (application programming interface) documentation is at link hosted on github pages and generated by Doxygen software. Lots of information on the software.

API URL Link

I2C

Hardware I2C.

  1. I2C Address is set by default to 0x3C(your module could be different, user can change argument passed into "OLEDbegin" method).

  2. Can support both I2C ports. IC20 or IC21 selected by user.

  3. I2C Clock rate can be a passed into in the "OLEDbegin" method as a argument in Kilo hertz.

Frame rate per second example file results I2C clock rate KiloHetrz
5 100
12 400
  1. The user must also specify the data and clk lines which are linked to the interface used

In all the examples the I2C is set up for :: Address 0x3C , Interface I2C1 , Clock speed 100Khz, Data pin GPIO 18, Clock pin GPIO 19 .

Fonts

There are 10 fonts packaged with library. Fonts can be easily added or removed by user. All the Font data is in file SSD1306_OLED_font.cpp and SSD1306_OLED_font.hpp

Font data table:

num Font pointer name character size XxY ASCII range Size in bytes
1 pFontDefault 6x8 0 - 0xFE, Full Extended 1534
2 pFontWide 9x8 0x20 - 0x5A, NO lowercase letters 535
3 pFontPico 4x6 0x20 - 0x7E 289
4 pFontSinclairS 8x8 0x20 - 0x7E 764
5 pFontMega 16x16 0x20 - 0x7E 3044
6 pFontArialBold 16x16 0x20 - 0x7E 3044
7 pFontHallfetica 16x16 0x20 - 0x7E 3044
8 pFontArialRound 16x24 0x20 - 0x7E 4564
9 pFontGroTesk 16x32 0x20 - 0x7A 5828
10 pFontSixteenSeg 32x48 0x2D-0x3A , 0-10 : . / - only 2692

Font size in bytes = ((X * (Y/8)) * numberOfCharacters) + (4*ControlByte)

Font class Function Notes
writeChar draws single character
writeCharString draws character array
print Polymorphic print class which will print out many data types

These methods return an error code in event of an error such as, ASCII character outside chosen fonts range, character out of screen bounds and invalid character array pointer object.

Remove a font

To remove an unwanted font from project simply comment out or delete.

  1. The Font data in SSD1306_OLED_font.cpp file
  2. The pointer to font at bottom of SSD1306_OLED_font.cpp file
  3. The associated extern pointer declaration in the SSD1306_OLED_font.hpp file

Adding a new font

  1. Add the Font data in SSD1306_OLED_font.cpp file
  2. Add a pointer to font at bottom of SSD1306_OLED_font.cpp file
  3. Add an associated extern pointer declaration in the SSD1306_OLED_font.hpp file

The new ASCII font must have following font structure. First 4 bytes are control bytes followed by vertically addressed font data.

// An 4 by 8 character size font starting at 
// ASCII offset 0x30 in ASCII table with 0x02 characters in font. 
// 0 and 1 
static const uint8_t FontBinaryExample[] =
{
0x04, 0x08, 0x30, 0x02,   // x-size, y-size, offset, total characters
(data),(data),(data),(data) // font data '0'
(data),(data),(data),(data) // font data '1'
}

Some of the fonts packaged with library came from URL. If you have picture of font like so.

 font

There is a monochrome font maker there at URL

Bitmaps

OLEDBitmap function will return an error if : The Bitmap is completely off screen , Invalid Bitmap pointer object, bitmap bigger than screen , bitmap bigger/smaller than provided width and height calculation ( This helps prevents buffer overflow). A horizontal addressed Bitmap's width MUST be divisible by 8. eg, for a bitmap with width=88 and height=48. Bitmap excepted size = (88/8) * 48 = 528 bytes.

Bitmaps can be turned to data here at link See example file "_BITMAP" for more details.

Screenshots

 ss