Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion configs/esp-shld-m5stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ extern "C" {
// RAM and flash memory which could be problematic for Arduino models
// with limited resources.
#define GSLC_SD_EN 0
#define GSLC_FS_EN 1



// =============================================================================
Expand Down Expand Up @@ -176,7 +178,7 @@ extern "C" {

// Enable support for graphics clipping (DrvSetClipRect)
// - Note that this will impact performance of drawing graphics primitives
#define GSLC_CLIP_EN 1
#define GSLC_CLIP_EN 0

// Enable for bitmap transparency and definition of color to use
#define GSLC_BMP_TRANS_EN 1 // 1 = enabled, 0 = disabled
Expand Down
11 changes: 11 additions & 0 deletions src/GUIslice.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,17 @@ gslc_tsImgRef gslc_GetImageFromFile(const char* pFname,gslc_teImgRefFlags eFmt)
return sImgRef;
}


gslc_tsImgRef gslc_GetImageFromFS(const char* pFname,gslc_teImgRefFlags eFmt)
{
gslc_tsImgRef sImgRef;
sImgRef.eImgFlags = GSLC_IMGREF_SRC_FS | (GSLC_IMGREF_FMT & eFmt);
sImgRef.pFname = pFname;
sImgRef.pImgBuf = NULL;
sImgRef.pvImgRaw = NULL;
return sImgRef;
}

gslc_tsImgRef gslc_GetImageFromSD(const char* pFname,gslc_teImgRefFlags eFmt)
{
gslc_tsImgRef sImgRef;
Expand Down
15 changes: 15 additions & 0 deletions src/GUIslice.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,12 +461,16 @@ typedef enum {
GSLC_IMGREF_SRC_SD = (2<<0), ///< Image is stored on SD card
GSLC_IMGREF_SRC_RAM = (3<<0), ///< Image is stored in RAM
GSLC_IMGREF_SRC_PROG = (4<<0), ///< Image is stored in program memory (PROGMEM)
GSLC_IMGREF_SRC_FS = (5<<0), ///< Image is stored in Filesystem (ESP32 SPIFFS)

// Define image types

GSLC_IMGREF_FMT_BMP24 = (1<<4), ///< Image format is BMP (24-bit)
GSLC_IMGREF_FMT_BMP16 = (2<<4), ///< Image format is BMP (16-bit RGB565)
GSLC_IMGREF_FMT_RAW1 = (3<<4), ///< Image format is raw monochrome (1-bit)
GSLC_IMGREF_FMT_JPG = (4<<4), ///< Image format is JPG (ESP32/ESP8366)
GSLC_IMGREF_FMT_PNG = (5<<4), ///< Image format is PNG (ESP32/ESP8366)


// Mask values for bitfield comparisons
GSLC_IMGREF_SRC = (7<<0), ///< Mask for Source flags
Expand Down Expand Up @@ -1224,6 +1228,17 @@ bool gslc_ClipRect(gslc_tsRect* pClipRect,gslc_tsRect* pRect);
gslc_tsImgRef gslc_GetImageFromFile(const char* pFname,gslc_teImgRefFlags eFmt);


///
/// Create an image from FS
///
/// \param[in] pFname Pointer to filename string of image
/// \param[in] eFmt Image format
///
/// \return Loaded image reference
///
gslc_tsImgRef gslc_GetImageFromFS(const char* pFname,gslc_teImgRefFlags eFmt);


///
/// Create an image reference to a bitmap file in SD card
///
Expand Down
26 changes: 26 additions & 0 deletions src/GUIslice_drv_m5stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ bool gslc_DrvInit(gslc_tsGui* pGui)
// - It also configures the serial interface for 115200 baud
m5.begin();

#if (GSLC_FS_EN)
if(!SPIFFS.begin(true)){
Serial.println("SPIFFS Mount Failed");
}
#endif

// Now that we have initialized the display, we can assign
// the rotation parameters and clipping region
gslc_DrvRotate(pGui,GSLC_ROTATE);
Expand Down Expand Up @@ -845,6 +851,26 @@ bool gslc_DrvDrawImage(gslc_tsGui* pGui,int16_t nDstX,int16_t nDstY,gslc_tsImgRe
return false;
#endif

}
else if ((sImgRef.eImgFlags & GSLC_IMGREF_SRC) == GSLC_IMGREF_SRC_FS) {
// Load image from FS media
#if (GSLC_FS_EN)
if ((sImgRef.eImgFlags & GSLC_IMGREF_FMT) == GSLC_IMGREF_FMT_PNG) {
// 24-bit Bitmap
m_disp.drawPngFile(SPIFFS,sImgRef.pFname,nDstX,nDstY);
return true;
} else if((sImgRef.eImgFlags & GSLC_IMGREF_FMT) == GSLC_IMGREF_FMT_BMP24){
m_disp.drawBmpFile(SPIFFS,sImgRef.pFname,nDstX,nDstY);
} else {
// Unsupported format
return false;
}
#else
// SD card access not enabled
GSLC_DEBUG_PRINT("ERROR: GSLC_FS_EN not enabled\n","");
return false;
#endif

} else {
// Unsupported source
GSLC_DEBUG2_PRINT("DBG: DrvDrawImage() unsupported source eImgFlags=%d\n", sImgRef.eImgFlags);
Expand Down