GUIslice  0.16.0
Embedded GUI in C
GUIslice_drv_m5stack.h File Reference

GUIslice library (driver layer for M5stack) More...

#include "GUIslice.h"
#include <stdio.h>
Include dependency graph for GUIslice_drv_m5stack.h:

Go to the source code of this file.

Data Structures

struct  gslc_tsDriver
 

Macros

#define DRV_HAS_DRAW_POINT
 Support gslc_DrvDrawPoint() More...
 
#define DRV_HAS_DRAW_POINTS
 Support gslc_DrvDrawPoints() More...
 
#define DRV_HAS_DRAW_LINE
 Support gslc_DrvDrawLine() More...
 
#define DRV_HAS_DRAW_RECT_FRAME
 Support gslc_DrvDrawFrameRect() More...
 
#define DRV_HAS_DRAW_RECT_FILL
 Support gslc_DrvDrawFillRect() More...
 
#define DRV_HAS_DRAW_RECT_ROUND_FRAME
 Support gslc_DrvDrawFrameRoundRect() More...
 
#define DRV_HAS_DRAW_RECT_ROUND_FILL
 Support gslc_DrvDrawFillRoundRect() More...
 
#define DRV_HAS_DRAW_CIRCLE_FRAME
 Support gslc_DrvDrawFrameCircle() More...
 
#define DRV_HAS_DRAW_CIRCLE_FILL
 Support gslc_DrvDrawFillCircle() More...
 
#define DRV_HAS_DRAW_TRI_FRAME
 Support gslc_DrvDrawFrameTriangle() More...
 
#define DRV_HAS_DRAW_TRI_FILL
 Support gslc_DrvDrawFillTriangle() More...
 
#define DRV_HAS_DRAW_TEXT
 Support gslc_DrvDrawTxt() More...
 
#define DRV_HAS_DRAW_BMP_MEM
 Support gslc_DrvDrawBmp24FromMem() More...
 
#define DRV_OVERRIDE_TXT_ALIGN
 Driver provides text alignment. More...
 

Functions

bool gslc_DrvInit (gslc_tsGui *pGui)
 Initialize the SDL library. More...
 
bool gslc_DrvInitTs (gslc_tsGui *pGui, const char *acDev)
 Perform any touchscreen-specific initialization. More...
 
void gslc_DrvDestruct (gslc_tsGui *pGui)
 Free up any members associated with the driver. More...
 
const char * gslc_DrvGetNameDisp (gslc_tsGui *pGui)
 Get the display driver name. More...
 
const char * gslc_DrvGetNameTouch (gslc_tsGui *pGui)
 Get the touch driver name. More...
 
void * gslc_DrvGetDriverDisp (gslc_tsGui *pGui)
 Get the native display driver instance. More...
 
void * gslc_DrvGetDriverTouch (gslc_tsGui *pGui)
 Get the native touch driver instance. More...
 
void * gslc_DrvLoadImage (gslc_tsGui *pGui, gslc_tsImgRef sImgRef)
 Load a bitmap (*.bmp) and create a new image resource. More...
 
bool gslc_DrvSetBkgndImage (gslc_tsGui *pGui, gslc_tsImgRef sImgRef)
 Configure the background to use a bitmap image. More...
 
bool gslc_DrvSetBkgndColor (gslc_tsGui *pGui, gslc_tsColor nCol)
 Configure the background to use a solid color. More...
 
bool gslc_DrvSetElemImageNorm (gslc_tsGui *pGui, gslc_tsElem *pElem, gslc_tsImgRef sImgRef)
 Set an element's normal-state image. More...
 
bool gslc_DrvSetElemImageGlow (gslc_tsGui *pGui, gslc_tsElem *pElem, gslc_tsImgRef sImgRef)
 Set an element's glow-state image. More...
 
void gslc_DrvImageDestruct (void *pvImg)
 Release an image surface. More...
 
bool gslc_DrvSetClipRect (gslc_tsGui *pGui, gslc_tsRect *pRect)
 Set the clipping rectangle for future drawing updates. More...
 
const void * gslc_DrvFontAdd (gslc_teFontRefType eFontRefType, const void *pvFontRef, uint16_t nFontSz)
 Load a font from a resource and return pointer to it. More...
 
