![]() |
Deluge Firmware 1.3.0
Build date: 2025.10.26
|
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 | clearPixel (int32_t x, int32_t y) |
| Clear a single pixel. | |
| void | invertPixel (int32_t x, int32_t y) |
| Invert 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 | drawLine (int32_t x0, int32_t y0, int32_t x1, int32_t y1, const DrawLineOptions &options={}) |
| void | drawRectangle (int32_t minX, int32_t minY, int32_t maxX, int32_t maxY) |
| void | drawRectangleRounded (int32_t minX, int32_t minY, int32_t maxX, int32_t maxY, BorderRadius radius=SMALL) |
| void | drawCircle (int32_t centerX, int32_t centerY, int32_t radius, std::optional< int32_t > min_x=std::nullopt, std::optional< int32_t > max_x=std::nullopt) |
| void | clearCircle (int32_t centerX, int32_t centerY, int32_t radius, std::optional< int32_t > min_x=std::nullopt, std::optional< int32_t > max_x=std::nullopt) |
| 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 | drawStringCentered (char const *string, int32_t startX, int32_t startY, int32_t textSpacingX, int32_t textSpacingY, int32_t totalWidth) |
| void | drawStringCentered (StringBuf &stringBuf, int32_t startX, int32_t startY, int32_t textSpacingX, int32_t textSpacingY, int32_t totalWidth) |
| 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, bool reversed=false) |
| void | drawIcon (const Icon &icon, int32_t x, int32_t y, bool reversed=false) |
| void | drawIconCentered (const Icon &icon, int32_t startX, int32_t totalWidth, int32_t y, bool reversed=false) |
| void | drawScreenTitle (std::string_view text, bool drawSeparator=true) |
| void | invertArea (int32_t xMin, int32_t width, int32_t startY, int32_t endY) |
| void | invertAreaRounded (int32_t xMin, int32_t width, int32_t startY, int32_t endY, BorderRadius radius=SMALL) |
| 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::clearCircle | ( | int32_t | centerX, |
| int32_t | centerY, | ||
| int32_t | radius, | ||
| std::optional< int32_t > | min_x = std::nullopt, | ||
| std::optional< int32_t > | max_x = std::nullopt ) |
Clear a circle using Bresenham algorithm
| centerX | Center X coordinate |
| centerY | Center Y coordinate |
| radius | Circle radius |
| min_x | Optional minimum X boundary |
| max_x | Optional maximum X boundary |
| void Canvas::drawCircle | ( | int32_t | centerX, |
| int32_t | centerY, | ||
| int32_t | radius, | ||
| std::optional< int32_t > | min_x = std::nullopt, | ||
| std::optional< int32_t > | max_x = std::nullopt ) |
Draw a circle using Bresenham algorithm
| centerX | Center X coordinate |
| centerY | Center Y coordinate |
| radius | Circle radius |
| min_x | Optional minimum X boundary |
| max_x | Optional maximum X boundary |
| void Canvas::drawGraphicMultiLine | ( | uint8_t const * | graphic, |
| int32_t | startX, | ||
| int32_t | startY, | ||
| int32_t | width, | ||
| int32_t | height = 8, | ||
| int32_t | numBytesTall = 1, | ||
| bool | reversed = false ) |
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::drawIcon | ( | const Icon & | icon, |
| int32_t | x, | ||
| int32_t | y, | ||
| bool | reversed = false ) |
Draw an icon.
| icon | Reference to the icon |
| x | X coodinate of the left edge of the icon |
| y | Y coordinate of the top of the icon |
| reversed | Should reverse the icon horizontally |
| void Canvas::drawIconCentered | ( | const Icon & | icon, |
| int32_t | startX, | ||
| int32_t | totalWidth, | ||
| int32_t | y, | ||
| bool | reversed = false ) |
Draw an icon, centered between the provided startX and startX + totalWidth
| icon | Reference to the icon |
| startX | Beginning X coordinate for center calculation |
| totalWidth | Total width for center calculation |
| y | Y coordinate of the top of the icon |
| reversed | Should reverse the icon horizontally |
| void Canvas::drawLine | ( | int32_t | x0, |
| int32_t | y0, | ||
| int32_t | x1, | ||
| int32_t | y1, | ||
| const DrawLineOptions & | options = {} ) |
Draw a line using Bresenham algorithm
| x0 | Start X coordinate of the line |
| y0 | Start Y coordinate of the line |
| x1 | End X coordinate of the line |
| y1 | End Y coordinate of the line |
| options | Draw options |
| 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::drawRectangleRounded | ( | int32_t | minX, |
| int32_t | minY, | ||
| int32_t | maxX, | ||
| int32_t | maxY, | ||
| BorderRadius | radius = SMALL ) |
Draw a 1-px wide rectangle with rounded corners
| 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, |
| bool | drawSeparator = true ) |
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::drawStringCentered | ( | char const * | string, |
| int32_t | startX, | ||
| int32_t | startY, | ||
| int32_t | textSpacingX, | ||
| int32_t | textSpacingY, | ||
| int32_t | totalWidth ) |
Draw a string, centered between the provided startX and startX + totalWidth
| string | A null-terminated C string |
| startX | Beginning X coordinate for center calculation |
| startY | Y coordinate of the top side of the string |
| textSpacingX | Base width in pixels of each character |
| textSpacingY | Height in pixels of each character |
| totalWidth | Total width for center calculation |
| void Canvas::drawStringCentered | ( | StringBuf & | stringBuf, |
| int32_t | startX, | ||
| int32_t | startY, | ||
| int32_t | textSpacingX, | ||
| int32_t | textSpacingY, | ||
| int32_t | totalWidth ) |
Draw a string, centered between the provided startX and startX + totalWidth
| stringBuf | A string buffer |
| startX | Beginning X coordinate for center calculation |
| startY | Y coordinate of the top side of the string |
| textSpacingX | Base width in pixels of each character |
| textSpacingY | Height in pixels of each character |
| totalWidth | Total width for center calculation |
| 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 |
Draw a string, reducing its height so the string fits within the specified width
| string | A null-terminated C 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::invertAreaRounded | ( | int32_t | xMin, |
| int32_t | width, | ||
| int32_t | startY, | ||
| int32_t | endY, | ||
| BorderRadius | radius = SMALL ) |
Invert an area of the canvas with rounded corners
| 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 |