Display_Lib_RPI 2.3.0
A C++ Library to connect electronic displays to Linux single board computers.
Loading...
Searching...
No Matches
SSD1306_OLED_RDL.hpp
Go to the documentation of this file.
1
9#pragma once
10
11// Library includes
12
13#include <cstdio>
14#include <cstdint>
15#include <cstdbool>
16#include <lgpio.h>
18
19
24 public:
26 ~SSD1306_RDL(){};
27
28 virtual void drawPixel(int16_t x, int16_t y, uint8_t color) override;
29
33 void OLEDBufferScreen(int16_t x, int16_t y, uint8_t w, uint8_t h, std::span<uint8_t> data);
34
37
38 void OLEDbegin();
39 void OLEDinit(void);
40 void OLEDPowerDown(void);
41
42 void OLEDEnable(uint8_t on);
44 void OLEDInvert(bool on);
45
50 void OLEDStopScroll(void) ;
51
54 int OLEDCheckConnection(void);
55 int OLEDI2CErrorGet(void);
60
61 const uint8_t SSD1306_ADDR = 0x3C;
63 private:
64
66 // === SSD1306 Command Set ===
67 // Fundamental Commands
68 static constexpr uint8_t SSD1306_SET_CONTRAST_CONTROL = 0x81;
69 static constexpr uint8_t SSD1306_DISPLAY_ALL_ON_RESUME = 0xA4;
70 static constexpr uint8_t SSD1306_DISPLAY_ALL_ON = 0xA5;
71 static constexpr uint8_t SSD1306_NORMAL_DISPLAY = 0xA6;
72 static constexpr uint8_t SSD1306_INVERT_DISPLAY = 0xA7;
73 static constexpr uint8_t SSD1306_DISPLAY_OFF = 0xAE;
74 static constexpr uint8_t SSD1306_DISPLAY_ON = 0xAF;
75 static constexpr uint8_t SSD1306_NOP = 0xE3;
77 // Scrolling Commands
78 static constexpr uint8_t SSD1306_RIGHT_HORIZONTAL_SCROLL = 0x26;
79 static constexpr uint8_t SSD1306_LEFT_HORIZONTAL_SCROLL = 0x27;
82 static constexpr uint8_t SSD1306_DEACTIVATE_SCROLL = 0x2E;
83 static constexpr uint8_t SSD1306_ACTIVATE_SCROLL = 0x2F;
84 static constexpr uint8_t SSD1306_SET_VERTICAL_SCROLL_AREA = 0xA3;
87 // Addressing Setting Commands
88 static constexpr uint8_t SSD1306_SET_LOWER_COLUMN = 0x00;
89 static constexpr uint8_t SSD1306_SET_HIGHER_COLUMN = 0x10;
90 static constexpr uint8_t SSD1306_MEMORY_ADDR_MODE = 0x20;
91 static constexpr uint8_t SSD1306_SET_COLUMN_ADDR = 0x21;
92 static constexpr uint8_t SSD1306_SET_PAGE_ADDR = 0x22;
94 // Hardware Configuration Commands
95 static constexpr uint8_t SSD1306_SET_START_LINE = 0x40;
96 static constexpr uint8_t SSD1306_SET_SEGMENT_REMAP = 0xA0;
97 static constexpr uint8_t SSD1306_SET_MULTIPLEX_RATIO = 0xA8;
98 static constexpr uint8_t SSD1306_COM_SCAN_DIR_INC = 0xC0;
99 static constexpr uint8_t SSD1306_COM_SCAN_DIR_DEC = 0xC8;
100 static constexpr uint8_t SSD1306_SET_DISPLAY_OFFSET = 0xD3;
101 static constexpr uint8_t SSD1306_SET_COM_PINS = 0xDA;
102 static constexpr uint8_t SSD1306_CHARGE_PUMP = 0x8D;
104 // Timing & Driving Scheme Setting Commands
106 static constexpr uint8_t SSD1306_SET_PRECHARGE_PERIOD = 0xD9;
107 static constexpr uint8_t SSD1306_SET_VCOM_DESELECT = 0xDB;
109 // I2C related
110 static constexpr uint8_t SSD1306_COMMAND = 0x00;
111 static constexpr uint8_t SSD1306_DATA = 0xC0;
112 static constexpr uint8_t SSD1306_DATA_CONTINUE = 0x40;
113 // === SSD1306 Command Set END ===
114
127 std::span<uint8_t> _OLEDbuffer;
130};
Graphics based functions for bicolor display.
static constexpr int defaultFormat()
Called from vector & string template , Get the default format for a given type.
Definition print_data_RDL.hpp:206
class to control OLED and define buffer
Definition SSD1306_OLED_RDL.hpp:23
int OLEDCheckConnection(void)
checks if OLED on I2C bus
Definition SSD1306_OLED_RDL.cpp:522
static constexpr uint8_t SSD1306_INVERT_DISPLAY
Definition SSD1306_OLED_RDL.hpp:72
static constexpr uint8_t SSD1306_SET_DISPLAY_CLOCK_DIV_RATIO
Definition SSD1306_OLED_RDL.hpp:105
static constexpr uint8_t SSD1306_DISPLAY_ALL_ON
Definition SSD1306_OLED_RDL.hpp:70
static constexpr uint8_t SSD1306_DATA
Definition SSD1306_OLED_RDL.hpp:111
static constexpr uint8_t SSD1306_SET_START_LINE
Definition SSD1306_OLED_RDL.hpp:95
static constexpr uint8_t SSD1306_DISPLAY_ALL_ON_RESUME
Definition SSD1306_OLED_RDL.hpp:69
static constexpr uint8_t SSD1306_NOP
Definition SSD1306_OLED_RDL.hpp:75
rdlib::Return_Codes_e OLEDupdate(void)
updates the buffer i.e. writes it to the screen
Definition SSD1306_OLED_RDL.cpp:276
uint8_t OLEDI2CErrorRetryNumGet(void)
Gets the I2C error retry attempts, used in the event of an I2C write error.
Definition SSD1306_OLED_RDL.cpp:505
static constexpr uint8_t SSD1306_SET_DISPLAY_OFFSET
Definition SSD1306_OLED_RDL.hpp:100
static constexpr uint8_t SSD1306_SET_COLUMN_ADDR
Definition SSD1306_OLED_RDL.hpp:91
uint8_t _OLED_PAGE_NUM
Definition SSD1306_OLED_RDL.hpp:125
static constexpr uint8_t SSD1306_COM_SCAN_DIR_DEC
Definition SSD1306_OLED_RDL.hpp:99
static constexpr uint8_t SSD1306_MEMORY_ADDR_MODE
Definition SSD1306_OLED_RDL.hpp:90
static constexpr uint8_t SSD1306_SET_SEGMENT_REMAP
Definition SSD1306_OLED_RDL.hpp:96
static constexpr uint8_t SSD1306_SET_HIGHER_COLUMN
Definition SSD1306_OLED_RDL.hpp:89
rdlib::Return_Codes_e OLEDSetBufferPtr(uint8_t width, uint8_t height, std::span< uint8_t > buffer)
sets the buffer pointer to the users screen data buffer
Definition SSD1306_OLED_RDL.cpp:41
uint8_t _OLED_HEIGHT
Definition SSD1306_OLED_RDL.hpp:124
void OLEDFillScreen(uint8_t pixel, uint8_t mircodelay)
Fill the screen NOT the buffer with a datapattern.
Definition SSD1306_OLED_RDL.cpp:205
static constexpr uint8_t SSD1306_CHARGE_PUMP
Definition SSD1306_OLED_RDL.hpp:102
virtual void drawPixel(int16_t x, int16_t y, uint8_t color) override
Draws a Pixel to the screen overrides the graphics lib.
Definition SSD1306_OLED_RDL.cpp:358
int _OLEDI2CHandle
Definition SSD1306_OLED_RDL.hpp:118
static constexpr uint8_t SSD1306_SET_LOWER_COLUMN
Definition SSD1306_OLED_RDL.hpp:88
std::span< uint8_t > _OLEDbuffer
Definition SSD1306_OLED_RDL.hpp:127
rdlib::Return_Codes_e OLED_I2C_ON(int I2C_device, int I2C_addr, int I2C_flags)
Start I2C operations.
Definition SSD1306_OLED_RDL.cpp:66
static constexpr uint8_t SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL
Definition SSD1306_OLED_RDL.hpp:80
void OLEDStartScrollLeft(uint8_t start, uint8_t stop)
Scroll OLED data to the left.
Definition SSD1306_OLED_RDL.cpp:414
rdlib::Return_Codes_e OLEDclearBuffer(void)
clears the buffer memory i.e. does NOT write to the screen
Definition SSD1306_OLED_RDL.cpp:297
static constexpr uint8_t SSD1306_COMMAND
Definition SSD1306_OLED_RDL.hpp:110
int _OLEDI2CFlags
Definition SSD1306_OLED_RDL.hpp:117
void OLEDEnable(uint8_t on)
Turns On Display.
Definition SSD1306_OLED_RDL.cpp:176
static constexpr uint8_t SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL
Definition SSD1306_OLED_RDL.hpp:81
void OLEDPowerDown(void)
Disables OLED Call when powering down.
Definition SSD1306_OLED_RDL.cpp:109
void OLEDStartScrollDiagLeft(uint8_t start, uint8_t stop)
Scroll OLED data diagonally to the left.
Definition SSD1306_OLED_RDL.cpp:452
static constexpr uint8_t SSD1306_COM_SCAN_DIR_INC
Definition SSD1306_OLED_RDL.hpp:98
const uint8_t SSD1306_ADDR
Definition SSD1306_OLED_RDL.hpp:61
int _I2C_ErrorFlag
Definition SSD1306_OLED_RDL.hpp:121
static constexpr uint8_t SSD1306_SET_MULTIPLEX_RATIO
Definition SSD1306_OLED_RDL.hpp:97
void OLEDInvert(bool on)
invert the display
Definition SSD1306_OLED_RDL.cpp:195
int _OLEDI2CAddress
Definition SSD1306_OLED_RDL.hpp:115
uint8_t _OLED_WIDTH
Definition SSD1306_OLED_RDL.hpp:123
static constexpr uint8_t SSD1306_ACTIVATE_SCROLL
Definition SSD1306_OLED_RDL.hpp:83
static constexpr uint8_t SSD1306_SET_COM_PINS
Definition SSD1306_OLED_RDL.hpp:101
void OLEDI2CErrorTimeoutSet(uint16_t)
Sets the I2C timeout, in the event of an I2C write error.
Definition SSD1306_OLED_RDL.cpp:488
void OLEDStartScrollDiagRight(uint8_t start, uint8_t stop)
Scroll OLED data diagonally to the right.
Definition SSD1306_OLED_RDL.cpp:432
static constexpr uint8_t SSD1306_DISPLAY_OFF
Definition SSD1306_OLED_RDL.hpp:73
static constexpr uint8_t SSD1306_DEACTIVATE_SCROLL
Definition SSD1306_OLED_RDL.hpp:82
uint16_t _I2C_ErrorDelay
Definition SSD1306_OLED_RDL.hpp:119
int _OLEDI2CDevice
Definition SSD1306_OLED_RDL.hpp:116
static constexpr uint8_t SSD1306_NORMAL_DISPLAY
Definition SSD1306_OLED_RDL.hpp:71
static constexpr uint8_t SSD1306_DATA_CONTINUE
Definition SSD1306_OLED_RDL.hpp:112
static constexpr uint8_t SSD1306_RIGHT_HORIZONTAL_SCROLL
Definition SSD1306_OLED_RDL.hpp:78
static constexpr uint8_t SSD1306_SET_VERTICAL_SCROLL_AREA
Definition SSD1306_OLED_RDL.hpp:84
uint16_t OLEDI2CErrorTimeoutGet(void)
Gets the I2C timeout, used in the event of an I2C write error.
Definition SSD1306_OLED_RDL.cpp:498
rdlib::Return_Codes_e OLED_I2C_OFF(void)
End I2C operations. This closes the I2C device.
Definition SSD1306_OLED_RDL.cpp:94
void OLEDStartScrollRight(uint8_t start, uint8_t stop)
Scroll OLED data to the right.
Definition SSD1306_OLED_RDL.cpp:396
static constexpr uint8_t SSD1306_DISPLAY_ON
Definition SSD1306_OLED_RDL.hpp:74
void OLEDinit(void)
Called from OLEDbegin carries out Power on sequence and register init.
Definition SSD1306_OLED_RDL.cpp:118
void OLEDFillPage(uint8_t page_num, uint8_t pixels, uint8_t delay)
Fill the chosen page(1-8) with a datapattern.
Definition SSD1306_OLED_RDL.cpp:226
static constexpr uint8_t SSD1306_SET_PAGE_ADDR
Definition SSD1306_OLED_RDL.hpp:92
void OLEDContrast(uint8_t OLEDcontrast)
Adjusts contrast.
Definition SSD1306_OLED_RDL.cpp:185
void OLEDI2CErrorRetryNumSet(uint8_t)
Sets the I2C error retry attempts used in the event of an I2C write error.
Definition SSD1306_OLED_RDL.cpp:512
int OLEDI2CErrorGet(void)
get I2C error Flag
Definition SSD1306_OLED_RDL.cpp:481
static constexpr uint8_t SSD1306_SET_PRECHARGE_PERIOD
Definition SSD1306_OLED_RDL.hpp:106
void OLEDStopScroll(void)
Stop scroll mode.
Definition SSD1306_OLED_RDL.cpp:470
static constexpr uint8_t SSD1306_LEFT_HORIZONTAL_SCROLL
Definition SSD1306_OLED_RDL.hpp:79
static constexpr uint8_t SSD1306_SET_VCOM_DESELECT
Definition SSD1306_OLED_RDL.hpp:107
static constexpr uint8_t SSD1306_SET_CONTRAST_CONTROL
Definition SSD1306_OLED_RDL.hpp:68
void OLEDbegin()
begin Method initialise OLED
Definition SSD1306_OLED_RDL.cpp:26
uint8_t _I2C_ErrorRetryNum
Definition SSD1306_OLED_RDL.hpp:120
void I2CWriteByte(uint8_t value=0x00, uint8_t DataOrCmd=SSD1306_COMMAND)
Writes a byte to I2C address,command or data, used internally.
Definition SSD1306_OLED_RDL.cpp:246
void OLEDBufferScreen(int16_t x, int16_t y, uint8_t w, uint8_t h, std::span< uint8_t > data)
Draw the buffer directly to the screen.
Definition SSD1306_OLED_RDL.cpp:318
Graphics class to hold graphic related functions for 1-bit displays.
Definition bicolor_graphics_RDL.hpp:21
int16_t width(void) const
Gets the width of the display (per current _rotation)
Definition bicolor_graphics_RDL.cpp:560
int16_t height(void) const
Gets the height of the display (per current _rotation)
Definition bicolor_graphics_RDL.cpp:566
Return_Codes_e
Definition common_data_RDL.hpp:22