SparkFun SSD168x Library  v1.0.2
Library for SSD1680 / SSD1681 e-paper displays on SPI
Loading...
Searching...
No Matches
SSD168xSPIBaseClass< DeviceType > Class Template Reference

The templated base class for all SSD168x SPI e-Paper displays. More...

#include <SparkFun_SSD168x_Library.h>

Inheritance diagram for SSD168xSPIBaseClass< DeviceType >:

Public Types

typedef SparkFun_SSD168x::sfe_print_t sfe_print_t
 The print type: Print on Arduino; SfeOutput on ESP-IDF. More...
 
typedef SparkFun_SSD168x::sfe_string_t sfe_string_t
 The string type: String on Arduino; std::string on ESP-IDF. More...
 

Public Member Functions

void disableDebugging (void)
 Turn off debug messages. More...
 
uint8_t getWidth (void)
 Get the width, in pixels, of the connected e-Paper device. More...
 
uint8_t getHeight (void)
 Get the height, in pixels, of the connected e-Paper device. More...
 
bool reset (void)
 Reset the system and the SSD168x back to an initial state. More...
 
void display (bool partial=false, bool dirtyOnly=true)
 Send any pending display updates to the connected SSD168x device and update the display. More...
 
void erase (void)
 Erase all graphics on the device, placing the display in a blank state. More...
 
void deepSleep (bool mode2=false)
 Put the SSD168x into deep sleep. More...
 
bool isBusy (void)
 Read the SSD168x BUSY pin. More...
 
void setFont (QwiicEpFont &theFont)
 Set the current font. The current font is used when calling the text() method on this device. More...
 
void setFont (const QwiicEpFont *theFont)
 Set the current font. The current font is used when calling the text() method on this device. More...
 
QwiicEpFont * getFont (void)
 Get the current font for the device. More...
 
sfe_string_t getFontName (void)
 Get the name of the current font for the device. More...
 
unsigned int getStringWidth (sfe_string_t &text)
 Get the width of the provided string, using the current font. More...
 
unsigned int getStringWidth (const char *text)
 Get the width of the provided string, using the current font. More...
 
unsigned int getStringHeight (sfe_string_t &text)
 Get the height of the provided string, using the current font. More...
 
unsigned int getStringHeight (const char *text)
 Get the height of the provided string, using the current font. More...
 
void setDrawMode (grEpRasterOp_t rop)
 Set the current draw mode. The draw mode determines how pixels are set on the screen during drawing operations. More...
 
grEpRasterOp_t getDrawMode (void)
 Get the current draw mode. The draw mode determines how pixels are set on the screen during drawing operations. More...
 
void pixel (uint8_t x, uint8_t y, uint8_t clr=COLOR_ON)
 Set the value of a pixel on the screen. More...
 
void line (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t clr=COLOR_ON)
 Draw a line on the screen. More...
 
void rectangle (uint8_t x0, uint8_t y0, uint8_t width, uint8_t height, uint8_t clr=COLOR_ON)
 Draw a rectangle on the screen. More...
 
void rectangleFill (uint8_t x0, uint8_t y0, uint8_t width, uint8_t height, uint8_t clr=COLOR_ON)
 Draw a filled rectangle on the screen. More...
 
void circle (uint8_t x0, uint8_t y0, uint8_t radius, uint8_t clr=COLOR_ON)
 Draw a circle on the screen. More...
 
void circleFill (uint8_t x0, uint8_t y0, uint8_t radius, uint8_t clr=COLOR_ON)
 Draw a filled circle on the screen. More...
 
void bitmap (uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t *pBitmap, uint8_t bmp_width, uint8_t bmp_height)
 Draw a bitmap on the screen. More...
 
void bitmap (uint8_t x0, uint8_t y0, uint8_t *pBitmap, uint8_t bmp_width, uint8_t bmp_height)
 Draw a bitmap on the screen. More...
 
void bitmap (uint8_t x0, uint8_t y0, QwiicEpBitmap &bitmap)
 Draw a bitmap object on the screen. More...
 
void text (uint8_t x0, uint8_t y0, const char *text, uint8_t clr=COLOR_ON)
 Draw a string on the screen using the current font. More...
 
void text (uint8_t x0, uint8_t y0, sfe_string_t &text, uint8_t clr=COLOR_ON)
 Draw a string on the screen using the current font. More...
 
void setCursor (uint8_t x, uint8_t y)
 Set the "cursor" position in the device. More...
 
