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.
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
avr0can completely be exchanged with any other hardware abstraction library. Note that all unused plattfomrs in./halfolder should be deleted to prevent compliling issues!
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). |
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/systickgit 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#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 ofSSD130X_USE_SOFT_TWIor uncommentingSSD130X_USE_SOFT_TWIinssd130x.his 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-Mode
tty_init();
printf("Test");Details on how-to-use/setup the
tty-mode can be found here.
// 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.
| Type | Link | Description |
|---|---|---|
| SSD1306 | OLED/PLED Segment/Common Driver with Controller |
R. GAECHTER
