ArduinoDumbDisplay v0.9.9-r34
DumbDisplay Arduino Library -- https://github.com/trevorwslee/Arduino-DumbDisplay
 
Loading...
Searching...
No Matches
GraphicalDDLayer Class Reference

Class for graphical LCD layer; created with DumbDisplay::createGraphicalLayer() More...

#include <dumbdisplay.h>

Inheritance diagram for GraphicalDDLayer:
MultiLevelDDLayer DDLayer DDObject

Public Member Functions

 GraphicalDDLayer (int8_t layerId)
 for internal use only
 
void setRotation (int8_t rotationType)
 rotate the screen
 
void setCursor (int x, int y)
 set cursor to position
 
void moveCursorBy (int byX, int byY)
 move cursor by some amount
 
void setTextColor (const String &color, const String &bgColor="")
 
void setTextSize (int size)
 set text size
 
void setTextFont (const String &fontName)
 
void setTextFont ()
 reset text font and size
 
void setTextFont (const String &fontName, int textSize)
 
void setTextWrap (bool wrapOn)
 set whether "print" will auto wrap or not
 
void fillScreen (const String &color)
 
void print (const String &text)
 print text
 
void println (const String &text="")
 print text with line feed
 
void drawChar (int x, int y, char c, const String &color="", const String &bgColor="", int size=0)
 
void drawStr (int x, int y, const String &string, const String &color="", const String &bgColor="", int size=0)
 
void drawTextLine (const String &text, int y, const String &align="L", const String &color="", const String &bgColor="", int size=0)
 
void drawPixel (int x, int y, const String &color="")
 
void drawLine (int x1, int y1, int x2, int y2, const String &color="")
 
void drawCircle (int x, int y, int r, const String &color="", bool filled=false)
 
void fillCircle (int x, int y, int r, const String &color="")
 
void drawTriangle (int x1, int y1, int x2, int y2, int x3, int y3, const String &color="", bool filled=false)
 
void fillTriangle (int x1, int y1, int x2, int y2, int x3, int y3, const String &color="")
 
void drawRect (int x, int y, int w, int h, const String &color="", bool filled=false)
 
void fillRect (int x, int y, int w, int h, const String &color="")
 
void drawRoundRect (int x, int y, int w, int h, int r, const String &color="", bool filled=false)
 
void fillRoundRect (int x, int y, int w, int h, int r, const String &color="")
 
void drawOval (int x, int y, int w, int h, const String &color="", bool filled=false)
 
void fillOval (int x, int y, int w, int h, const String &color="")
 
void drawArc (int x, int y, int w, int h, int startAngle, int sweepAngle, bool useCenter, const String &color="", bool filled=false)
 
void fillArc (int x, int y, int w, int h, int startAngle, int sweepAngle, bool useCenter, const String &color="")
 
void forward (int distance)
 move forward (relative to cursor)
 
void leftTurn (int angle)
 turn left
 
void rightTurn (int angle)
 turn right
 
void setHeading (int angle)
 set heading angle (degree)
 
void penSize (int size)
 set pen size
 
void penColor (const String &color)
 
void fillColor (const String &color)
 
void noFillColor ()
 set no fill color (for shape)
 
void circle (int radius, bool centered=false)
 draw a circle; centered or not
 
void oval (int width, int height, bool centered=false)
 draw an oval; centered or not
 
void arc (int width, int height, int startAngle, int sweepAngle, bool centered=false)
 draw arc; centered or not
 
void triangle (int side1, int angle, int side2)
 draw triangle (SAS)
 
void isoscelesTriangle (int side, int angle)
 draw isosceles triangle; given size and angle
 
void rectangle (int width, int height, bool centered=false)
 draw rectangle; centered or not
 
void polygon (int side, int vertexCount)
 draw polygon given side and vertex count
 
void centeredPolygon (int radius, int vertexCount, bool inside=false)
 
void write (const String &text, bool draw=false)
 
void loadImageFile (const String &imageFileName, int w=0, int h=0, const String &asImageFileName="")
 
void loadImageFileScaled (const String &imageFileName, int w, int h, const String &asImageFileName)
 
void loadImageFileCropped (const String &imageFileName, int x, int y, int w, int h, const String &asImageFileName, int scaleW=0, int scaleH=0)
 
void unloadImageFile (const String &imageFileName)
 unload image file from cache
 
void unloadAllImageFiles ()
 unload all image files from cache
 
void drawImageFile (const String &imageFileName, int x=0, int y=0, int w=0, int h=0, const String &options="")
 