void setColor (uint8_t clr)
 Set the current color of the system. This is used by the Arduino Print interface functionality. More...
 
uint8_t getColor (void)
 Get the current color of the system. This is used by the Arduino Print interface functionality. More...
 
virtual size_t write (uint8_t theChar)
 Write one character at the cursor position, using the current font and color. For the Arduino Print interface. More...
 

Protected Attributes

DeviceType m_device
 

Detailed Description

template<typename DeviceType>
class SSD168xSPIBaseClass< DeviceType >

The templated base class for all SSD168x SPI e-Paper displays.

Implements the Arduino Print interface (or SSD168xPrint on ESP-IDF), so print(), println() (and printf()) can be used to write text at the cursor position.

Template Parameters
DeviceTypeThe device driver class (e.g. SpiSsd1680_184x88).

Member Typedef Documentation

◆ sfe_print_t

template<typename DeviceType >
typedef SparkFun_SSD168x::sfe_print_t SSD168xSPIBaseClass< DeviceType >::sfe_print_t

The print type: Print on Arduino; SfeOutput on ESP-IDF.

◆ sfe_string_t

template<typename DeviceType >
typedef SparkFun_SSD168x::sfe_string_t SSD168xSPIBaseClass< DeviceType >::sfe_string_t

The string type: String on Arduino; std::string on ESP-IDF.

Member Function Documentation

◆ bitmap() [1/3]

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::bitmap ( uint8_t  x0,
uint8_t  y0,
QwiicEpBitmap &  bitmap 
)
inline

Draw a bitmap object on the screen.

Parameters
x0The X coordinate to place the bitmap - upper left corner.
y0The Y coordinate to place the bitmap - upper left corner.
bitmapA bitmap object (e.g. QW_EP_BMP_SPARKFUN).

◆ bitmap() [2/3]

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::bitmap ( uint8_t  x0,
uint8_t  y0,
uint8_t *  pBitmap,
uint8_t  bmp_width,
uint8_t  bmp_height 
)
inline

Draw a bitmap on the screen.

Parameters
x0The X coordinate to place the bitmap - upper left corner.
y0The Y coordinate to place the bitmap - upper left corner.
pBitmapA pointer to the bitmap array.
bmp_widthThe width of the bitmap.
bmp_heightThe height of the bitmap.

◆ bitmap() [3/3]

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::bitmap ( uint8_t  x0,
uint8_t  y0,
uint8_t  x1,
uint8_t  y1,
uint8_t *  pBitmap,
uint8_t  bmp_width,
uint8_t  bmp_height 
)
inline

Draw a bitmap on the screen.

Parameters
x0The X coordinate to place the bitmap - upper left corner.
y0The Y coordinate to place the bitmap - upper left corner.
x1The end X coordinate of the area to draw - lower right corner. Range will not exceed the bitmap width.
y1The end Y coordinate of the area to draw - lower right corner. Range will not exceed the bitmap height.
pBitmapA pointer to the bitmap array.
bmp_widthThe width of the bitmap.
bmp_heightThe height of the bitmap.

◆ circle()

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::circle ( uint8_t  x0,
uint8_t  y0,
uint8_t  radius,
uint8_t  clr = COLOR_ON 
)
inline

Draw a circle on the screen.

Parameters
x0The X coordinate of the circle center.
y0The Y coordinate of the circle center.
radiusThe radius of the circle.
clroptional. The color value to draw the circle. Defaults to COLOR_ON (black).

◆ circleFill()

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::circleFill ( uint8_t  x0,
uint8_t  y0,
uint8_t  radius,
uint8_t  clr = COLOR_ON 
)
inline

Draw a filled circle on the screen.

Parameters
x0The X coordinate of the circle center.
y0The Y coordinate of the circle center.
radiusThe radius of the circle.
clroptional. The color value to draw the filled circle. Defaults to COLOR_ON (black).

◆ deepSleep()

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::deepSleep ( bool  mode2 = false)
inline

Put the SSD168x into deep sleep.

Only a hardware reset can wake it again. display() does this automatically.

Parameters
mode2false (default) : Deep Sleep Mode 1 (RAM retained), true : Deep Sleep Mode 2 (RAM not retained).

◆ disableDebugging()

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::disableDebugging ( void  )
inline

Turn off debug messages.

◆ display()

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::display ( bool  partial = false,
bool  dirtyOnly = true 
)
inline

Send any pending display updates to the connected SSD168x device and update the display.

This includes drawn graphics and erase commands. To display any graphics, this method must be called.

