Ersa Wearable Platform
Embedded smartwatch firmware and application framework
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes | List of all members
ersa::test::MockDisplay Class Reference

#include <mock_display.h>

Inheritance diagram for ersa::test::MockDisplay:
Inheritance graph
[legend]
Collaboration diagram for ersa::test::MockDisplay:
Collaboration graph
[legend]

Public Member Functions

 MockDisplay ()
 
Result< void > init () override
 
int16_t width () const override
 
int16_t height () const override
 
void clear (hal::Color color=hal::Color::Black) override
 
void drawPixel (int16_t x, int16_t y, hal::Color color) override
 
void drawLine (int16_t x1, int16_t y1, int16_t x2, int16_t y2, hal::Color color) override
 
void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, hal::Color color) override
 
void drawFastHLine (int16_t x, int16_t y, int16_t w, hal::Color color) override
 
void drawFastVLine (int16_t x, int16_t y, int16_t h, hal::Color color) override
 
void drawCircle (int16_t x, int16_t y, int16_t r, hal::Color color) override
 
void fillCircle (int16_t x, int16_t y, int16_t r, hal::Color color) override
 
void drawRoundRect (int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, hal::Color color) override
 Draw an unfilled rectangle with rounded corners.
 
void fillRoundRect (int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, hal::Color color) override
 Draw a filled rectangle with rounded corners.
 
void setFont (hal::FontFace face) override
 
void setTextSize (uint8_t size) override
 
void setTextColor (hal::Color color) override
 
void setTextWrap (bool wrap) override
 
void setCursor (int16_t x, int16_t y) override
 
size_t print (const char *text) override
 
size_t print (uint8_t value) override
 Draw an unsigned byte value and return the number of characters consumed.
 
size_t print (int32_t value) override
 Draw a signed 32-bit value and return the number of characters consumed.
 
size_t print (uint32_t value) override
 Draw an unsigned 32-bit value and return the number of characters consumed.
 
void getTextBounds (const char *text, int16_t x, int16_t y, int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h) override
 
void refresh (bool full=false) override
 
void refreshRect (const Rect &rect) override
 
bool isBusy () const override
 Return whether the panel is still processing a refresh.
 
void setBusyCallback (hal::DisplayBusyCallback cb, void *userData=nullptr) override
 
void powerOff () override
 
void powerOn () override
 
bool isPowered () const override
 
const uint8_t * getBuffer () const override
 
uint8_t * getBuffer () override
 
hal::Color getPixel (int16_t x, int16_t y) const
 
- Public Member Functions inherited from ersa::hal::IDisplay
virtual ~IDisplay ()=default
 
void fillScreen (uint16_t color)
 Clear the framebuffer using the legacy 0=black, nonzero=white mapping.
 
void setTextColor (uint16_t color)
 Set legacy monochrome text color; nonzero maps to white.
 
