Giter Site home page Giter Site logo

pico-ssd1306's Introduction

SSD1306 OLED Library for RP2040

1. Importing the library

  • Clone this project into your pico project
  • Add this to your CMakeLists.txt
      add_subdirectory(pico-ssd1306)
      target_link_libraries(${PROJECT_NAME}
          pico_ssd1306
      )
  • Import library in your code
    #include "pico-ssd1306/ssd1306.h"

2. Basic usage

i2c_init(I2C_PORT, 1000000); //Use i2c port with baud rate of 1Mhz
//Set pins for I2C operation
gpio_set_function(I2C_PIN_SDA, GPIO_FUNC_I2C);
gpio_set_function(I2C_PIN_SCL, GPIO_FUNC_I2C);
gpio_pull_up(I2C_PIN_SDA);
gpio_pull_up(I2C_PIN_SCL);

//Create a new display object
pico_ssd1306::SSD1306 display = pico_ssd1306::SSD1306(I2C_PORT, 0x3D, pico_ssd1306::Size::W128xH64);

//create a vertical line on x: 64 y:0-63
for (int y = 0; y < 64; y++){
    display.setPixel(64, y);
}
display.sendBuffer(); //Send buffer to device and show on screen

Expected output:

example1

You may have noticed that this entire library is under pico_ssd1306 namespace to avoid conflicts, but if you don't have any conflicts and don't want to write pico_ssd1306:: all the time just add

using namespace pico_ssd1306;

to your file

3. Principles of operation

See usage explanation for detailed information on how to use core of the lib, but in short:

  • First Initialize i2c and pins for i2c communication
  • Create a display object. This automatically send setup commands to the device and prepares it for operation
  • Modify the buffer containing pixel data
  • Send buffer to display
  • Clear the buffer and repeat

4. Pixel Addressing

pixel_addressing

same is true for 128x32 displays, then y range is 0-31

5. Additional Modules

This library comes with additional modules for shape rendering and text rendering to make your life easier

Importing Shape Renderer

#include "pico-ssd1306/shapeRenderer/ShapeRenderer.h"

See: Shape Renderer readme for usage and details

Importing Text Renderer

#include "pico-ssd1306/textRenderer/TextRenderer.h"

See: Text Renderer readme for usage and details

6. Examples

See examples. Many of them have their own readmes. Many things are also explained in code comments.

7. Documentation

Documentation of all functions is here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.