void drawImageFile (const String &imageFileName, const String &options)
 another version of drawImageFile() with options
 
void drawImageFileScaled (const String &imageFileName, int w, int h, const String &options="")
 
void drawImageFileFit (const String &imageFileName, int x=0, int y=0, int w=0, int h=0, const String &options="")
 
void drawImageFileFit (const String &imageFileName, const String &options)
 another version of drawImageFileFit() with options
 
void cacheImage (const String &imageName, const uint8_t *bytes, int byteCount, char compressionMethod=0)
 cache image; not saved
 
void cacheImageWithTS (const String &imageName, const uint8_t *bytes, int byteCount, long imageTimestamp, char compressionMethod=0)
 
void cachePixelImage (const String &imageName, const uint8_t *bytes, int width, int height, const String &color="", char compressionMethod=0)
 cache single-bit "pixel" image (i.e. B&W image); not saved
 
void cachePixelImage16 (const String &imageName, const uint16_t *data, int width, int height, const String &options="", char compressMethod=0)
 cache 16-bit "pixel" image (i.e. 565 RGB image); not saved
 
void cachePixelImageGS (const String &imageName, const uint8_t *data, int width, int height, const String &options="", char compressMethod=0)
 cache grayscale "pixel" image; as if image saved and loaded
 
void saveCachedImageFile (const String &imageName, const String &asImageName="")
 
void saveCachedImageFileAsync (const String &imageName, const String &asImageName="")
 
void saveCachedImageFiles (const String &stitchAsImageName="")
 
- Public Member Functions inherited from MultiLevelDDLayer
void addLevel (const String &levelId, float width=0, float height=0, bool switchToIt=false)
 
void addLevel (const String &levelId, bool switchToIt)
 another version of addLevel()
 
void switchLevel (const String &levelId, bool addIfMissing=true)
 
void pushLevel ()
 push the current level onto the level stack, to be pop with popLevel()
 
void pushLevelAndSwitchTo (const String &switchTolevelId, bool addIfMissing=true)
 
void popLevel ()
 pop a level from the level stack and make it the current level
 
void levelOpacity (int opacity)
 
void levelTransparent (bool transparent)
 set whether level is transparent
 
void setLevelAnchor (float x, float y, long reachInMillis=0)
 set the anchor of the level; note that level anchor is the top-left corner of the level "opening"
 
void moveLevelAnchorBy (float byX, float byY, long reachInMillis=0)
 move the level anchor
 
void registerLevelBackground (const String &backgroundId, const String &backgroundImageName, const String &drawBackgroundOptions="")
 
void setLevelBackground (const String &backgroundId, const String &backgroundImageName="", const String &drawBackgroundOptions="")
 
void setLevelNoBackground ()
 set that the current level uses no background image
 
void animateLevelBackground (int fps, bool reset=true, const String &options="")
 
void stopAnimateLevelBackground (bool reset=true)
 
void reorderLevel (const String &levelId, const String &how)
 
void exportLevelsAsImage (const String &imageFileName, bool cacheItNotSave=false)
 export (and save) the levels as an image (without the decorations of the layer like border)
 
void deleteLevel (const String &levelId)
 delete the specified level
 
- Public Member Functions inherited from DDLayer
void border (float size, const String &color, const String &shape="flat", float extraSize=0)
 
void noBorder ()
 
void padding (float size)
 
void padding (float left, float top, float right, float bottom)
 
void noPadding ()
 
void margin (float size)
 
void margin (float left, float top, float right, float bottom)
 
void noMargin ()
 
void backgroundColor (const String &color, int opacity=100)
 
void noBackgroundColor ()
 
void visible (bool visible)
 
void transparent (bool transparent)
 
void disabled (bool disabled=true)
 
void opacity (int opacity)
 
void alpha (int alpha)
 
void blend (const String &color, int alpha=255, const String &mode="darken")
 
void noblend ()
 
void clear ()
 clear the layer
 
void flash ()
 normally used for "feedback" – flash the default way (layer + border)
 
void flashArea (int x, int y)
 normally used for "feedback" – flash the area (x, y) where the layer is clicked
 
void explicitFeedback (int16_t x=0, int16_t y=0, const String &text="", DDFeedbackType type=CLICK, const String &option="")
 
const String & getLayerId () const
 
void setFeedbackHandler (DDFeedbackHandler handler, const String &autoFeedbackMethod="", const String &allowFeedbackTypes="")
 
void enableFeedback (const String &autoFeedbackMethod="", const String &allowFeedbackTypes="")
 
void disableFeedback ()
 disable "feedback"
 
