|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
Abstract base class for ePaper display panels. More...
Public Member Functions | |
| virtual | ~panel ()=default |
| panel (const panel &)=delete | |
| panel & | operator= (const panel &)=delete |
| size_t | width () const noexcept |
| Returns the panel width in pixels. | |
| size_t | height () const noexcept |
| Returns the panel height in pixels. | |
| enum color_mode | color_mode () const noexcept |
| Returns the panel's current pixel format. | |
| bool | asleep () const noexcept |
| Returns whether the panel is in deep sleep. | |
| void | write (const mono_framebuffer &fb, size_t x=0, size_t y=0) |
| Uploads a monochrome framebuffer to the controller's RAM. | |
| void | write (const gray4_framebuffer &fb, size_t x=0, size_t y=0) |
| Uploads a grayscale framebuffer to the controller's RAM. | |
| void | write_rows (const mono_framebuffer &fb, size_t row_start, size_t row_end, size_t x=0, size_t y=0) |
| Uploads a horizontal band of a monochrome framebuffer. | |
| void | write_rows (const gray4_framebuffer &fb, size_t row_start, size_t row_end, size_t x=0, size_t y=0) |
| Uploads a horizontal band of a grayscale framebuffer. | |
| void | clear () |
| Clears the controller's RAM to white, without a framebuffer. | |
| result< void > | try_write (const mono_framebuffer &fb, size_t x=0, size_t y=0) |
| Uploads a monochrome framebuffer to the controller's RAM. | |
| result< void > | try_write (const gray4_framebuffer &fb, size_t x=0, size_t y=0) |
| Uploads a grayscale framebuffer to the controller's RAM. | |
| result< void > | try_write_rows (const mono_framebuffer &fb, size_t row_start, size_t row_end, size_t x=0, size_t y=0) |
| Uploads a horizontal band of a monochrome framebuffer. | |
| result< void > | try_write_rows (const gray4_framebuffer &fb, size_t row_start, size_t row_end, size_t x=0, size_t y=0) |
| Uploads a horizontal band of a grayscale framebuffer. | |
| result< void > | try_clear () |
| Clears the controller's RAM to white, without a framebuffer. | |
| void | refresh (refresh_mode mode=refresh_mode::full) |
| Refreshes the panel from the controller's RAM. | |
| void | wait () |
| Waits for the controller's BUSY line to release. | |
| template<typename Rep , typename Period > | |
| void | wait_for (const std::chrono::duration< Rep, Period > &timeout) |
| Waits for the controller's BUSY line to release, with a timeout. | |
| result< void > | try_refresh (refresh_mode mode=refresh_mode::full) |
| Refreshes the panel from the controller's RAM. | |
| result< void > | try_wait () |
| Waits for the controller's BUSY line to release. | |
| template<typename Rep , typename Period > | |
| result< void > | try_wait_for (const std::chrono::duration< Rep, Period > &timeout) |
| Waits for the controller's BUSY line to release, with a timeout. | |
| void | set_color_mode (enum color_mode mode) |
| Switches the panel between monochrome and grayscale operation. | |
| result< void > | try_set_color_mode (enum color_mode mode) |
| Switches the panel between monochrome and grayscale operation. | |
| void | sleep () |
| Puts the panel controller into deep sleep. | |
| void | wake () |
| Wakes the panel controller from deep sleep. | |
| result< void > | try_sleep () |
| Puts the panel controller into deep sleep. | |
| result< void > | try_wake () |
| Wakes the panel controller from deep sleep. | |
Protected Member Functions | |
| panel (size_t width, size_t height) noexcept | |
| Constructs the panel base with the given dimensions and no control lines. | |
| panel (size_t width, size_t height, gpio busy_gpio, enum gpio::level busy_level, std::chrono::milliseconds busy_timeout, gpio reset_gpio) noexcept | |
| Constructs the panel base with the given dimensions and control lines. | |
| panel (panel &&) noexcept=default | |
| panel & | operator= (panel &&) noexcept=default |
| gpio | busy_gpio () const noexcept |
| Returns the BUSY input pin (may be unconnected). | |
| gpio | reset_gpio () const noexcept |
| Returns the reset output pin (may be unconnected). | |
| std::chrono::milliseconds | busy_timeout () const noexcept |
| Returns the default BUSY timeout. | |
| virtual result< void > | do_write (const mono_framebuffer &fb, size_t row_start, size_t row_end, size_t x, size_t y)=0 |
| Hook for try_write / try_write_rows (monochrome). | |
| virtual result< void > | do_write (const gray4_framebuffer &fb, size_t row_start, size_t row_end, size_t x, size_t y) |
| Hook for try_write / try_write_rows (grayscale). | |
| virtual result< void > | do_clear ()=0 |
| Hook for try_clear. | |
| virtual result< void > | do_refresh (refresh_mode mode)=0 |
| Hook for try_refresh. | |
| virtual result< void > | do_set_color_mode (enum color_mode mode) |
| Hook for try_set_color_mode. | |
| virtual result< void > | do_sleep ()=0 |
| Hook for try_sleep. Called only while the panel is awake. | |
| virtual result< void > | do_wake ()=0 |
| Hook for try_wake. | |
| virtual result< void > | do_wait (std::optional< std::chrono::milliseconds > timeout) |
| Hook for try_wait / try_wait_for. | |
| result< void > | wait_busy (std::optional< std::chrono::milliseconds > timeout=std::nullopt) |
| Polls the BUSY line until it releases. | |
| result< void > | hardware_reset () |
| Pulses the reset line and waits for the controller to settle. | |
Static Protected Member Functions | |
| static result< void > | configure_control_lines (gpio busy_gpio, gpio reset_gpio) |
| Configures the direction of the BUSY and reset pins. | |
Abstract base class for ePaper display panels.
The public interface is non-virtual; concrete drivers (e.g. idfxx::epaper::ssd1680) customize behaviour by overriding the protected do_* hooks, mirroring the standard library's non-virtual-interface pattern (cf. std::pmr::memory_resource).
The interface follows the ePaper update cycle:
|
virtualdefault |
|
delete |
|
inlineprotectednoexcept |
|
inlineprotectednoexcept |
Constructs the panel base with the given dimensions and control lines.
The base then owns the physical control lines: the default do_wait polls busy_gpio, and hardware_reset pulses reset_gpio. Configure the pin directions first (see configure_control_lines).
| width | Panel width in pixels. |
| height | Panel height in pixels. |
| busy_gpio | The BUSY input pin, or gpio::nc(). |
| busy_level | The level the controller drives while busy. |
| busy_timeout | Default maximum time to wait for BUSY to release. |
| reset_gpio | The reset output pin, or gpio::nc(). |
|
protecteddefaultnoexcept |
|
inlinenoexcept |
Returns whether the panel is in deep sleep.
True after a successful sleep and until the next successful wake. While asleep, writes and refreshes report errc::invalid_state.
|
inlineprotectednoexcept |
|
inlineprotectednoexcept |
|
inline |
Clears the controller's RAM to white, without a framebuffer.
Fills the entire image RAM with white (blank paper) in the current color mode. Like a write, the cleared frame is invisible until the next refresh — which is promoted to refresh_mode::full, since the cleared RAM no longer matches what a partial refresh would diff against.
Useful for blanking the display, or for erasing previous content before switching to color_mode::gray4, whose waveform erases less aggressively than a monochrome full refresh.
| std::system_error | on failure, including errc::invalid_state if the panel is asleep. |
Definition at line 263 of file panel.hpp.
References try_clear(), and idfxx::unwrap().
|
inlinenoexcept |
Returns the panel's current pixel format.
Reflects the most recent successful try_set_color_mode / set_color_mode, or color_mode::mono before any call.
|
staticprotected |
Configures the direction of the BUSY and reset pins.
Shared helper for driver factories, run before construction: sets busy_gpio as an input (it is driven by the panel, so no pull is needed) and, when connected, reset_gpio as an output idling high.
| busy_gpio | The BUSY input pin (required). |
| reset_gpio | The reset output pin, or gpio::nc(). |
| invalid_arg | busy_gpio is not connected. |
|
protectedpure virtual |
Hook for try_clear.
Fills the entire image RAM with white in the current color mode. The panel is awake; the base class invalidates the partial-refresh baseline after a successful clear.
Referenced by try_clear().
|
protectedpure virtual |
Hook for try_refresh.
The panel is awake, and a partial request has already been promoted to full when no baseline exists. Must block until the update completes (or times out), and must return errc::not_supported for a mode the driver cannot perform in the current color mode.
Referenced by try_refresh().
|
inlineprotectedvirtual |
Hook for try_set_color_mode.
Called only for an actual mode change while the panel is awake. The default returns errc::not_supported: drivers with grayscale support override it.
Definition at line 741 of file panel.hpp.
References idfxx::error(), and idfxx::not_supported.
Referenced by try_set_color_mode().
|
protectedpure virtual |
Hook for try_sleep. Called only while the panel is awake.
Referenced by try_sleep().
|
inlineprotectedvirtual |
Hook for try_wait / try_wait_for.
A std::nullopt timeout selects the driver's configured default. The default implementation polls the BUSY line configured at construction (see wait_busy).
Definition at line 755 of file panel.hpp.
References idfxx::timeout, and wait_busy().
Referenced by try_wait(), and try_wait_for().
|
protectedpure virtual |
Hook for try_wake.
Must hardware-reset the controller, re-initialize it, and restore the current color mode.
Referenced by try_wake().
|
inlineprotectedvirtual |
Hook for try_write / try_write_rows (grayscale).
Uploads rows [row_start, row_end) of fb with its origin at (x, y). The placement is aligned and in-bounds, the row range is valid, and the panel is awake and in color_mode::gray4. Must not reference fb's storage after returning: callers may mutate the framebuffer immediately. The default returns errc::not_supported; drivers with grayscale support override it alongside do_set_color_mode (without that override the panel never enters color_mode::gray4, so this hook is never reached).
Definition at line 717 of file panel.hpp.
References idfxx::error(), and idfxx::not_supported.
|
protectedpure virtual |
Hook for try_write / try_write_rows (monochrome).
Uploads rows [row_start, row_end) of fb with its origin at (x, y). The placement is aligned and in-bounds, the row range is valid, and the panel is awake and in color_mode::mono. Must not reference fb's storage after returning: callers may mutate the framebuffer immediately.
|
protected |
Pulses the reset line and waits for the controller to settle.
Drives the reset pin configured at construction low for 10 ms, back high for 10 ms, then waits for the BUSY line to release.
| invalid_state | No reset pin is configured. |
| timeout | The BUSY line did not release after the reset. |
|
inlinenoexcept |
|
inline |
Refreshes the panel from the controller's RAM.
Drives the physical ink update, making previously written pixel data visible, and blocks until the controller's BUSY line reports completion. Full refreshes take on the order of seconds; partial refreshes well under a second, depending on the panel.
A refresh_mode::partial refresh needs a baseline image from a previous refresh to diff against; the first refresh after construction, wake, or a color-mode change is silently promoted to refresh_mode::full.
| mode | The refresh style to use. |
| std::system_error | on failure, including errc::timeout if the BUSY line does not release in time, errc::invalid_state if the panel is asleep, and errc::not_supported if the driver does not support mode in the current color mode. |
Definition at line 403 of file panel.hpp.
References try_refresh(), and idfxx::unwrap().
|
inlineprotectednoexcept |
|
inline |
Switches the panel between monochrome and grayscale operation.
Reconfigures the controller's waveforms for the new pixel format and invalidates the partial-refresh baseline: the next refresh is promoted to refresh_mode::full. A no-op if the panel is already in the requested mode.
| mode | The pixel format to operate in. |
| std::system_error | on failure, including errc::invalid_state if the panel is asleep, and errc::not_supported if the driver has no grayscale support. |
Definition at line 520 of file panel.hpp.
References try_set_color_mode(), and idfxx::unwrap().
|
inline |
Puts the panel controller into deep sleep.
ePaper retains its image without power, so sleeping between updates costs nothing visually and is strongly recommended — both for power and for panel longevity (controllers left active can degrade the glass). While asleep, writes and refreshes report errc::invalid_state; call wake to resume. A no-op if the panel is already asleep.
| std::system_error | on failure. |
Definition at line 569 of file panel.hpp.
References try_sleep(), and idfxx::unwrap().
|
inline |
Clears the controller's RAM to white, without a framebuffer.
Fills the entire image RAM with white (blank paper) in the current color mode. Like a write, the cleared frame is invisible until the next try_refresh — which is promoted to refresh_mode::full, since the cleared RAM no longer matches what a partial refresh would diff against.
Useful for blanking the display, or for erasing previous content before switching to color_mode::gray4, whose waveform erases less aggressively than a monochrome full refresh.
| invalid_state | The panel is asleep. |
Definition at line 367 of file panel.hpp.
References do_clear(), idfxx::error(), and idfxx::invalid_state.
Referenced by clear().
|
inline |
Refreshes the panel from the controller's RAM.
Drives the physical ink update, making previously written pixel data visible, and blocks until the controller's BUSY line reports completion. Full refreshes take on the order of seconds; partial refreshes well under a second, depending on the panel.
A refresh_mode::partial refresh needs a baseline image from a previous refresh to diff against; the first refresh after construction, try_wake, or a color-mode change is silently promoted to refresh_mode::full.
| mode | The refresh style to use. |
| timeout | The BUSY line did not release in time. |
| invalid_state | The panel is asleep. |
| not_supported | The driver does not support mode in the current color mode (e.g. fast/partial in color_mode::gray4 on current drivers). |
Definition at line 458 of file panel.hpp.
References do_refresh(), idfxx::error(), idfxx::epaper::full, idfxx::invalid_state, and idfxx::epaper::partial.
Referenced by refresh().
|
inline |
Switches the panel between monochrome and grayscale operation.
Reconfigures the controller's waveforms for the new pixel format and invalidates the partial-refresh baseline: the next refresh is promoted to refresh_mode::full. A no-op if the panel is already in the requested mode.
| mode | The pixel format to operate in. |
| invalid_state | The panel is asleep. |
| not_supported | The driver has no grayscale support. |
Definition at line 536 of file panel.hpp.
References do_set_color_mode(), idfxx::error(), and idfxx::invalid_state.
Referenced by set_color_mode().
|
inline |
Puts the panel controller into deep sleep.
ePaper retains its image without power, so sleeping between updates costs nothing visually and is strongly recommended — both for power and for panel longevity (controllers left active can degrade the glass). While asleep, writes and refreshes report errc::invalid_state; call try_wake to resume. A no-op if the panel is already asleep.
Definition at line 599 of file panel.hpp.
References do_sleep().
Referenced by sleep().
|
inline |
Waits for the controller's BUSY line to release.
Blocks while the controller reports it is busy, up to the driver's configured default timeout. try_refresh already waits for completion; this is useful before driver-specific raw operations or after recovering from an error.
| timeout | The BUSY line did not release in time. |
Definition at line 483 of file panel.hpp.
References do_wait().
Referenced by wait().
|
inline |
Waits for the controller's BUSY line to release, with a timeout.
Blocks while the controller reports it is busy, up to timeout.
| Rep | Duration arithmetic type. |
| Period | Duration period type. |
| timeout | Maximum time to wait. |
| timeout | The BUSY line did not release within timeout. |
Definition at line 497 of file panel.hpp.
References do_wait(), and idfxx::timeout.
Referenced by wait_for().
|
inline |
Wakes the panel controller from deep sleep.
ePaper controllers require a hardware reset to leave deep sleep, so this pulses the driver's reset line and re-runs the full controller initialization, restoring the configured color mode. The partial-refresh baseline is lost: the next refresh is promoted to refresh_mode::full.
| invalid_state | No reset line is configured. |
Definition at line 622 of file panel.hpp.
References do_wake().
Referenced by wake().
| result< void > idfxx::epaper::panel::try_write | ( | const gray4_framebuffer & | fb, |
| size_t | x = 0, |
||
| size_t | y = 0 |
||
| ) |
Uploads a grayscale framebuffer to the controller's RAM.
Places the framebuffer's origin at pixel (x, y). The upload is invisible until the next try_refresh. The panel must be operating in color_mode::gray4.
| fb | The framebuffer to upload. |
| x | Destination column; must be a multiple of 8 (controller RAM is byte-packed along the row). |
| y | Destination row. |
| invalid_arg | x is not a multiple of 8, or the framebuffer does not fit within the panel at (x, y). |
| invalid_state | The panel is asleep, or is operating in color_mode::mono. |
| result< void > idfxx::epaper::panel::try_write | ( | const mono_framebuffer & | fb, |
| size_t | x = 0, |
||
| size_t | y = 0 |
||
| ) |
Uploads a monochrome framebuffer to the controller's RAM.
Places the framebuffer's origin at pixel (x, y). The upload is invisible until the next try_refresh. The panel must be operating in color_mode::mono.
| fb | The framebuffer to upload. |
| x | Destination column; must be a multiple of 8 (controller RAM is byte-packed along the row). |
| y | Destination row. |
| invalid_arg | x is not a multiple of 8, or the framebuffer does not fit within the panel at (x, y). |
| invalid_state | The panel is asleep, or is operating in color_mode::gray4. |
Referenced by idfxx::epaper::gray4_framebuffer::try_flush(), idfxx::epaper::mono_framebuffer::try_flush(), write(), and write().
| result< void > idfxx::epaper::panel::try_write_rows | ( | const gray4_framebuffer & | fb, |
| size_t | row_start, | ||
| size_t | row_end, | ||
| size_t | x = 0, |
||
| size_t | y = 0 |
||
| ) |
Uploads a horizontal band of a grayscale framebuffer.
Uploads rows [row_start, row_end) of fb, with the framebuffer's origin at pixel (x, y) — row r of the framebuffer lands at panel row y + r.
| fb | The framebuffer to upload from. |
| row_start | First framebuffer row of the band, inclusive. |
| row_end | End framebuffer row, exclusive; must satisfy row_start < row_end <= fb.height(). |
| x | Destination column of the framebuffer origin; must be a multiple of 8. |
| y | Destination row of the framebuffer origin. |
| invalid_arg | The row range is invalid, x is not a multiple of 8, or the band does not fit within the panel. |
| invalid_state | The panel is asleep, or is operating in color_mode::mono. |
| result< void > idfxx::epaper::panel::try_write_rows | ( | const mono_framebuffer & | fb, |
| size_t | row_start, | ||
| size_t | row_end, | ||
| size_t | x = 0, |
||
| size_t | y = 0 |
||
| ) |
Uploads a horizontal band of a monochrome framebuffer.
Uploads rows [row_start, row_end) of fb, with the framebuffer's origin at pixel (x, y) — row r of the framebuffer lands at panel row y + r, so a band flushed from a full-frame framebuffer lands exactly where the full upload would place it.
| fb | The framebuffer to upload from. |
| row_start | First framebuffer row of the band, inclusive. |
| row_end | End framebuffer row, exclusive; must satisfy row_start < row_end <= fb.height(). |
| x | Destination column of the framebuffer origin; must be a multiple of 8. |
| y | Destination row of the framebuffer origin. |
| invalid_arg | The row range is invalid, x is not a multiple of 8, or the band does not fit within the panel. |
| invalid_state | The panel is asleep, or is operating in color_mode::gray4. |
Referenced by idfxx::epaper::gray4_framebuffer::try_flush_rows(), idfxx::epaper::mono_framebuffer::try_flush_rows(), write_rows(), and write_rows().
|
inline |
Waits for the controller's BUSY line to release.
Blocks while the controller reports it is busy, up to the driver's configured default timeout. refresh already waits for completion; this is useful before driver-specific raw operations or after recovering from an error.
| std::system_error | on failure, including errc::timeout if the BUSY line does not release in time. |
Definition at line 417 of file panel.hpp.
References try_wait(), and idfxx::unwrap().
|
protected |
Polls the BUSY line until it releases.
Polls the BUSY pin configured at construction once per RTOS tick until it leaves the busy level, reporting errc::timeout if it does not release in time. Returns success immediately if no BUSY pin is configured.
| timeout | Maximum time to wait, or std::nullopt for the default configured at construction. |
| timeout | The BUSY line did not release in time. |
Referenced by do_wait().
|
inline |
Waits for the controller's BUSY line to release, with a timeout.
Blocks while the controller reports it is busy, up to timeout.
| Rep | Duration arithmetic type. |
| Period | Duration period type. |
| timeout | Maximum time to wait. |
| std::system_error | on failure, including errc::timeout if the BUSY line does not release in time. |
Definition at line 432 of file panel.hpp.
References idfxx::timeout, try_wait_for(), and idfxx::unwrap().
|
inline |
Wakes the panel controller from deep sleep.
ePaper controllers require a hardware reset to leave deep sleep, so this pulses the driver's reset line and re-runs the full controller initialization, restoring the configured color mode. The partial-refresh baseline is lost: the next refresh is promoted to refresh_mode::full.
| std::system_error | on failure, including errc::invalid_state if no reset line is configured. |
Definition at line 584 of file panel.hpp.
References try_wake(), and idfxx::unwrap().
|
inlinenoexcept |
|
inline |
Uploads a grayscale framebuffer to the controller's RAM.
Places the framebuffer's origin at pixel (x, y). The upload is invisible until the next refresh. The panel must be operating in color_mode::gray4.
| fb | The framebuffer to upload. |
| x | Destination column; must be a multiple of 8 (controller RAM is byte-packed along the row). |
| y | Destination row. |
| std::system_error | on failure, including errc::invalid_arg for an unaligned x or an out-of-bounds placement, and errc::invalid_state if the panel is asleep or in color_mode::mono. |
Definition at line 195 of file panel.hpp.
References try_write(), and idfxx::unwrap().
|
inline |
Uploads a monochrome framebuffer to the controller's RAM.
Places the framebuffer's origin at pixel (x, y). The upload is invisible until the next refresh. The panel must be operating in color_mode::mono.
| fb | The framebuffer to upload. |
| x | Destination column; must be a multiple of 8 (controller RAM is byte-packed along the row). |
| y | Destination row. |
| std::system_error | on failure, including errc::invalid_arg for an unaligned x or an out-of-bounds placement, and errc::invalid_state if the panel is asleep or in color_mode::gray4. |
Definition at line 176 of file panel.hpp.
References try_write(), and idfxx::unwrap().
|
inline |
Uploads a horizontal band of a grayscale framebuffer.
Uploads rows [row_start, row_end) of fb, with the framebuffer's origin at pixel (x, y) — row r of the framebuffer lands at panel row y + r.
| fb | The framebuffer to upload from. |
| row_start | First framebuffer row of the band, inclusive. |
| row_end | End framebuffer row, exclusive; must satisfy row_start < row_end <= fb.height(). |
| x | Destination column of the framebuffer origin; must be a multiple of 8. |
| y | Destination row of the framebuffer origin. |
| std::system_error | on failure, including errc::invalid_arg for an invalid row range, an unaligned x, or an out-of-bounds placement, and errc::invalid_state if the panel is asleep or in color_mode::mono. |
Definition at line 242 of file panel.hpp.
References try_write_rows(), and idfxx::unwrap().
|
inline |
Uploads a horizontal band of a monochrome framebuffer.
Uploads rows [row_start, row_end) of fb, with the framebuffer's origin at pixel (x, y) — row r of the framebuffer lands at panel row y + r, so a band flushed from a full-frame framebuffer lands exactly where the full upload would place it.
| fb | The framebuffer to upload from. |
| row_start | First framebuffer row of the band, inclusive. |
| row_end | End framebuffer row, exclusive; must satisfy row_start < row_end <= fb.height(). |
| x | Destination column of the framebuffer origin; must be a multiple of 8. |
| y | Destination row of the framebuffer origin. |
| std::system_error | on failure, including errc::invalid_arg for an invalid row range, an unaligned x, or an out-of-bounds placement, and errc::invalid_state if the panel is asleep or in color_mode::gray4. |
Definition at line 218 of file panel.hpp.
References try_write_rows(), and idfxx::unwrap().