Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/irdcat/avr-ssd1306
SSD1306 OLED display driver library for AVR microcontrollers written in C++14, and experiment of using templates on MCU.
https://github.com/irdcat/avr-ssd1306
avr cpp14 oled-display-ssd1306
Last synced: about 1 month ago
JSON representation
SSD1306 OLED display driver library for AVR microcontrollers written in C++14, and experiment of using templates on MCU.
- Host: GitHub
- URL: https://github.com/irdcat/avr-ssd1306
- Owner: irdcat
- License: mit
- Created: 2018-08-03T18:47:25.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-08T20:28:00.000Z (almost 6 years ago)
- Last Synced: 2023-08-18T18:09:23.349Z (over 1 year ago)
- Topics: avr, cpp14, oled-display-ssd1306
- Language: C++
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SSD1306 AVR Library
SSD1306 driver library for AVR microcontrollers. SSD1306 is a single-chip CMOS OLED/PLED driver with controller for organic / polymer light emitting
diode dot-matrix graphic display system. It consists of 128 segments and 64commons. This IC is designed for Common Cathode type OLED panel.This project is more of an experiment of using c++ templates on a small microcontroller, such as avr, than a library, that focuses on optimization. The only goal was to provide easy to use interface.
### Supported communication interfaces
- [x] 4-wire SPI
- [ ] 3-wire SPI
- [ ] I2C### Usage
Library usage example:
```C++
#include
#include "ports.hpp" // Include custom IO implementationint main()
{
/* Set correct data direction values of the used ports */
auto display = ssd1306::initDisplay128x64(port_c.p0, port_c.p1, port_c.p2, port_c.p3, port_c.p4);while(1)
{
display.clear();
/* Draw something */
display.display();
}return 0;
}
```Library needs custom implementation of I/O pin manipulation. Pin must be a class, and overload assignment operator.
Library allows template class pin implementations. Pins are passed to display instance by reference.
Example pin implementation:```C++
#includeusing reg8 = volatile uint8_t
using u8 = uint8_t;struct Pin
{
reg8 & ddrReg;
reg8 & pinReg;
reg8 & portReg;
u8 pos;Pin(reg8 & _ddr, reg8 & _pin, reg8 & _port, u8 _pos)
: ddrReg(_ddr)
, pinReg(_pin)
, portReg(_port)
, pos(_pos)
{
}void setup(bool output)
{
ddrReg = (ddrReg & ~(1 << pos)) | (output << pos);
}template
Pin & operator=(T value)
{
portReg = (portReg & ~(1 << pos)) | (!!value << pos);
}operator bool() const
{
return pinReg & (1 << pos);
}
};
```