void drawLine (int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 Draw a line using the legacy monochrome color convention.
 
void drawFastHLine (int16_t x, int16_t y, int16_t w, uint16_t color)
 
void drawFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 
void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 
void drawCircle (int16_t x, int16_t y, int16_t r, uint16_t color)
 
void fillCircle (int16_t x, int16_t y, int16_t r, uint16_t color)
 
void drawRoundRect (int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color)
 
void fillRoundRect (int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color)
 

Public Attributes

uint32_t fullRefreshes_ {0}
 
uint32_t partialRefreshes_ {0}
 
bool powered_ {true}
 
uint32_t drawLineCalls_ {0}
 
hal::FontFace font_ {hal::FontFace::MiSansRegular8}
 
hal::Color textColor_ {hal::Color::White}
 
uint8_t textSize_ {1}
 
bool textWrap_ {true}
 
int16_t cursorX_ {0}
 
int16_t cursorY_ {0}
 
std::string lastText_
 
int32_t lastNumber_ {0}
 

Static Public Attributes

static constexpr int16_t W = 200
 
static constexpr int16_t H = 200
 

Private Attributes

std::vector< uint8_t > buffer_
 

Constructor & Destructor Documentation

◆ MockDisplay()

ersa::test::MockDisplay::MockDisplay ( )
inline

Member Function Documentation

◆ clear()

void ersa::test::MockDisplay::clear ( hal::Color  color = hal::Color::Black)
inlineoverridevirtual

Fill the drawing buffer with one logical color; this does not itself trigger a physical panel refresh.

Implements ersa::hal::IDisplay.

◆ drawCircle()

void ersa::test::MockDisplay::drawCircle ( int16_t  x,
int16_t  y,
int16_t  r,
hal::Color  color 
)
inlineoverridevirtual

Draw a circle outline centered at (x, y) with the given radius.

Implements ersa::hal::IDisplay.

◆ drawFastHLine()

void ersa::test::MockDisplay::drawFastHLine ( int16_t  x,
int16_t  y,
int16_t  w,
hal::Color  color 
)
inlineoverridevirtual

Draw a horizontal line, allowing the backend to optimize row access.

Implements ersa::hal::IDisplay.

◆ drawFastVLine()

void ersa::test::MockDisplay::drawFastVLine ( int16_t  x,
int16_t  y,
int16_t  h,
hal::Color  color 
)
inlineoverridevirtual

Draw a vertical line, allowing the backend to optimize column access.

Implements ersa::hal::IDisplay.

◆ drawLine()

void ersa::test::MockDisplay::drawLine ( int16_t  x1,
int16_t  y1,
int16_t  x2,
int16_t  y2,
hal::Color  color 
)
inlineoverridevirtual

Rasterize a line from (x1, y1) to (x2, y2) in the framebuffer.

Implements ersa::hal::IDisplay.

◆ drawPixel()

void ersa::test::MockDisplay::drawPixel ( int16_t  x,
int16_t  y,
hal::Color  color 
)
inlineoverridevirtual

Set the framebuffer pixel at (x, y), clipping unsupported coordinates.

Implements ersa::hal::IDisplay.

◆ drawRoundRect()

void ersa::test::MockDisplay::drawRoundRect ( int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
int16_t  radius,
hal::Color  color 
)
inlineoverridevirtual

Draw an unfilled rectangle with rounded corners.

Implements ersa::hal::IDisplay.

◆ fillCircle()

void ersa::test::MockDisplay::fillCircle ( int16_t  x,
int16_t  y,
int16_t  r,
hal::Color  color 
)
inlineoverridevirtual

Fill a circle centered at (x, y) with the given radius.

Implements ersa::hal::IDisplay.

◆ fillRect()

void ersa::test::MockDisplay::fillRect ( int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
hal::Color  color 
)
inlineoverridevirtual

Fill a rectangle with its top-left corner at (x, y).

Implements ersa::hal::IDisplay.

◆ fillRoundRect()

void ersa::test::MockDisplay::fillRoundRect ( int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
int16_t  radius,
hal::Color  color 
)
inlineoverridevirtual

Draw a filled rectangle with rounded corners.

Implements ersa::hal::IDisplay.

◆ getBuffer() [1/2]

const uint8_t * ersa::test::MockDisplay::getBuffer ( ) const
inlineoverridevirtual

Return a non-owning read-only framebuffer view, or null if unavailable.

Implements ersa::hal::IDisplay.

◆ getBuffer() [2/2]

uint8_t * ersa::test::MockDisplay::getBuffer ( )
inlineoverridevirtual

Return a non-owning mutable framebuffer view, or null if unavailable. Direct access is an optimization; callers must still schedule refresh().

Implements ersa::hal::IDisplay.

◆ getPixel()

hal::Color ersa::test::MockDisplay::getPixel ( int16_t  x,
int16_t  y 
) const
inline

◆ getTextBounds()

void ersa::test::MockDisplay::getTextBounds ( const char *  text,
int16_t  x,
int16_t  y,
int16_t *  x1,
int16_t *  y1,
uint16_t *  w,
uint16_t *  h 
)
inlineoverridevirtual

Measure text using the current font/size without drawing it.

Parameters
textNull-terminated string to measure.
xBaseline origin x coordinate.
yBaseline origin y coordinate.
x1Receives the left edge relative to the supplied origin.
y1Receives the top edge relative to the supplied baseline.
wReceives measured width in pixels.
hReceives measured height in pixels. Callers should provide non-null output pointers supported by the driver.

Implements ersa::hal::IDisplay.

◆ height()

int16_t ersa::test::MockDisplay::height ( ) const
inlineoverridevirtual

Return vertical logical resolution used by app coordinates.

Implements ersa::hal::IDisplay.

◆ init()

Result< void > ersa::test::MockDisplay::init ( )
inlineoverridevirtual

Initialize the panel and its drawing buffer.

Returns
An error when the controller or required buffer is unavailable.

Implements ersa::hal::IDisplay.

◆ isBusy()

bool ersa::test::MockDisplay::isBusy ( ) const
inlineoverridevirtual

Return whether the panel is still processing a refresh.

Implements ersa::hal::IDisplay.

◆ isPowered()

bool ersa::test::MockDisplay::isPowered ( ) const
inlineoverridevirtual

Return the driver's current powered state; this does not imply the image is visible.

Implements ersa::hal::IDisplay.

◆ powerOff()

void ersa::test::MockDisplay::powerOff ( )
inlineoverridevirtual

Put the panel or driver into its supported low-power state. Visible-image retention and controller-state retention are device-specific.

Implements ersa::hal::IDisplay.

◆ powerOn()

void ersa::test::MockDisplay::powerOn ( )
inlineoverridevirtual

Restore a state usable for drawing or refresh; implementations may reinitialize hardware.

Implements ersa::hal::IDisplay.

◆ print() [1/4]

size_t ersa::test::MockDisplay::print ( const char *  text)
inlineoverridevirtual

Draw a null-terminated string at the current cursor and return its consumed character count. The pointer is borrowed for this call only.

Implements ersa::hal::IDisplay.

◆ print() [2/4]

size_t ersa::test::MockDisplay::print ( int32_t  value)
inlineoverridevirtual

Draw a signed 32-bit value and return the number of characters consumed.

Implements ersa::hal::IDisplay.

◆ print() [3/4]

size_t ersa::test::MockDisplay::print ( uint32_t  value)
inlineoverridevirtual

Draw an unsigned 32-bit value and return the number of characters consumed.

Implements ersa::hal::IDisplay.

◆ print() [4/4]

size_t ersa::test::MockDisplay::print ( uint8_t  value)
inlineoverridevirtual

Draw an unsigned byte value and return the number of characters consumed.

Implements ersa::hal::IDisplay.

◆ refresh()

void ersa::test::MockDisplay::refresh ( bool  full = false)
inlineoverridevirtual

Transmit the framebuffer to the panel.

Parameters
fullRequest a full waveform when true; partial waveform otherwise.

Implements ersa::hal::IDisplay.

◆ refreshRect()

void ersa::test::MockDisplay::refreshRect ( const Rect &  rect)
inlineoverridevirtual

Update only the specified region when the panel supports partial refresh. Drivers without region updates may safely promote this to a full refresh.

Implements ersa::hal::IDisplay.

◆ setBusyCallback()

void ersa::test::MockDisplay::setBusyCallback ( hal::DisplayBusyCallback  cb,
void *  userData = nullptr 
)
inlineoverridevirtual

Register a completion/wait callback for panel busy handling.

Parameters
cbCallback invoked by the driver, or null to clear it.
userDataOpaque context passed back unchanged to cb.

Implements ersa::hal::IDisplay.

◆ setCursor()

void ersa::test::MockDisplay::setCursor ( int16_t  x,
int16_t  y 
)
inlineoverridevirtual

Set the text baseline origin used by subsequent print() calls.

Implements ersa::hal::IDisplay.

◆ setFont()

void ersa::test::MockDisplay::setFont ( hal::FontFace  face)
inlineoverridevirtual

Select an asset-level font name; drivers map it to their own font data.

Implements ersa::hal::IDisplay.

◆ setTextColor()

void ersa::test::MockDisplay::setTextColor ( hal::Color  color)
inlineoverridevirtual

Set the color used by subsequent print() calls.

Implements ersa::hal::IDisplay.

◆ setTextSize()

void ersa::test::MockDisplay::setTextSize ( uint8_t  size)
inlineoverridevirtual

Set text scaling; size 1 is the backend's normal scale.

Implements ersa::hal::IDisplay.

◆ setTextWrap()

void ersa::test::MockDisplay::setTextWrap ( bool  wrap)
inlineoverridevirtual

Control whether subsequent text wraps when it reaches the canvas edge.

Implements ersa::hal::IDisplay.

◆ width()

int16_t ersa::test::MockDisplay::width ( ) const
inlineoverridevirtual

Return horizontal logical resolution used by app coordinates.

Implements ersa::hal::IDisplay.

Member Data Documentation

◆ buffer_

std::vector<uint8_t> ersa::test::MockDisplay::buffer_
private

◆ cursorX_

int16_t ersa::test::MockDisplay::cursorX_ {0}

◆ cursorY_

int16_t ersa::test::MockDisplay::cursorY_ {0}

◆ drawLineCalls_

uint32_t ersa::test::MockDisplay::drawLineCalls_ {0}

◆ font_

hal::FontFace ersa::test::MockDisplay::font_ {hal::FontFace::MiSansRegular8}

◆ fullRefreshes_

uint32_t ersa::test::MockDisplay::fullRefreshes_ {0}

◆ H

constexpr int16_t ersa::test::MockDisplay::H = 200
staticconstexpr

◆ lastNumber_

int32_t ersa::test::MockDisplay::lastNumber_ {0}

◆ lastText_

std::string ersa::test::MockDisplay::lastText_

◆ partialRefreshes_

uint32_t ersa::test::MockDisplay::partialRefreshes_ {0}

◆ powered_

bool ersa::test::MockDisplay::powered_ {true}

◆ textColor_

hal::Color ersa::test::MockDisplay::textColor_ {hal::Color::White}

◆ textSize_

uint8_t ersa::test::MockDisplay::textSize_ {1}

◆ textWrap_

bool ersa::test::MockDisplay::textWrap_ {true}

◆ W

constexpr int16_t ersa::test::MockDisplay::W = 200
staticconstexpr

The documentation for this class was generated from the following file: