Skip to content

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version: 1.0 Release Build License GPLv3

SSD130X Display Driver

Ask DeepWiki

This hardware abstracted driver can be used to interact with an SSD130X over (software-)TWI/I2C. The hardware layer is fully abstracted an can be switched between different plattforms. The TWI/I2C library has to impelement the twi.h- or the twi_soft.h-header used in this repository.

File Structure

File Structure

drivers/
└── display/
    ├── font/
    |   ├── font.h
    |   ├── font.c
    |   └── fonts/
    |       └── font_5x7_ascii.c
    └── ssd130x/
        ├── ssd130x.c
        ├── ssd130x.h
        ├── frame/
        |   ├── frame.c
        |   └── frame.h
        └── tty/
            ├── tty.c
            └── tty.h

hal/
├── common/
|   ├── defines/
|   |   └── TWI_defines.h
|   └── enums/
|       └── TWI_enums.h
└── avr0/
    ├── twi/
    |   ├── twi.c
    |   └── twi.h
    └── twi_soft/
        ├── twi_soft.c
        └── twi_soft.h

utils/
├── macros/
|   └── stringify.h
└── systick/
    ├── systick.c
    └── systick.h

The plattform avr0 can completely be exchanged with any other hardware abstraction library. Note that all unused plattfomrs in ./hal folder should be deleted to prevent compliling issues!

Downloads

The library can be downloaded (zip or tar), cloned or used as submodule in a project.

Type File Description
Library zip / tar SSD130X display library including all required libraries (including hal-avr(0)-twi and hal-avr(0)-twi_soft).

Using with git clone

mkdir -p ./drivers/display
git clone https://github.com/0x007E/drivers-display-font.git    ./drivers/display
mv ./drivers/display/drivers-display-font                       ./drivers/display/font

mkdir -p ./drivers/display/
git clone https://github.com/0x007E/drivers-display-ssd130x.git ./drivers/display
mv ./drivers/display/drivers-display-ssd130x                    ./drivers/display/ssd130x

mkdir -p ./hal/
git clone https://github.com/0x007E/hal-common.git              ./hal
mv ./hal/hal-common                                             ./hal/common

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Hardware abstraction layer of TWI (Must fit the used plattform)
# HARDWARE-TWI
mkdir -p ./hal/avr0/
git clone https://github.com/0x007E/hal-avr0-twi.git            ./hal/avr0
mv ./hal/avr0/hal-avr0-twi                                      ./hal/avr0/twi

# SOFTWARE-TWI
mkdir -p ./hal/avr0/
git clone https://github.com/0x007E/hal-avr0-twi_soft.git       ./hal/avr0
mv ./hal/avr0/hal-avr0-twi                                      ./hal/avr0/twi_soft
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

mkdir -p ./utils/
git clone https://github.com/0x007E/utils-macros.git            ./utils
mv ./utils/utils-macros                                         ./utils/macros

git clone https://github.com/0x007E/utils-systick.git           ./utils
mv ./utils/utils-systick                                        ./utils/systick

Using as git submodule

git submodule add https://github.com/0x007E/drivers-display-font.git    ./drivers/display/font
git submodule add https://github.com/0x007E/drivers-display-ssd130x.git ./drivers/display/ssd130x

git submodule add https://github.com/0x007E/hal-common.git              ./hal/common
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Hardware abstraction layer of TWI (Must fit the used plattform)
# HARDWARE-TWI
git submodule add https://github.com/0x007E/hal-avr0-twi.git            ./hal/avr0/twi

# SOFTWARE-TWI
git submodule add https://github.com/0x007E/hal-avr0-twi_soft.git       ./hal/avr0/twi_soft
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

git submodule add https://github.com/0x007E/utils-macros.git            ./utils/macros
git submodule add https://github.com/0x007E/utils-systick.git           ./utils/systick

Programming

#include "../lib/drivers/display/ssd130x/ssd130x.h"

// TTY-Mode
#include "../lib/drivers/display/ssd130x/tty/tty.h"

// FRAME-Mode
#include "../lib/drivers/display/ssd130x/frame/frame.h"

#include "../lib/utils/systick/systick.h"

// Called every microsecond!
ISR(...)
{
	systick_tick();
}

void systick_timer_wait_ms(unsigned int ms)
{
	systick_timer_wait((ms * 1000));
}

void systick_timer_wait_us(unsigned int us)
{
	systick_timer_wait(us);
}

It is possible to work with the basic ssd130x (low-level-driver) functions (for details see ssd130x.h).

int main(void)
{
	systick_init();

    #ifdef SSD130X_USE_SOFT_TWI
        twi_soft_init();
    #else
        twi_init();
    #endif

    // It is possible to work with the basic ssd130x (low-level-driver) functions (for details see ssd130x.h)
    ssd130x_init();
	ssd230x_clear();
}

To use software-TWI, either a global definition of SSD130X_USE_SOFT_TWI or uncommenting SSD130X_USE_SOFT_TWI in ssd130x.h is required!

To handle text and/or graphics a better approach would be tu use the implemented frame/tty (frontend) functions. A how-to-use guide can be found on here.

TTY - Console Mode

    // TTY-Mode
    tty_init();
    printf("Test");

Details on how-to-use/setup the tty-mode can be found here.

FRAME - Drawing Mode

    // FRAME-Mode
    GFX_Position position = { 102, 2 };

    frame_init();
    frame_draw_text("Test", position);

Details on how-to-use/setup the frame-mode can be found here.

Additional Information

Type Link Description
SSD1306 pdf OLED/PLED Segment/Common Driver with Controller

R. GAECHTER