const DDFeedbackgetFeedback ()
 
void debugOnly (int i)
 for debug use
 
DDFeedbackManager * getFeedbackManager () const
 
DDFeedbackHandler getFeedbackHandler () const
 

Additional Inherited Members

- Public Attributes inherited from DDObject
int8_t objectType
 object type – DD_OBJECT_TYPE_LAYER or DD_OBJECT_TYPE_TUNNEL
 
String customData
 custom data
 
- Protected Member Functions inherited from MultiLevelDDLayer
 MultiLevelDDLayer (int8_t layerId)
 
- Protected Member Functions inherited from DDLayer
 DDLayer (int8_t layerId)
 
void _enableFeedback ()
 
- Protected Attributes inherited from DDLayer
String layerId
 
DDFeedbackManager * pFeedbackManager
 
DDFeedbackHandler feedbackHandler
 

Detailed Description

Class for graphical LCD layer; created with DumbDisplay::createGraphicalLayer()

Member Function Documentation

◆ centeredPolygon()

void GraphicalDDLayer::centeredPolygon ( int  radius,
int  vertexCount,
bool  inside = false 
)

draw polygon "enclosed" in an imaginary centered circle

Parameters
radiuscircle radius
vertexCountnumber of vertices
insidewhether inside the imaginary circle or outside of it

◆ drawArc()

void GraphicalDDLayer::drawArc ( int  x,
int  y,
int  w,
int  h,
int  startAngle,
int  sweepAngle,
bool  useCenter,
const String &  color = "",
bool  filled = false 
)

draw an arc

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color

◆ drawChar()

void GraphicalDDLayer::drawChar ( int  x,
int  y,
char  c,
const String &  color = "",
const String &  bgColor = "",
int  size = 0 
)

draw char

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color
backgroundColorDD_RGB_COLOR(...) or common color name; empty background color means no background color
size0 means default

◆ drawCircle()

void GraphicalDDLayer::drawCircle ( int  x,
int  y,
int  r,
const String &  color = "",
bool  filled = false 
)

draw a circle

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color

◆ drawImageFile()

void GraphicalDDLayer::drawImageFile ( const String &  imageFileName,
int  x = 0,
int  y = 0,
int  w = 0,
int  h = 0,
const String &  options = "" 
)

draw image file in cache (if not already loaded to cache, load it)

Parameters
x,yposition of the left-top corner
w,himage size to scale to; if both 0, will not scale, if any 0, will scale keeping aspect ratio

◆ drawImageFileFit()

void GraphicalDDLayer::drawImageFileFit ( const String &  imageFileName,
int  x = 0,
int  y = 0,
int  w = 0,
int  h = 0,
const String &  options = "" 
)

draw image file in cache (if not already loaded to cache, load it)

Parameters
x,y,w,hrect to draw the image; 0 means the default value
options(e.g. "LB"): left align "L"; right align "R"; top align "T"; bottom align "B"; default to fit centered

◆ drawImageFileScaled()

void GraphicalDDLayer::drawImageFileScaled ( const String &  imageFileName,
int  w,
int  h,
const String &  options = "" 
)
inline

draw image file in cache scaled, like calling drawImageFile(imageFileName, 0, 0, w, h, options) with w and h

See also
drawImageFile()

◆ drawLine()

void GraphicalDDLayer::drawLine ( int  x1,
int  y1,
int  x2,
int  y2,
const String &  color = "" 
)

draw a line

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color

◆ drawOval()

void GraphicalDDLayer::drawOval ( int  x,
int  y,
int  w,
int  h,
const String &  color = "",
bool  filled = false 
)

draw an ellipse (oval)

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color

◆ drawPixel()

void GraphicalDDLayer::drawPixel ( int  x,
int  y,
const String &  color = "" 
)

draw a pixel

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color

◆ drawRect()

void GraphicalDDLayer::drawRect ( int  x,
int  y,
int  w,
int  h,
const String &  color = "",
bool  filled = false 
)

draw a rectangle

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color

◆ drawRoundRect()

void GraphicalDDLayer::drawRoundRect ( int  x,
int  y,
int  w,
int  h,
int  r,
const String &  color = "",
bool  filled = false 
)

draw a rounded rectangle

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color

◆ drawStr()

void GraphicalDDLayer::drawStr ( int  x,
int  y,
const String &  string,
const String &  color = "",
const String &  bgColor = "",
int  size = 0 
)

draw string

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color
backgroundColorDD_RGB_COLOR(...) or common color name; empty background color means no background color
size0 means default

◆ drawTextLine()

