![]() |
Deluge Firmware 1.3.0
Build date: 2025.04.16
|
Public Types | |
using | ImageStore = uint8_t[kImageHeight][kImageWidth] |
Public Member Functions | |
Canvas (Canvas const &other)=delete | |
Canvas (Canvas &&other)=delete | |
Canvas & | operator= (Canvas const &other)=delete |
Canvas & | operator= (Canvas &&other)=delete |
ImageStore & | hackGetImageStore () |
XXX: DO NOT USE THIS OUTSIDE OF THE CORE OLED CODE. | |
Rendering routines | |
void | clear () |
Clear the entire image. | |
void | clearAreaExact (int32_t minX, int32_t minY, int32_t maxX, int32_t maxY) |
void | drawPixel (int32_t x, int32_t y) |
Set a single pixel. | |
void | drawHorizontalLine (int32_t pixelY, int32_t startX, int32_t endX) |
void | drawVerticalLine (int32_t pixelX, int32_t startY, int32_t endY) |
void | drawRectangle (int32_t minX, int32_t minY, int32_t maxX, int32_t maxY) |
void | drawString (std::string_view str, int32_t pixelX, int32_t pixelY, int32_t textWidth, int32_t textHeight, int32_t scrollPos=0, int32_t endX=OLED_MAIN_WIDTH_PIXELS, bool useTextWidth=false) |
void | drawStringCentred (char const *string, int32_t pixelY, int32_t textWidth, int32_t textHeight, int32_t centrePos=OLED_MAIN_WIDTH_PIXELS/2) |
void | drawStringCentredShrinkIfNecessary (char const *string, int32_t pixelY, int32_t textWidth, int32_t textHeight) |
void | drawStringAlignRight (char const *string, int32_t pixelY, int32_t textWidth, int32_t textHeight, int32_t rightPos=OLED_MAIN_WIDTH_PIXELS) |
void | drawChar (uint8_t theChar, int32_t pixelX, int32_t pixelY, int32_t textWidth, int32_t textHeight, int32_t scrollPos=0, int32_t endX=OLED_MAIN_WIDTH_PIXELS) |
Draw a single character. | |
int32_t | getCharIndex (uint8_t theChar) |
int32_t | getCharWidthInPixels (uint8_t theChar, int32_t textHeight) |
int32_t | getCharSpacingInPixels (uint8_t theChar, int32_t textHeight, bool isLastChar) |
int32_t | getStringWidthInPixels (char const *string, int32_t textHeight) |
void | drawGraphicMultiLine (uint8_t const *graphic, int32_t startX, int32_t startY, int32_t width, int32_t height=8, int32_t numBytesTall=1) |
void | drawScreenTitle (std::string_view text) |
void | invertArea (int32_t xMin, int32_t width, int32_t startY, int32_t endY) |
void | invertLeftEdgeForMenuHighlighting (int32_t xMin, int32_t width, int32_t startY, int32_t endY) |
inverts just the left edge | |
Private Attributes | |
uint8_t | image_ [kImageHeight][kImageWidth] |
void Canvas::clearAreaExact | ( | int32_t | minX, |
int32_t | minY, | ||
int32_t | maxX, | ||
int32_t | maxY ) |
Clear only a subset of the image
minX | minimum X coordinate, inclusive |
minY | minimum Y coordinate, inclusive |
maxX | maximum X coordinate, inclusive |
maxY | maximum Y coordinate, exclusive |
void Canvas::drawGraphicMultiLine | ( | uint8_t const * | graphic, |
int32_t | startX, | ||
int32_t | startY, | ||
int32_t | width, | ||
int32_t | height = 8, | ||
int32_t | numBytesTall = 1 ) |
Draw a "graphic".
The provided graphic array is used as a bit mask and added to the existing content.
graphic | Pointer to the start of an array representing the graphic. |
startX | X coodinate of the left edge of the graphic |
startY | Y coordinate of the top of the graphic |
width | Width of the graphic in pixels |
height | Height of the graphic in pixels |
numBytesTall | Number of bytes in the Y direction, determines the stride in the graphic array |
void Canvas::drawHorizontalLine | ( | int32_t | pixelY, |
int32_t | startX, | ||
int32_t | endX ) |
Draw a horizontal line.
pixelY | Y coordinate of the line to draw |
startX | Starting X coordinate, inclusive |
endY | Ending Y coordinate, inclusive |
void Canvas::drawRectangle | ( | int32_t | minX, |
int32_t | minY, | ||
int32_t | maxX, | ||
int32_t | maxY ) |
Draw a 1-px wide rectangle.
minX | Minimum X coordinate, inclusive |
minY | Minimum Y coordinate, inclusive |
maxX | Maximum X coordinate, inclusive |
maxY | Maximum Y coordinate, inclusive |
void Canvas::drawScreenTitle | ( | std::string_view | title | ) |
Draw a screen title and underline it.
text | Title text |
void Canvas::drawString | ( | std::string_view | str, |
int32_t | pixelX, | ||
int32_t | pixelY, | ||
int32_t | textWidth, | ||
int32_t | textHeight, | ||
int32_t | scrollPos = 0, | ||
int32_t | endX = OLED_MAIN_WIDTH_PIXELS, | ||
bool | useTextWidth = false ) |
Draw a string
str | The string |
pixelX | X coordinate of the left side of the string |
pixelY | Y coordinate of the top side of the string |
textWidth | Base width in pixels of each character |
textHeight | Height in pixels of each character |
scrollPos | Offset in pixels representing how far the text has scrolled from the left. |
endX | Maximum X coordinate after which we bail out. N.B. this means the actual maximum X coordinate rendered is endX + textWidth, as the individual character rendering work can overshoot. |
void Canvas::drawStringAlignRight | ( | char const * | string, |
int32_t | pixelY, | ||
int32_t | textWidth, | ||
int32_t | textHeight, | ||
int32_t | rightPos = OLED_MAIN_WIDTH_PIXELS ) |
Draw a string, aligned to the right.
string | A null-terminated C string |
pixelY | The Y coordinate of the top of the string |
textWidth | The width for each character in the string |
textHeight | The height for each character in the string |
rightPos | X coordinate, exclusive, of the rightmost pixel to use for the string |
void Canvas::drawStringCentred | ( | char const * | string, |
int32_t | pixelY, | ||
int32_t | textWidth, | ||
int32_t | textHeight, | ||
int32_t | centrePos = OLED_MAIN_WIDTH_PIXELS / 2 ) |
Draw a string, centered at the provided location.
string | A null-terminated C string |
pixelY | Y coordinate of the top side of the string |
textWidth | Base width in pixels of each character |
textHeight | Height in pixels of each character |
scrollPos | Offset in pixels representing how far the text has scrolled from the left. |
endX | Maximum X coordinate after which we bail out. N.B. this means the actual maximum X coordinate rendered is endX + textWidth, as the individual character rendering work can overshoot. |
void Canvas::drawStringCentredShrinkIfNecessary | ( | char const * | string, |
int32_t | pixelY, | ||
int32_t | textWidth, | ||
int32_t | textHeight ) |
Draw a string, reducing its height so the string fits within the specified width
string | A null-terminated C string |
pixelY | The Y coordinate of the top of the string |
textWidth | Requested width for each character in the string |
textHeight | Requested height for each character in the string |
void Canvas::drawVerticalLine | ( | int32_t | pixelX, |
int32_t | startY, | ||
int32_t | endY ) |
Draw a vertical line.
pixelX | X coordinate of the line |
startY | Y coordinate of the line, inclusive |
endY | Y coordinate of the line, inclusive |
int32_t Canvas::getCharIndex | ( | uint8_t | theChar | ) |
Returns index for character so it can be looked up
theChar | A single character |
int32_t Canvas::getCharSpacingInPixels | ( | uint8_t | theChar, |
int32_t | textHeight, | ||
bool | isLastChar ) |
Returns spacing in pixels between characters drawn in a string
theChar | A single character |
textHeight | The height of the character (to distinguish between non-bold and bold characters) |
isLastChar | a boolean to specify whether any char's follow this char |
int32_t Canvas::getCharWidthInPixels | ( | uint8_t | theChar, |
int32_t | textHeight ) |
Return width of a single character with a given character height
theChar | A single character |
textHeight | The height of the character |
int32_t Canvas::getStringWidthInPixels | ( | char const * | string, |
int32_t | textHeight ) |
Returns width of a string in pixels
string | A null-terminated C string |
textHeight | The height for each character in the string |
void Canvas::invertArea | ( | int32_t | xMin, |
int32_t | width, | ||
int32_t | startY, | ||
int32_t | endY ) |
Invert an area of the canvas.
xMin | Minimum X coordinate, inclusive |
width | Width of the region to invert. End coordinate is excluded. |
startY | Minimum Y coordinate, inclusive |
endY | Maximum Y coordinate, inclusive |
void Canvas::invertLeftEdgeForMenuHighlighting | ( | int32_t | xMin, |
int32_t | width, | ||
int32_t | startY, | ||
int32_t | endY ) |
inverts just the left edge
Invert just the left edge of the canvas.
xMin | Minimum X coordinate, inclusive |
width | Width of the region to invert. End coordinate is excluded. |
startY | Minimum Y coordinate, inclusive |
endY | Maximum Y coordinate, inclusive |