display() will always reset (wake) the SSD168x, even if there is nothing new to display. This avoids it staying in deep sleep and holding BUSY high.

The update takes some time. Check isBusy() to see when it is complete.

Parameters
partialfalse (default) : full update, true : partial update
dirtyOnlytrue (default) : send dirty pixels only, false : send all pixels

◆ erase()

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::erase ( void  )
inline

Erase all graphics on the device, placing the display in a blank state.

The erase update isn't sent to the device until the next display() call on the device.

◆ getColor()

template<typename DeviceType >
uint8_t SSD168xSPIBaseClass< DeviceType >::getColor ( void  )
inline

Get the current color of the system. This is used by the Arduino Print interface functionality.

Returns
The current color. COLOR_OFF (0) = white, COLOR_ON (1) = black.

◆ getDrawMode()

template<typename DeviceType >
grEpRasterOp_t SSD168xSPIBaseClass< DeviceType >::getDrawMode ( void  )
inline

Get the current draw mode. The draw mode determines how pixels are set on the screen during drawing operations.

Returns
The current raster operation (ROP) of the graphics system.

◆ getFont()

template<typename DeviceType >
QwiicEpFont * SSD168xSPIBaseClass< DeviceType >::getFont ( void  )
inline

Get the current font for the device.

Returns
A pointer to the current font. See setFont() for font object details.

◆ getFontName()

template<typename DeviceType >
sfe_string_t SSD168xSPIBaseClass< DeviceType >::getFontName ( void  )
inline

Get the name of the current font for the device.

Returns
The font name (an Arduino String, or a std::string on ESP-IDF). Empty if no font is set.

◆ getHeight()

template<typename DeviceType >
uint8_t SSD168xSPIBaseClass< DeviceType >::getHeight ( void  )
inline

Get the height, in pixels, of the connected e-Paper device.

Returns
The height in pixels.

◆ getStringHeight() [1/2]

template<typename DeviceType >
unsigned int SSD168xSPIBaseClass< DeviceType >::getStringHeight ( const char *  text)
inline

Get the height of the provided string, using the current font.

Parameters
textThe null-terminated string used to determine the height.
Returns
The height of the provided string in pixels, as determined using the current font.

◆ getStringHeight() [2/2]

template<typename DeviceType >
unsigned int SSD168xSPIBaseClass< DeviceType >::getStringHeight ( sfe_string_t &  text)
inline

Get the height of the provided string, using the current font.

Parameters
textThe string used to determine the height.
Returns
The height of the provided string in pixels, as determined using the current font.

◆ getStringWidth() [1/2]

template<typename DeviceType >
unsigned int SSD168xSPIBaseClass< DeviceType >::getStringWidth ( const char *  text)
inline

Get the width of the provided string, using the current font.

Parameters
textThe null-terminated string used to determine the width.
Returns
The width of the provided string in pixels, as determined using the current font.

◆ getStringWidth() [2/2]

template<typename DeviceType >
unsigned int SSD168xSPIBaseClass< DeviceType >::getStringWidth ( sfe_string_t &  text)
inline

Get the width of the provided string, using the current font.

Parameters
textThe string used to determine the width.
Returns
The width of the provided string in pixels, as determined using the current font.

◆ getWidth()

template<typename DeviceType >
uint8_t SSD168xSPIBaseClass< DeviceType >::getWidth ( void  )
inline

Get the width, in pixels, of the connected e-Paper device.

Returns
The width in pixels.

◆ isBusy()

template<typename DeviceType >
bool SSD168xSPIBaseClass< DeviceType >::isBusy ( void  )
inline

Read the SSD168x BUSY pin.

Returns
true if the SSD168x is busy (e.g. performing a display update).

◆ line()

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::line ( uint8_t  x0,
uint8_t  y0,
uint8_t  x1,
uint8_t  y1,
uint8_t  clr = COLOR_ON 
)
inline

Draw a line on the screen.

If a line is horizontal (y0 = y1) or vertical (x0 = x1), optimized draw algorithms are used by the library.

Parameters
x0The start X coordinate of the line.
y0The start Y coordinate of the line.
x1The end X coordinate of the line.
y1The end Y coordinate of the line.
clroptional. The color value to draw the line. Defaults to COLOR_ON (black).

◆ pixel()

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::pixel ( uint8_t  x,
uint8_t  y,
uint8_t  clr = COLOR_ON 
)
inline

Set the value of a pixel on the screen.