void GraphicalDDLayer::drawTextLine ( const String &  text,
int  y,
const String &  align = "L",
const String &  color = "",
const String &  bgColor = "",
int  size = 0 
)

similar to drawStr(), but draw string as a text line at (0, y) with alignment option

Parameters
align'L', 'C', or 'R'

◆ drawTriangle()

void GraphicalDDLayer::drawTriangle ( int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3,
const String &  color = "",
bool  filled = false 
)

draw a triangle

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color

◆ fillArc()

void GraphicalDDLayer::fillArc ( int  x,
int  y,
int  w,
int  h,
int  startAngle,
int  sweepAngle,
bool  useCenter,
const String &  color = "" 
)
inline

draw filled arc

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color

◆ fillCircle()

void GraphicalDDLayer::fillCircle ( int  x,
int  y,
int  r,
const String &  color = "" 
)
inline
Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color

◆ fillColor()

void GraphicalDDLayer::fillColor ( const String &  color)

set fill color (for shape)

Parameters
colorDD_COLOR_XXX; DD_RGB_COLOR(...); can also be common "color name"

◆ fillOval()

void GraphicalDDLayer::fillOval ( int  x,
int  y,
int  w,
int  h,
const String &  color = "" 
)
inline

draw filled ellipse (oval)

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color

◆ fillRect()

void GraphicalDDLayer::fillRect ( int  x,
int  y,
int  w,
int  h,
const String &  color = "" 
)
inline

draw filled rectangle

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color

◆ fillRoundRect()

void GraphicalDDLayer::fillRoundRect ( int  x,
int  y,
int  w,
int  h,
int  r,
const String &  color = "" 
)
inline

draw filled rounded rectangle

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color

◆ fillScreen()

void GraphicalDDLayer::fillScreen ( const String &  color)

fill screen with color

Parameters
colorDD_COLOR_XXX; DD_RGB_COLOR(...); can also be common "color name"

◆ fillTriangle()

void GraphicalDDLayer::fillTriangle ( int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3,
const String &  color = "" 
)
inline

draw filled triangle

Parameters
colorDD_RGB_COLOR(...) or common color name; empty color means text color

◆ loadImageFile()

void GraphicalDDLayer::loadImageFile ( const String &  imageFileName,
int  w = 0,
int  h = 0,
const String &  asImageFileName = "" 
)

load image file to cache

Parameters
w,himage size to scale to; if both 0, will not scale, if any 0, will scale keeping aspect ratio
asImageFileNamebetter provide a different name for the scaled cached

◆ loadImageFileScaled()

void GraphicalDDLayer::loadImageFileScaled ( const String &  imageFileName,
int  w,
int  h,
const String &  asImageFileName 
)
inline

load image file to cache cropped

Parameters
x,y,w,hrect to crop the image
asImageFileNamesince image cropped, should provide a different name for the scaled cached

see loadImageFile()

◆ penColor()

void GraphicalDDLayer::penColor ( const String &  color)

set pen color (i.e. text color)

Parameters
colorDD_COLOR_XXX; DD_RGB_COLOR(...); can also be common "color name"

◆ saveCachedImageFile()

void GraphicalDDLayer::saveCachedImageFile ( const String &  imageName,
const String &  asImageName = "" 
)

saved cached image

Parameters
imageNamecachedImageName

◆ saveCachedImageFileAsync()

void GraphicalDDLayer::saveCachedImageFileAsync ( const String &  imageName,
const String &  asImageName = "" 
)

saved cached image (async / non-blocking)

Parameters
imageNamecachedImageName

◆ saveCachedImageFiles()

void GraphicalDDLayer::saveCachedImageFiles ( const String &  stitchAsImageName = "")

saved cached image

Parameters
stitchAsImageNameif not empty, will stitch all cached images to one image file of the given name

◆ setTextColor()

void GraphicalDDLayer::setTextColor ( const String &  color,
const String &  bgColor = "" 
)

set text color and text background color

Parameters
colorDD_COLOR_XXX; DD_RGB_COLOR(...); can also be common "color name"
bgColorempty background color means no background color

◆ setTextFont() [1/2]

void GraphicalDDLayer::setTextFont ( const String &  fontName)

set font

Parameters
fontNameempty means default
textSize0 means default

◆ setTextFont() [2/2]

void GraphicalDDLayer::setTextFont ( const String &  fontName,
int  textSize 
)
inline

◆ write()

void GraphicalDDLayer::write ( const String &  text,
bool  draw = false 
)

write text; will not auto wrap

Parameters
drawmeans draw the text (in the heading direction)