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/hw_i2c.h"
17
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{
125private:
127 HW_I2C_Master *i2c_master;
129 struct_ConfigSSD1306 device_config;
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);
169 void send_buf(uint8_t buf[], size_t buflen);
170
171public:
172
174
181 SSD1306(HW_I2C_Master *master, struct_ConfigSSD1306 device_config);
191 static struct_RenderArea compute_render_area(uint8_t start_col, uint8_t end_col, uint8_t start_line, uint8_t end_line);
192
200 void show(Canvas *canvas, const uint8_t anchor_x, const uint8_t anchor_y);
201
209 void show_render_area(uint8_t *data_buffer, struct_RenderArea screen_area, uint8_t addressing_mode = HORIZONTAL_ADDRESSING_MODE);
217 void fill_pattern_and_show_GDDRAM(uint8_t pattern, struct_RenderArea area);
228 void set_contrast(uint8_t value);
237 void set_all_pixel_ON();
243 void set_inverse_color(bool inverse);
248 void set_display_OFF();
253 void set_display_ON();
260 void horizontal_scroll(bool on, struct_ConfigScrollSSD1306 scroll_data);
267 void vertical_scroll(bool on, struct_ConfigScrollSSD1306 scroll_data);
268};
The canvas is a virtual memory in which the widget draws.
Definition canvas.h:121
GraphicDisplayDevice(size_t screen_width, size_t screen_height)
Construct a new Display Device object.
Definition display_device.cpp:4
this is a C++ wrapper for the original pico SDK i2c master API
Definition hw_i2c.h:129
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:30
void show(Canvas *canvas, const uint8_t anchor_x, const uint8_t anchor_y)
Definition ssd1306.cpp:154
void vertical_scroll(bool on, struct_ConfigScrollSSD1306 scroll_data)
Definition ssd1306.cpp:254
void horizontal_scroll(bool on, struct_ConfigScrollSSD1306 scroll_data)
Definition ssd1306.cpp:234
SSD1306(HW_I2C_Master *master, struct_ConfigSSD1306 device_config)
Definition ssd1306.cpp:22
void clear_device_screen_buffer()
write 0x00 directly into the device framebuffer. Uses fill_pattern_and_show_GDDRAM command.
Definition ssd1306.cpp:78
void set_display_OFF()
Set the display OFF object.
Definition ssd1306.cpp:61
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:71
void set_inverse_color(bool inverse)
Set the inverse color object.
Definition ssd1306.cpp:53
void set_display_from_RAM()
Set the display from RAM object.
Definition ssd1306.cpp:43
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:116
void set_display_ON()
Set the display ON object.
Definition ssd1306.cpp:66
void set_contrast(uint8_t value)
Set the contrast object. refer to datasheet of SSD1306 device.
Definition ssd1306.cpp:203
void check_display_device_compatibility(struct_ConfigGraphicWidget framebuffer_cfg)
A pure virtual member function. Each device must implement this method and check the compatibility of...
Definition ssd1306.cpp:143
void set_all_pixel_ON()
Set the all pixel ON.
Definition ssd1306.cpp:48
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 assocoated 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:73
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