void gslc_DrvFontsDestruct (gslc_tsGui *pGui)
 Release all fonts defined in the GUI. More...
 
bool gslc_DrvGetTxtSize (gslc_tsGui *pGui, gslc_tsFont *pFont, const char *pStr, gslc_teTxtFlags eTxtFlags, int16_t *pnTxtX, int16_t *pnTxtY, uint16_t *pnTxtSzW, uint16_t *pnTxtSzH)
 Get the extent (width and height) of a text string. More...
 
bool gslc_DrvDrawTxt (gslc_tsGui *pGui, int16_t nTxtX, int16_t nTxtY, gslc_tsFont *pFont, const char *pStr, gslc_teTxtFlags eTxtFlags, gslc_tsColor colTxt, gslc_tsColor colBg)
 Draw a text string at the given coordinate. More...
 
bool gslc_DrvDrawTxtAlign (gslc_tsGui *pGui, int16_t nX0, int16_t nY0, int16_t nX1, int16_t nY1, int8_t eTxtAlign, gslc_tsFont *pFont, const char *pStr, gslc_teTxtFlags eTxtFlags, gslc_tsColor colTxt, gslc_tsColor colBg)
 Draw a text string in a bounding box using the specified alignment. More...
 
void gslc_DrvPageFlipNow (gslc_tsGui *pGui)
 Force a page flip to occur. More...
 
bool gslc_DrvDrawPoint (gslc_tsGui *pGui, int16_t nX, int16_t nY, gslc_tsColor nCol)
 Draw a point. More...
 
bool gslc_DrvDrawPoints (gslc_tsGui *pGui, gslc_tsPt *asPt, uint16_t nNumPt, gslc_tsColor nCol)
 Draw a point. More...
 
bool gslc_DrvDrawFrameRect (gslc_tsGui *pGui, gslc_tsRect rRect, gslc_tsColor nCol)
 Draw a framed rectangle. More...
 
bool gslc_DrvDrawFillRect (gslc_tsGui *pGui, gslc_tsRect rRect, gslc_tsColor nCol)
 Draw a filled rectangle. More...
 
bool gslc_DrvDrawFrameRoundRect (gslc_tsGui *pGui, gslc_tsRect rRect, int16_t nRadius, gslc_tsColor nCol)
 Draw a framed rounded rectangle. More...
 
bool gslc_DrvDrawFillRoundRect (gslc_tsGui *pGui, gslc_tsRect rRect, int16_t nRadius, gslc_tsColor nCol)
 Draw a filled rounded rectangle. More...
 
bool gslc_DrvDrawLine (gslc_tsGui *pGui, int16_t nX0, int16_t nY0, int16_t nX1, int16_t nY1, gslc_tsColor nCol)
 Draw a line. More...
 
bool gslc_DrvDrawFrameCircle (gslc_tsGui *pGui, int16_t nMidX, int16_t nMidY, uint16_t nRadius, gslc_tsColor nCol)
 Draw a framed circle. More...
 
bool gslc_DrvDrawFillCircle (gslc_tsGui *pGui, int16_t nMidX, int16_t nMidY, uint16_t nRadius, gslc_tsColor nCol)
 Draw a filled circle. More...
 
bool gslc_DrvDrawFrameTriangle (gslc_tsGui *pGui, int16_t nX0, int16_t nY0, int16_t nX1, int16_t nY1, int16_t nX2, int16_t nY2, gslc_tsColor nCol)
 Draw a framed triangle. More...
 
bool gslc_DrvDrawFillTriangle (gslc_tsGui *pGui, int16_t nX0, int16_t nY0, int16_t nX1, int16_t nY1, int16_t nX2, int16_t nY2, gslc_tsColor nCol)
 Draw a filled triangle. More...
 
bool gslc_DrvDrawImage (gslc_tsGui *pGui, int16_t nDstX, int16_t nDstY, gslc_tsImgRef sImgRef)
 Copy all of source image to destination screen at specified coordinate. More...
 
void gslc_DrvDrawMonoFromMem (gslc_tsGui *pGui, int16_t nDstX, int16_t nDstY, const unsigned char *pBitmap, bool bProgMem)
 Draw a monochrome bitmap from a memory array. More...
 
void gslc_DrvDrawBmp24FromMem (gslc_tsGui *pGui, int16_t nDstX, int16_t nDstY, const unsigned char *pBitmap, bool bProgMem)
 Draw a color 24-bit depth bitmap from a memory array. More...
 