Parameters
xThe X coordinate of the pixel to set.
yThe Y coordinate of the pixel to set.
clroptional. The color value to set the pixel. Defaults to COLOR_ON (black).

◆ rectangle()

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::rectangle ( uint8_t  x0,
uint8_t  y0,
uint8_t  width,
uint8_t  height,
uint8_t  clr = COLOR_ON 
)
inline

Draw a rectangle on the screen.

Parameters
x0The start X coordinate of the rectangle - upper left corner.
y0The start Y coordinate of the rectangle - upper left corner.
widthThe width of the rectangle.
heightThe height of the rectangle.
clroptional. The color value to draw the rectangle. Defaults to COLOR_ON (black).

◆ rectangleFill()

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::rectangleFill ( uint8_t  x0,
uint8_t  y0,
uint8_t  width,
uint8_t  height,
uint8_t  clr = COLOR_ON 
)
inline

Draw a filled rectangle on the screen.

Parameters
x0The start X coordinate of the rectangle - upper left corner.
y0The start Y coordinate of the rectangle - upper left corner.
widthThe width of the rectangle.
heightThe height of the rectangle.
clroptional. The color value to draw the filled rectangle. Defaults to COLOR_ON (black).

◆ reset()

template<typename DeviceType >
bool SSD168xSPIBaseClass< DeviceType >::reset ( void  )
inline

Reset the system and the SSD168x back to an initial state.

Clears the graphics buffer and the display RAM, and performs a full update. The user must check isBusy() afterwards.

Returns
true on success, false on failure.

◆ setColor()

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::setColor ( uint8_t  clr)
inline

Set the current color of the system. This is used by the Arduino Print interface functionality.

Parameters
clrThe color to set. COLOR_ON ('ON') is e-paper BLACK (due to inversion); COLOR_OFF ('OFF') is e-paper WHITE.

◆ setCursor()

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::setCursor ( uint8_t  x,
uint8_t  y 
)
inline

Set the "cursor" position in the device.

The library supports the Arduino Print interface, enabling the use of the print() and println() methods. The cursor position defines where to start text output for this functionality.

Parameters
xThe X coordinate of the cursor.
yThe Y coordinate of the cursor.

◆ setDrawMode()

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::setDrawMode ( grEpRasterOp_t  rop)
inline

Set the current draw mode. The draw mode determines how pixels are set on the screen during drawing operations.

Parameters
ropThe raster operation (ROP) to set the graphics system to. See the comments above for the available codes.

◆ setFont() [1/2]

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::setFont ( const QwiicEpFont *  theFont)
inline

Set the current font. The current font is used when calling the text() method on this device.

Parameters
theFontA pointer to the font to set as current in the device.

◆ setFont() [2/2]

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::setFont ( QwiicEpFont &  theFont)
inline

Set the current font. The current font is used when calling the text() method on this device.

The default font for the device is 5x7. See the comments above for the list of fonts.

Parameters
theFontThe font to set as current in the device.

◆ text() [1/2]

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::text ( uint8_t  x0,
uint8_t  y0,
const char *  text,
uint8_t  clr = COLOR_ON 
)
inline

Draw a string on the screen using the current font.

Parameters
x0The X coordinate to start drawing the text.
y0The Y coordinate to start drawing the text.
textThe null-terminated string to draw on the screen.
clroptional. The color value to draw the text. Defaults to COLOR_ON (black).

◆ text() [2/2]

template<typename DeviceType >
void SSD168xSPIBaseClass< DeviceType >::text ( uint8_t  x0,
uint8_t  y0,
sfe_string_t &  text,
uint8_t  clr = COLOR_ON 
)
inline

Draw a string on the screen using the current font.

Parameters
x0The X coordinate to start drawing the text.
y0The Y coordinate to start drawing the text.
textThe string (an Arduino String, or a std::string on ESP-IDF) to draw on the screen.
clroptional. The color value to draw the text. Defaults to COLOR_ON (black).

◆ write()

template<typename DeviceType >
virtual size_t SSD168xSPIBaseClass< DeviceType >::write ( uint8_t  theChar)
inlinevirtual

Write one character at the cursor position, using the current font and color. For the Arduino Print interface.

'\n' moves the cursor to the start of the next line. '\r' is ignored.

Parameters
theCharThe character to write.
Returns
1 on success, 0 if there is no font.

Member Data Documentation

◆ m_device

template<typename DeviceType >
DeviceType SSD168xSPIBaseClass< DeviceType >::m_device
protected

The documentation for this class was generated from the following file: