C++ DevKit
C++ set of OOP library
Loading...
Searching...
No Matches
ssd1306.h
Go to the documentation of this file.
1
11#pragma once
12
13#include "commands_SSD1306.h"
14#include "pico/stdlib.h"
15#include "hw/i2c/rtos_hw_i2c.h"
18
19// Time_frame_interval
21#define _2_FRAMES 0b111
23#define _3_FRAMES 0b100
25#define _4_FRAMES 0b101
27#define _5_FRAMES 0b000
29#define _25_FRAMES 0b110
31#define _64_FRAMES 0b001
33#define _128_FRAMES 0b010
35#define _256_FRAMES 0b011
36
37// addressing mode
39#define HORIZONTAL_ADDRESSING_MODE 0
41#define VERTICAL_ADDRESSING_MODE 1
43#define PAGE_ADDRESSING_MODE 2
44
50
51{
53 uint8_t i2c_address = 0x3C;
55 uint8_t mux_ratio_value = 64;
57 uint8_t vertical_offset = 0;
59 uint8_t GDDRAM_start_line = 0;
65 bool sequential_COM = false;
69 uint8_t contrast = 127;
71 uint8_t frequency_divider = 1;
73 uint8_t frequency_factor = 0;
74};
75
96
118
124{
125protected:
130
132 void init();
135 void init_MUX_ratio(uint8_t value);
138 void init_display_vertical_shift(uint8_t value);
141 void init_RAM_start_line(uint8_t value);
144 void init_SEG_scan_inverse_direction(bool inverse);
147 void init_COM_scan_inverse_direction(bool inverse);
151 void init_COM_cfg(bool sequentialCOM, bool enableCOMLRremap);
155 void init_clock_frequency(uint8_t divide_ratio, uint8_t frequency_factor);
158 void init_charge_pump_enabled(bool enabled);
161 void send_cmd(uint8_t cmd);
165 void send_cmd_list(uint8_t *cmd_list, int num);
166
167public:
169
177
178 virtual ~SSD1306();
188 static struct_RenderArea compute_render_area(uint8_t start_col, uint8_t end_col, uint8_t start_line, uint8_t end_line);
189
197 void show(Canvas *canvas, const uint8_t anchor_x, const uint8_t anchor_y);
198
206 virtual void show_render_area(uint8_t *data_buffer, struct_RenderArea screen_area, uint8_t addressing_mode = HORIZONTAL_ADDRESSING_MODE);
214 virtual void fill_pattern_and_show_GDDRAM(uint8_t pattern, struct_RenderArea area);
225 void set_contrast(uint8_t value);
234 void set_all_pixel_ON();
240 void set_inverse_color(bool inverse);
245 void set_display_OFF();
250 void set_display_ON();
257 void horizontal_scroll(bool on, struct_ConfigScrollSSD1306 scroll_data);
264 void vertical_scroll(bool on, struct_ConfigScrollSSD1306 scroll_data);
265};
266
269class rtos_SSD1306 : public SSD1306, public rtos_GraphicDisplayDevice
270{
271private:
272public:
278
283
286
289 void show_widget(rtos_Widget* widget);
290
291 void show_render_area(uint8_t *data_buffer, struct_RenderArea display_area, uint8_t addressing_mode = HORIZONTAL_ADDRESSING_MODE);
292
298 void fill_GDDRAM_with_pattern(uint8_t pattern, struct_RenderArea area, uint8_t addressing_mode = HORIZONTAL_ADDRESSING_MODE);
299};
CanvasFormat
the format of the canvas
Definition canvas.h:61
The canvas is a virtual memory in which the widget draws.
Definition canvas.h:129
GraphicDisplayDevice(size_t screen_width, size_t screen_height)
Construct a new Display Device object.
Definition display_device.cpp:14
this is a C++ wrapper for the original pico SDK i2c master API
Definition hw_i2c.h:137
static struct_RenderArea compute_render_area(uint8_t start_col, uint8_t end_col, uint8_t start_line, uint8_t end_line)
A static member function that converts the area we want to display into device specific parameters.
Definition ssd1306.cpp:29
void show(Canvas *canvas, const uint8_t anchor_x, const uint8_t anchor_y)
Definition ssd1306.cpp:157
void init_SEG_scan_inverse_direction(bool inverse)
refer to SSD1306 data sheet for more details
Definition ssd1306.cpp:179
void vertical_scroll(bool on, struct_ConfigScrollSSD1306 scroll_data)
Definition ssd1306.cpp:257
void horizontal_scroll(bool on, struct_ConfigScrollSSD1306 scroll_data)
Definition ssd1306.cpp:237
void init()
the master init function that calls all others
Definition ssd1306.cpp:83
void init_COM_scan_inverse_direction(bool inverse)
refer to SSD1306 data sheet for more details
Definition ssd1306.cpp:187
SSD1306(HW_I2C_Master *master, struct_ConfigSSD1306 device_config)
Definition ssd1306.cpp:17
void clear_device_screen_buffer()
write 0x00 directly into the device framebuffer. Uses fill_pattern_and_show_GDDRAM command.
Definition ssd1306.cpp:77
void set_display_OFF()
Set the display OFF object.
Definition ssd1306.cpp:60
virtual void fill_pattern_and_show_GDDRAM(uint8_t pattern, struct_RenderArea area)
fill a pattern in the device framebuffer. this make it visible as soon as the device transfer the fra...
Definition ssd1306.cpp:70
void init_RAM_start_line(uint8_t value)
refer to SSD1306 data sheet for more details
Definition ssd1306.cpp:172
void init_clock_frequency(uint8_t divide_ratio, uint8_t frequency_factor)
refer to SSD1306 data sheet for more details
Definition ssd1306.cpp:213
void set_inverse_color(bool inverse)
Set the inverse color object.
Definition ssd1306.cpp:52
void init_charge_pump_enabled(bool enabled)
refer to SSD1306 data sheet for more details
Definition ssd1306.cpp:222
void set_display_from_RAM()
Set the display from RAM object.
Definition ssd1306.cpp:42
struct_ConfigSSD1306 device_config
the SSD1306 device configuration
Definition ssd1306.h:129
void check_display_device_compatibility(struct_ConfigGraphicWidget framebuffer_cfg, CanvasFormat canvas_format)
A pure virtual member function. Each device must implement this method and check the compatibility of...
Definition ssd1306.cpp:144
void send_cmd_list(uint8_t *cmd_list, int num)
refer to SSD1306 data sheet for more details
Definition ssd1306.cpp:11
HW_I2C_Master * i2c_master
the I2C master that control the SSD1306 display
Definition ssd1306.h:127
void init_COM_cfg(bool sequentialCOM, bool enableCOMLRremap)
refer to SSD1306 data sheet for more details
Definition ssd1306.cpp:195
virtual void show_render_area(uint8_t *data_buffer, struct_RenderArea screen_area, uint8_t addressing_mode=0)
when we need to show a render area with a given framebuffer
Definition ssd1306.cpp:115
void send_cmd(uint8_t cmd)
refer to SSD1306 data sheet for more details
Definition ssd1306.cpp:4
void set_display_ON()
Set the display ON object.
Definition ssd1306.cpp:65
void set_contrast(uint8_t value)
Set the contrast object. refer to datasheet of SSD1306 device.
Definition ssd1306.cpp:206
void init_MUX_ratio(uint8_t value)
refer to SSD1306 data sheet for more details
Definition ssd1306.cpp:108
void set_all_pixel_ON()
Set the all pixel ON.
Definition ssd1306.cpp:47
void init_display_vertical_shift(uint8_t value)
refer to SSD1306 data sheet for more details
Definition ssd1306.cpp:165
This is a C++ wrapper for the original pico SDK i2c master API, adapted to FreeRTOS environment.
Definition rtos_hw_i2c.h:29
rtos_SSD1306(rtos_HW_I2C_Master *master, struct_ConfigSSD1306 device_config)
constructor for FreeRTOS compliant SSD1306 device driver.
Definition ssd1306.cpp:276
void check_rtos_display_device_compatibility(struct_ConfigGraphicWidget framebuffer_cfg, CanvasFormat canvas_format)
Check the compatibility of the framebuffer configuration with the display device physical limitations...
Definition ssd1306.cpp:285
void fill_GDDRAM_with_pattern(uint8_t pattern, struct_RenderArea area, uint8_t addressing_mode=0)
fill a pattern in the device framebuffer (GDDRAM). This is shown on display as soon as the GDDRAM buf...
Definition ssd1306.cpp:329
void clear_device_screen_buffer()
Clear the device screen buffer.
Definition ssd1306.cpp:290
void show_render_area(uint8_t *data_buffer, struct_RenderArea display_area, uint8_t addressing_mode=0)
when we need to show a render area with a given framebuffer
Definition ssd1306.cpp:301
void show_widget(rtos_Widget *widget)
Show the widget on the display device.
Definition ssd1306.cpp:296
RTOS wrapper for Widget class.
Definition rtos_widget.h:31
This file contains all the defineition of SSD1306 commands.
#define SSD1306_HEIGHT
the height in pixel of SSD1306, can be either 32 or 64
Definition commands_SSD1306.h:19
#define SSD1306_NUM_PAGES
Related to FramebufferFormat, SSD1306_WIDTH divided by the font height.
Definition commands_SSD1306.h:25
#define SSD1306_BUF_LEN
size of the pixel_buffer of the associated framebuffer
Definition commands_SSD1306.h:27
#define SSD1306_WIDTH
the width in pixel of SSD1306
Definition commands_SSD1306.h:21
#define HORIZONTAL_ADDRESSING_MODE
refer to SSD1306 data sheet
Definition ssd1306.h:39
#define _2_FRAMES
refer to SSD1306 data sheet
Definition ssd1306.h:21
data structure used to configure graphic framebuffer
Definition canvas.h:81
configuration data for SSD1306 OLED display. refer to datasheet for more details.
Definition ssd1306.h:51
bool sequential_COM
refer to SSD1306 datasheet for more details.
Definition ssd1306.h:65
uint8_t frequency_divider
refer to SSD1306 datasheet for more details.
Definition ssd1306.h:71
uint8_t vertical_offset
refer to SSD1306 datasheet for more details.
Definition ssd1306.h:57
uint8_t contrast
refer to SSD1306 datasheet for more details.
Definition ssd1306.h:69
bool scan_COM_inverse_direction
refer to SSD1306 datasheet for more details.
Definition ssd1306.h:63
bool enable_COM_L_R_remap
refer to SSD1306 datasheet for more details.
Definition ssd1306.h:67
uint8_t frequency_factor
refer to SSD1306 datasheet for more details.
Definition ssd1306.h:73
uint8_t GDDRAM_start_line
refer to SSD1306 datasheet for more details.
Definition ssd1306.h:59
bool scan_SEG_inverse_direction
refer to SSD1306 datasheet for more details.
Definition ssd1306.h:61
uint8_t mux_ratio_value
multiplex ratio
Definition ssd1306.h:55
uint8_t i2c_address
the i2c address, usually 0x3C, may be 0x3D
Definition ssd1306.h:53
configuration data for SSD1306 OLED display scrolling feature.
Definition ssd1306.h:82
bool scroll_H_to_right
if true SSD1306_SET_R_HORIZ_SCROLL else SSD1306_SET_L_HORIZ_SCROLL
Definition ssd1306.h:84
uint8_t scroll_H_end_page
0 <= value <= 7
Definition ssd1306.h:92
bool scroll_V_and_H_to_right
if true SSD1306_SET_VERTICAL_R_HORIZ_SCROLL else SSD1306_SET_VERTICAL_L_HORIZ_SCROLL
Definition ssd1306.h:86
uint8_t vertical_scrolling_offset
0 <= value <= 63
Definition ssd1306.h:94
uint8_t time_frame_interval
0 <= value <= 7
Definition ssd1306.h:90
uint8_t scroll_H_start_page
0 <= value <= 7
Definition ssd1306.h:88
data used to compute the render area position in the display framebuffer reference,...
Definition ssd1306.h:102
size_t height
the eight of the copy area
Definition ssd1306.h:114
size_t buflen
the size of the graphic buffer
Definition ssd1306.h:116
uint8_t end_col
the pixel x where to end copy of the graphic framebuffer
Definition ssd1306.h:106
uint8_t start_col
the pixel x where to start copy of the graphic framebuffer
Definition ssd1306.h:104
uint8_t start_page
the page number where to start copy of the graphic framebuffer
Definition ssd1306.h:108
size_t width
the width of the copy area
Definition ssd1306.h:112
uint8_t end_page
the page number where to end copy of the graphic framebuffer
Definition ssd1306.h:110