void gslc_DrvDrawBkgnd (gslc_tsGui *pGui)
 Copy the background image to destination screen. More...
 
bool gslc_DrvRotate (gslc_tsGui *pGui, uint8_t nRotation)
 Change rotation, automatically adapt touchscreen axes swap/flip. More...
 
uint16_t gslc_DrvAdaptColorToRaw (gslc_tsColor nCol)
 

Variables

const char GSLC_PMEM ERRSTR_NULL []
 
const char GSLC_PMEM ERRSTR_PXD_NULL []
 

Detailed Description

GUIslice library (driver layer for M5stack)

Macro Definition Documentation

#define DRV_HAS_DRAW_BMP_MEM
#define DRV_HAS_DRAW_CIRCLE_FILL
#define DRV_HAS_DRAW_CIRCLE_FRAME
#define DRV_HAS_DRAW_LINE
#define DRV_HAS_DRAW_POINT
#define DRV_HAS_DRAW_POINTS
#define DRV_HAS_DRAW_RECT_FILL
#define DRV_HAS_DRAW_RECT_FRAME
#define DRV_HAS_DRAW_RECT_ROUND_FILL
#define DRV_HAS_DRAW_RECT_ROUND_FRAME
#define DRV_HAS_DRAW_TEXT
#define DRV_HAS_DRAW_TRI_FILL
#define DRV_HAS_DRAW_TRI_FRAME
#define DRV_OVERRIDE_TXT_ALIGN

Driver provides text alignment.

Function Documentation

uint16_t gslc_DrvAdaptColorToRaw ( gslc_tsColor  nCol)
void gslc_DrvDestruct ( gslc_tsGui pGui)

Free up any members associated with the driver.

  • Eg. renderers, windows, background surfaces, etc.
Parameters
[in]pGuiPointer to GUI
Returns
none
void gslc_DrvDrawBkgnd ( gslc_tsGui pGui)

Copy the background image to destination screen.

Parameters
[in]pGuiPointer to GUI
Returns
true if success, false if fail
void gslc_DrvDrawBmp24FromMem ( gslc_tsGui pGui,
int16_t  nDstX,
int16_t  nDstY,
const unsigned char *  pBitmap,
bool  bProgMem 
)

Draw a color 24-bit depth bitmap from a memory array.

Parameters
[in]pGuiPointer to GUI
[in]nDstXX coord for copy
[in]nDstYY coord for copy
[in]pBitmapPointer to bitmap buffer
[in]bProgMemBitmap is stored in Flash if true, RAM otherwise
Returns
none
bool gslc_DrvDrawFillCircle ( gslc_tsGui pGui,
int16_t  nMidX,
int16_t  nMidY,
uint16_t  nRadius,
gslc_tsColor  nCol 
)

Draw a filled circle.

Parameters
[in]pGuiPointer to GUI
[in]nMidXCenter of circle (X coordinate)
[in]nMidYCenter of circle (Y coordinate)
[in]nRadiusRadius of circle
[in]nColColor RGB value to fill
Returns
true if success, false if error
bool gslc_DrvDrawFillRect ( gslc_tsGui pGui,
gslc_tsRect  rRect,
gslc_tsColor  nCol 
)

Draw a filled rectangle.

Parameters
[in]pGuiPointer to GUI
[in]rRectRectangular region to fill
[in]nColColor RGB value to fill
Returns
true if success, false if error
bool gslc_DrvDrawFillRoundRect ( gslc_tsGui pGui,
gslc_tsRect  rRect,
int16_t  nRadius,
gslc_tsColor  nCol 
)

Draw a filled rounded rectangle.

Parameters
[in]pGuiPointer to GUI
[in]rRectRectangular region to fill
[in]nRadiusRadius for rounded corners
[in]nColColor RGB value to fill
Returns
true if success, false if error
bool gslc_DrvDrawFillTriangle ( gslc_tsGui pGui,
int16_t  nX0,
int16_t  nY0,
int16_t  nX1,
int16_t  nY1,
int16_t  nX2,
int16_t  nY2,
gslc_tsColor  nCol 
)

Draw a filled triangle.

