|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
SSD1306 monochrome OLED display controller driver. More...
Classes | |
| struct | config |
| Configuration structure for SSD1306 panels. More... | |
Public Member Functions | |
| ssd1306 (idfxx::panel_io &panel_io, config config) | |
| Creates a new ssd1306 panel. | |
| void | set_contrast (uint8_t level) |
| Sets the display contrast (SSD1306 "Set Contrast Control", command 0x81). | |
| result< void > | try_set_contrast (uint8_t level) |
| Sets the display contrast (SSD1306 "Set Contrast Control", command 0x81). | |
| ~ssd1306 () | |
| ssd1306 (const ssd1306 &)=delete | |
| ssd1306 & | operator= (const ssd1306 &)=delete |
| ssd1306 (ssd1306 &&other) noexcept | |
| ssd1306 & | operator= (ssd1306 &&other) noexcept |
Public Member Functions inherited from idfxx::lcd::panel | |
| virtual | ~panel ()=default |
| panel (const panel &)=delete | |
| panel & | operator= (const panel &)=delete |
| esp_lcd_panel_handle_t | idf_handle () const |
| Returns the underlying ESP-IDF handle. | |
| size_t | width () const noexcept |
| Returns the panel's native width in pixels. | |
| size_t | height () const noexcept |
| Returns the panel's native height in pixels. | |
| void | draw_bitmap (int x_start, int y_start, int x_end, int y_end, const void *color_data) |
| Draws bitmap data to a region of the display. | |
| void | invert_color (bool invert) |
| Inverts the color of the display. | |
| void | swap_xy (bool swap) |
| Swaps the X and Y axes. | |
| void | mirror (bool mirror_x, bool mirror_y) |
| Mirrors the display. | |
| void | display_on (bool on) |
| Turns the display on or off. | |
| result< void > | try_draw_bitmap (int x_start, int y_start, int x_end, int y_end, const void *color_data) |
| Draws bitmap data to a region of the display. | |
| result< void > | try_invert_color (bool invert) |
| Inverts the color of the display. | |
| result< void > | try_swap_xy (bool swap) |
| Swaps the X and Y axes. | |
| result< void > | try_mirror (bool mirror_x, bool mirror_y) |
| Mirrors the display. | |
| result< void > | try_display_on (bool on) |
| Turns the display on or off. | |
Static Public Member Functions | |
| static panel_io::i2c_config | i2c_io_config (uint16_t device_address=0x3C, freq::hertz scl_speed=freq::hertz{400000}) noexcept |
| Returns a panel I/O configuration for communicating with an SSD1306 over I2C. | |
| static result< ssd1306 > | make (idfxx::panel_io &panel_io, config config) |
| Creates a new ssd1306 panel. | |
Additional Inherited Members | |
Protected Member Functions inherited from idfxx::lcd::panel | |
| panel ()=default | |
| panel (size_t width, size_t height) noexcept | |
| Constructs a panel reporting the given native dimensions. | |
| panel (panel &&) noexcept=default | |
| panel & | operator= (panel &&) noexcept=default |
| virtual result< void > | do_draw_bitmap (int x_start, int y_start, int x_end, int y_end, const void *color_data) |
| Hook for try_draw_bitmap. | |
| virtual result< void > | do_invert_color (bool invert) |
| Hook for try_invert_color. | |
| virtual result< void > | do_swap_xy (bool swap) |
| Hook for try_swap_xy. | |
| virtual result< void > | do_mirror (bool mirror_x, bool mirror_y) |
| Hook for try_mirror. | |
| virtual result< void > | do_display_on (bool on) |
| Hook for try_display_on. | |
SSD1306 monochrome OLED display controller driver.
Driver for SSD1306-based OLED displays (128x64 or 128x32, 1 bit per pixel). The display starts off; call display_on(true) after construction to make output visible.
Pixel data for draw_bitmap must be page-packed: each byte holds 8 vertically adjacent pixels (bit 0 topmost), and pages (rows of 8 pixels) are laid out top-to-bottom. Row coordinates passed to draw_bitmap must be page-aligned (multiples of 8). idfxx::lcd::mono_framebuffer produces this layout directly.
Definition at line 39 of file ssd1306.hpp.
|
explicit |
Creates a new ssd1306 panel.
Does not take ownership of panel_io. It is the caller's responsibility to ensure that this panel does not outlive the panel I/O interface.
| panel_io | The panel I/O interface. |
| config | panel configuration. |
| std::system_error | on error. |
| idfxx::lcd::ssd1306::~ssd1306 | ( | ) |
|
delete |
|
noexcept |
|
staticnoexcept |
Returns a panel I/O configuration for communicating with an SSD1306 over I2C.
Fills in the I2C framing the SSD1306 controller requires (a one-byte control phase with the D/C selection in bit 6, and 8-bit commands and parameters), so only the wiring-specific values are parameters.
| device_address | The panel's 7-bit I2C address. Most modules use 0x3C; some are strapped to 0x3D. |
| scl_speed | The I2C SCL frequency. The SSD1306 supports up to 400 kHz. |
|
static |
Creates a new ssd1306 panel.
Does not take ownership of panel_io. It is the caller's responsibility to ensure that this panel does not outlive the panel I/O interface.
| panel_io | The panel I/O interface. |
| config | panel configuration. |
| idfxx::errc::invalid_arg | if the configured height is not 64 or 32. |
|
inline |
Sets the display contrast (SSD1306 "Set Contrast Control", command 0x81).
The controller powers on with contrast 0x7F. Lower values dim the panel; dimming also slows OLED burn-in on mostly-static content.
| level | Contrast level, 0x00 (dimmest) to 0xFF (brightest). |
| std::system_error | on error. |
Definition at line 114 of file ssd1306.hpp.
References try_set_contrast(), and idfxx::unwrap().
| result< void > idfxx::lcd::ssd1306::try_set_contrast | ( | uint8_t | level | ) |
Sets the display contrast (SSD1306 "Set Contrast Control", command 0x81).
The controller powers on with contrast 0x7F. Lower values dim the panel; dimming also slows OLED burn-in on mostly-static content.
| level | Contrast level, 0x00 (dimmest) to 0xFF (brightest). |
| idfxx::errc::invalid_state | if the panel has been moved from. |
Referenced by set_contrast().