Parameters
[in]pGuiPointer to GUI
[in]nX0X Coordinate #1
[in]nY0Y Coordinate #1
[in]nX1X Coordinate #2
[in]nY1Y Coordinate #2
[in]nX2X Coordinate #3
[in]nY2Y Coordinate #3
[in]nColColor RGB value to fill
Returns
true if success, false if error
bool gslc_DrvDrawFrameCircle ( gslc_tsGui pGui,
int16_t  nMidX,
int16_t  nMidY,
uint16_t  nRadius,
gslc_tsColor  nCol 
)

Draw a framed circle.

Parameters
[in]pGuiPointer to GUI
[in]nMidXCenter of circle (X coordinate)
[in]nMidYCenter of circle (Y coordinate)
[in]nRadiusRadius of circle
[in]nColColor RGB value to frame
Returns
true if success, false if error
bool gslc_DrvDrawFrameRect ( gslc_tsGui pGui,
gslc_tsRect  rRect,
gslc_tsColor  nCol 
)

Draw a framed rectangle.

Parameters
[in]pGuiPointer to GUI
[in]rRectRectangular region to frame
[in]nColColor RGB value to frame
Returns
true if success, false if error
bool gslc_DrvDrawFrameRoundRect ( gslc_tsGui pGui,
gslc_tsRect  rRect,
int16_t  nRadius,
gslc_tsColor  nCol 
)

Draw a framed rounded rectangle.

Parameters
[in]pGuiPointer to GUI
[in]rRectRectangular region to frame
[in]nRadiusRadius for rounded corners
[in]nColColor RGB value to frame
Returns
true if success, false if error
bool gslc_DrvDrawFrameTriangle ( gslc_tsGui pGui,
int16_t  nX0,
int16_t  nY0,
int16_t  nX1,
int16_t  nY1,
int16_t  nX2,
int16_t  nY2,
gslc_tsColor  nCol 
)

Draw a framed triangle.

Parameters
[in]pGuiPointer to GUI
[in]nX0X Coordinate #1
[in]nY0Y Coordinate #1
[in]nX1X Coordinate #2
[in]nY1Y Coordinate #2
[in]nX2X Coordinate #3
[in]nY2Y Coordinate #3
[in]nColColor RGB value to frame
Returns
true if success, false if error
bool gslc_DrvDrawImage ( gslc_tsGui pGui,
int16_t  nDstX,
int16_t  nDstY,
gslc_tsImgRef  sImgRef 
)

Copy all of source image to destination screen at specified coordinate.

Parameters
[in]pGuiPointer to GUI
[in]nDstXDestination X coord for copy
[in]nDstYDestination Y coord for copy
[in]sImgRefImage reference
Returns
true if success, false if fail
bool gslc_DrvDrawLine ( gslc_tsGui pGui,
int16_t  nX0,
int16_t  nY0,
int16_t  nX1,
int16_t  nY1,
gslc_tsColor  nCol 
)

Draw a line.

Parameters
[in]pGuiPointer to GUI
[in]nX0Line start (X coordinate)
[in]nY0Line start (Y coordinate)
[in]nX1Line finish (X coordinate)
[in]nY1Line finish (Y coordinate)
[in]nColColor RGB value to draw
Returns
true if success, false if error
void gslc_DrvDrawMonoFromMem ( gslc_tsGui pGui,
int16_t  nDstX,
int16_t  nDstY,
const unsigned char *  pBitmap,
bool  bProgMem 
)

Draw a monochrome bitmap from a memory array.

  • Draw from the bitmap buffer using the foreground color defined in the header (unset bits are transparent)
Parameters
[in]pGuiPointer to GUI
[in]nDstXDestination X coord for copy
[in]nDstYDestination Y coord for copy
[in]pBitmapPointer to bitmap buffer
[in]bProgMemBitmap is stored in Flash if true, RAM otherwise
Returns
none
bool gslc_DrvDrawPoint ( gslc_tsGui pGui,
int16_t  nX,
int16_t  nY,
gslc_tsColor  nCol 
)

Draw a point.

Parameters
[in]pGuiPointer to GUI
[in]nXX coordinate of point
[in]nYY coordinate of point
[in]nColColor RGB value to draw
Returns
true if success, false if error
bool gslc_DrvDrawPoints ( gslc_tsGui pGui,
gslc_tsPt asPt,
uint16_t  nNumPt,
gslc_tsColor  nCol 
)

Draw a point.

Parameters
[in]pGuiPointer to GUI
[in]asPtArray of points to draw
[in]nNumPtNumber of points in array
[in]nColColor RGB value to draw
Returns
true if success, false if error
bool gslc_DrvDrawTxt ( gslc_tsGui pGui,
int16_t  nTxtX,
int16_t  nTxtY,
gslc_tsFont pFont,
const char *  pStr,
gslc_teTxtFlags  eTxtFlags,
gslc_tsColor  colTxt,
gslc_tsColor  colBg 
)

Draw a text string at the given coordinate.

Parameters
[in]pGuiPointer to GUI
[in]nTxtXX coordinate of top-left text string
[in]nTxtYY coordinate of top-left text string
[in]pFontPtr to Font
[in]pStrString to display
[in]eTxtFlagsFlags associated with text string
[in]colTxtColor to draw text
[in]colBgunused in m5stack, defaults to black
Returns
true if success, false if failure
Parameters
[in]pGuiPointer to GUI
[in]nTxtXX coordinate of top-left text string
[in]nTxtYY coordinate of top-left text string
[in]pFontPtr to Font
[in]pStrString to display
[in]eTxtFlagsFlags associated with text string
[in]colTxtColor to draw text
[in]colBgunused in ADAGFX, defaults to black
Returns
true if success, false if failure
bool gslc_DrvDrawTxtAlign ( gslc_tsGui pGui,
int16_t  nX0,
int16_t  nY0,
int16_t  nX1,
int16_t  nY1,
int8_t  eTxtAlign,
gslc_tsFont pFont,
const char *  pStr,
gslc_teTxtFlags  eTxtFlags,
gslc_tsColor  colTxt,
gslc_tsColor  colBg 
)

Draw a text string in a bounding box using the specified alignment.

Parameters
[in]pGuiPointer to GUI
[in]nX0X coordinate of top-left of bounding box
[in]nY0Y coordinate of top-left of bounding box
[in]nX1X coordinate of bot-right of bounding box
[in]nY1Y coordinate of bot-right of bounding box
[in]eTxtAlignAlignment mode]
[in]pFontPtr to Font
[in]pStrString to display
[in]eTxtFlagsFlags associated with text string
[in]colTxtColor to draw text
[in]colBgunused in m5stack, defaults to black
Returns
true if success, false if failure
const void* gslc_DrvFontAdd ( gslc_teFontRefType  eFontRefType,
const void *  pvFontRef,
uint16_t  nFontSz 
)

Load a font from a resource and return pointer to it.

Parameters
[in]eFontRefTypeFont reference type (GSLC_FONTREF_PTR for Arduino)
[in]pvFontRefFont reference pointer (Pointer to the GFXFont array)
[in]nFontSzTypeface size to use
Returns
Void ptr to driver-specific font if load was successful, NULL otherwise
void gslc_DrvFontsDestruct ( gslc_tsGui pGui)

Release all fonts defined in the GUI.

Parameters
[in]pGuiPointer to GUI
Returns
none
void* gslc_DrvGetDriverDisp ( gslc_tsGui pGui)

Get the native display driver instance.

  • This can be useful to access special commands available in the selected driver.
Parameters
[in]pGuiPointer to GUI
Returns
Void pointer to the display driver instance. This pointer should be typecast to the particular driver being used. If no driver was created then this function will return NULL.
void* gslc_DrvGetDriverTouch ( gslc_tsGui pGui)

Get the native touch driver instance.

  • This can be useful to access special commands available in the selected driver.
Parameters
[in]pGuiPointer to GUI
Returns
Void pointer to the touch driver instance. This pointer should be typecast to the particular driver being used. If no driver was created then this function will return NULL.
const char* gslc_DrvGetNameDisp ( gslc_tsGui pGui)

Get the display driver name.

Parameters
[in]pGuiPointer to GUI
Returns
String containing driver name
const char* gslc_DrvGetNameTouch ( gslc_tsGui pGui)

Get the touch driver name.

Parameters
[in]pGuiPointer to GUI
Returns
String containing driver name
bool gslc_DrvGetTxtSize ( gslc_tsGui pGui,
gslc_tsFont pFont,
const char *  pStr,
gslc_teTxtFlags  eTxtFlags,
int16_t *  pnTxtX,
int16_t *  pnTxtY,
uint16_t *  pnTxtSzW,
uint16_t *  pnTxtSzH 
)

Get the extent (width and height) of a text string.

Parameters
[in]pGuiPointer to GUI
[in]pFontPtr to Font structure
[in]pStrString to display
[in]eTxtFlagsFlags associated with text string
[out]pnTxtXPtr to offset X of text
[out]pnTxtYPtr to offset Y of text
[out]pnTxtSzWPtr to width of text
[out]pnTxtSzHPtr to height of text
Returns
true if success, false if failure
void gslc_DrvImageDestruct ( void *  pvImg)

Release an image surface.

Parameters
[in]pvImgVoid ptr to image
Returns
none
bool gslc_DrvInit ( gslc_tsGui pGui)

Initialize the SDL library.

  • Performs clean startup workaround (if enabled)
  • Configures video mode
  • Initializes font support

PRE:

  • The environment variables should be configured before calling gslc_DrvInit(). This can be done with gslc_DrvInitEnv() or manually in user function.
Parameters
[in]pGuiPointer to GUI
Returns
true if success, false if fail
bool gslc_DrvInitTs ( gslc_tsGui pGui,
const char *  acDev 
)

Perform any touchscreen-specific initialization.

Parameters
[in]pGuiPointer to GUI
[in]acDevDevice path to touchscreen eg. "/dev/input/touchscreen"
Returns
true if successful
void* gslc_DrvLoadImage ( gslc_tsGui pGui,
gslc_tsImgRef  sImgRef 
)

Load a bitmap (*.bmp) and create a new image resource.

Transparency is enabled by GSLC_BMP_TRANS_EN through use of color (GSLC_BMP_TRANS_RGB).

Parameters
[in]pGuiPointer to GUI
[in]sImgRefImage reference
Returns
Image pointer (surface/texture) or NULL if error
void gslc_DrvPageFlipNow ( gslc_tsGui pGui)

Force a page flip to occur.

This generally copies active screen surface to the display.

Parameters
[in]pGuiPointer to GUI
Returns
none
bool gslc_DrvRotate ( gslc_tsGui pGui,
uint8_t  nRotation 
)

Change rotation, automatically adapt touchscreen axes swap/flip.

Parameters
[in]pGuiPointer to GUI
[in]nRotationScreen Rotation value (0, 1, 2 or 3)
Returns
true if successful

Change rotation, automatically adapt touchscreen axes swap/flip.

bool gslc_DrvSetBkgndColor ( gslc_tsGui pGui,
gslc_tsColor  nCol 
)

Configure the background to use a solid color.

  • The background is used when redrawing the entire page
Parameters
[in]pGuiPointer to GUI
[in]nColRGB Color to use
Returns
true if success, false if fail
bool gslc_DrvSetBkgndImage ( gslc_tsGui pGui,
gslc_tsImgRef  sImgRef 
)

Configure the background to use a bitmap image.

  • The background is used when redrawing the entire page
Parameters
[in]pGuiPointer to GUI
[in]sImgRefImage reference
Returns
true if success, false if fail
bool gslc_DrvSetClipRect ( gslc_tsGui pGui,
gslc_tsRect pRect 
)

Set the clipping rectangle for future drawing updates.

Parameters
[in]pGuiPointer to GUI
[in]pRectRectangular region to constrain edits
Returns
true if success, false if error
bool gslc_DrvSetElemImageGlow ( gslc_tsGui pGui,
gslc_tsElem pElem,
gslc_tsImgRef  sImgRef 
)

Set an element's glow-state image.

Parameters
[in]pGuiPointer to GUI
[in]pElemPointer to Element to update
[in]sImgRefImage reference
Returns
true if success, false if error
bool gslc_DrvSetElemImageNorm ( gslc_tsGui pGui,
gslc_tsElem pElem,
gslc_tsImgRef  sImgRef 
)

Set an element's normal-state image.

Parameters
[in]pGuiPointer to GUI
[in]pElemPointer to Element to update
[in]sImgRefImage reference
Returns
true if success, false if error

Variable Documentation

const char GSLC_PMEM ERRSTR_NULL[]
const char GSLC_PMEM ERRSTR_PXD_NULL[]