51#if defined(SFE_SSD168X_ESP_IDF)
63#if defined(SFE_SSD168X_ESP_IDF)
73 virtual ~SSD168xPrint() {}
81 virtual size_t write(uint8_t theChar) = 0;
84 size_t print(
const char *str)
89 n += write((uint8_t)*str++);
93 size_t print(
const std::string &str)
95 return print(str.c_str());
100 return write((uint8_t)c);
103 size_t print(
long value)
106 snprintf(buf,
sizeof(buf),
"%ld", value);
110 size_t print(
int value)
112 return print((
long)value);
115 size_t print(
unsigned long value,
int base = DEC)
118 snprintf(buf,
sizeof(buf), (base == HEX) ?
"%lX" :
"%lu", value);
122 size_t print(
unsigned int value,
int base = DEC)
124 return print((
unsigned long)value, base);
127 size_t print(
double value,
int decimalPlaces = 2)
130 snprintf(buf,
sizeof(buf),
"%.*f", decimalPlaces, value);
136 return write((uint8_t)
'\n');
139 size_t println(
const char *str)
141 return print(str) + println();
144 size_t println(
const std::string &str)
146 return print(str) + println();
149 size_t println(
long value)
151 return print(value) + println();
154 size_t println(
int value)
156 return print(value) + println();
159 size_t println(
unsigned long value,
int base = DEC)
161 return print(value, base) + println();
164 size_t println(
unsigned int value,
int base = DEC)
166 return print(value, base) + println();
169 size_t println(
double value,
int decimalPlaces = 2)
171 return print(value, decimalPlaces) + println();
179 size_t printf(
const char *format, ...) __attribute__((format(printf, 2, 3)))
183 va_start(args, format);
184 vsnprintf(buf,
sizeof(buf), format, args);
232 SparkFun_SSD168x::SfeSPI m_spiBus;
245 bool initDevice(
int resetPin,
int busyPin)
251 m_device.setCommBus(m_spiBus, resetPin, busyPin);
263 m_cursorY = pFont->
height;
270#if defined(SFE_SSD168X_ARDUINO)
298 bool begin(
int csPin,
int dcPin,
int resetPin,
int busyPin, SPIClass &spiPort = SPI,
299 uint32_t spiClockHz = SparkFun_SSD168x::kDefaultSpiClockHz)
301 if (!m_spiBus.init(spiPort, spiClockHz, csPin, dcPin))
303 m_device.debugPrintln(
"begin: invalid CS or D/C pin",
true);
307 return initDevice(resetPin, busyPin);
316 void enableDebugging(Print &debugPort = Serial,
bool printLimitedDebug =
false)
318 m_device.enableDebugging(debugPort, printLimitedDebug);
321#elif defined(SFE_SSD168X_ESP_IDF)
338 bool begin(spi_host_device_t host, gpio_num_t csPin, gpio_num_t dcPin, gpio_num_t resetPin, gpio_num_t busyPin,
339 uint32_t spiClockHz = SparkFun_SSD168x::kDefaultSpiClockHz)
341 if (!m_spiBus.init(host, csPin, dcPin, spiClockHz))
343 m_device.debugPrintln(
"begin: SPI init failed",
true);
347 return initDevice((
int)resetPin, (
int)busyPin);
362 bool begin(spi_device_handle_t device, gpio_num_t csPin, gpio_num_t dcPin, gpio_num_t resetPin, gpio_num_t busyPin)
364 if (!m_spiBus.init(device, csPin, dcPin))
366 m_device.debugPrintln(
"begin: SPI init failed",
true);
370 return initDevice((
int)resetPin, (
int)busyPin);
379 void enableDebugging(
sfe_print_t &debugPort = SparkFun_SSD168x::sfeStdout,
bool printLimitedDebug =
false)
381 m_device.enableDebugging(debugPort, printLimitedDebug);
452 void display(
bool partial =
false,
bool dirtyOnly =
true)
454 m_device.display(partial, dirtyOnly);
606 uint16_t height, width;
608 return (
m_device.getStringSize(
text, width, height) ? width : 0);
633 uint16_t height, width;
635 return (
m_device.getStringSize(
text, width, height) ? height : 0);
708 void line(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t clr =
COLOR_ON)
727 m_device.rectangle(x0, y0, width, height, clr);
744 m_device.rectangleFill(x0, y0, width, height, clr);
760 m_device.circle(x0, y0, radius, clr);
776 m_device.circleFill(x0, y0, radius, clr);
793 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)
795 m_device.bitmap(x0, y0, x1, y1, pBitmap, bmp_width, bmp_height);
807 void bitmap(uint8_t x0, uint8_t y0, uint8_t *pBitmap, uint8_t bmp_width, uint8_t bmp_height)
809 m_device.bitmap(x0, y0, pBitmap, bmp_width, bmp_height);
915 virtual size_t write(uint8_t theChar)
926 m_cursorY += pFont->
height;
932 char buffer[2] = {(char)theChar,
'\0'};
933 m_device.text(m_cursorX, m_cursorY, buffer, m_color);
935 m_cursorX += pFont->
width + 1;
940 m_cursorY += pFont->
height;
950#if defined(SFE_SSD168X_ARDUINO)
Print SSD168xPrintBase
Definition: SparkFun_SSD168x_Library.h:194
QwEpFont QwiicEpFont
Definition: SparkFun_SSD168x_Library.h:56
QwEpBitmap QwiicEpBitmap
Definition: SparkFun_SSD168x_Library.h:57
Definition: qwiic_resdef.h:102
Definition: qwiic_resdef.h:138
const char * name
Definition: qwiic_resdef.h:146
uint8_t width
Definition: qwiic_resdef.h:141
uint8_t height
Definition: qwiic_resdef.h:142
A 184x88 SSD1680 e-Paper display (e.g. GoodDisplay GDEM0097T61) - portrait: 88 pixels wide,...
Definition: SparkFun_SSD168x_Library.h:962
A 184x88 SSD1680 e-Paper display (e.g. GoodDisplay GDEM0097T61) - rotated to landscape: 184 pixels wi...
Definition: SparkFun_SSD168x_Library.h:1034
A custom-sized SSD1680 e-Paper display. Call the set methods before begin().
Definition: SparkFun_SSD168x_Library.h:978
void setYOffset(uint8_t yOffset)
Set the Y offset. Call before begin().
Definition: SparkFun_SSD168x_Library.h:986
void setXOffset(uint8_t xOffset)
Set the X offset. Call before begin().
Definition: SparkFun_SSD168x_Library.h:981
void setDisplayHeight(uint8_t displayHeight)
Set the display height. Call before begin().
Definition: SparkFun_SSD168x_Library.h:996
void setDisplayWidth(uint8_t displayWidth)
Set the display width. Call before begin().
Definition: SparkFun_SSD168x_Library.h:991
A 200x200 SSD1681 e-Paper display (e.g. GoodDisplay GDEY0154D67).
Definition: SparkFun_SSD168x_Library.h:970
A custom-sized SSD1681 e-Paper display. Call the set methods before begin().
Definition: SparkFun_SSD168x_Library.h:1006
void setXOffset(uint8_t xOffset)
Set the X offset. Call before begin().
Definition: SparkFun_SSD168x_Library.h:1009
void setDisplayWidth(uint8_t displayWidth)
Set the display width. Call before begin().
Definition: SparkFun_SSD168x_Library.h:1019
void setYOffset(uint8_t yOffset)
Set the Y offset. Call before begin().
Definition: SparkFun_SSD168x_Library.h:1014
void setDisplayHeight(uint8_t displayHeight)
Set the display height. Call before begin().
Definition: SparkFun_SSD168x_Library.h:1024
The templated base class for all SSD168x SPI e-Paper displays.
Definition: SparkFun_SSD168x_Library.h:221
virtual size_t write(uint8_t theChar)
Write one character at the cursor position, using the current font and color. For the Arduino Print i...
Definition: SparkFun_SSD168x_Library.h:915
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.
Definition: SparkFun_SSD168x_Library.h:793
void setCursor(uint8_t x, uint8_t y)
Set the "cursor" position in the device.
Definition: SparkFun_SSD168x_Library.h:868
SparkFun_SSD168x::sfe_string_t sfe_string_t
The string type: String on Arduino; std::string on ESP-IDF.
Definition: SparkFun_SSD168x_Library.h:225
void setFont(QwiicEpFont &theFont)
Set the current font. The current font is used when calling the text() method on this device.
Definition: SparkFun_SSD168x_Library.h:539
void display(bool partial=false, bool dirtyOnly=true)
Send any pending display updates to the connected SSD168x device and update the display.
Definition: SparkFun_SSD168x_Library.h:452
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.
Definition: SparkFun_SSD168x_Library.h:835
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.
Definition: SparkFun_SSD168x_Library.h:742
void disableDebugging(void)
Turn off debug messages.
Definition: SparkFun_SSD168x_Library.h:389
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.
Definition: SparkFun_SSD168x_Library.h:725
void setColor(uint8_t clr)
Set the current color of the system. This is used by the Arduino Print interface functionality.
Definition: SparkFun_SSD168x_Library.h:886
void circleFill(uint8_t x0, uint8_t y0, uint8_t radius, uint8_t clr=COLOR_ON)
Draw a filled circle on the screen.
Definition: SparkFun_SSD168x_Library.h:774
sfe_string_t getFontName(void)
Get the name of the current font for the device.
Definition: SparkFun_SSD168x_Library.h:574
void bitmap(uint8_t x0, uint8_t y0, QwiicEpBitmap &bitmap)
Draw a bitmap object on the screen.
Definition: SparkFun_SSD168x_Library.h:819
bool reset(void)
Reset the system and the SSD168x back to an initial state.
Definition: SparkFun_SSD168x_Library.h:431
uint8_t getColor(void)
Get the current color of the system. This is used by the Arduino Print interface functionality.
Definition: SparkFun_SSD168x_Library.h:899
DeviceType m_device
Definition: SparkFun_SSD168x_Library.h:229
void deepSleep(bool mode2=false)
Put the SSD168x into deep sleep.
Definition: SparkFun_SSD168x_Library.h:480
unsigned int getStringHeight(sfe_string_t &text)
Get the height of the provided string, using the current font.
Definition: SparkFun_SSD168x_Library.h:620
SparkFun_SSD168x::sfe_print_t sfe_print_t
The print type: Print on Arduino; SfeOutput on ESP-IDF.
Definition: SparkFun_SSD168x_Library.h:224
void setDrawMode(grEpRasterOp_t rop)
Set the current draw mode. The draw mode determines how pixels are set on the screen during drawing o...
Definition: SparkFun_SSD168x_Library.h:658
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.
Definition: SparkFun_SSD168x_Library.h:848
QwiicEpFont * getFont(void)
Get the current font for the device.
Definition: SparkFun_SSD168x_Library.h:561
void circle(uint8_t x0, uint8_t y0, uint8_t radius, uint8_t clr=COLOR_ON)
Draw a circle on the screen.
Definition: SparkFun_SSD168x_Library.h:758
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.
Definition: SparkFun_SSD168x_Library.h:807
unsigned int getStringHeight(const char *text)
Get the height of the provided string, using the current font.
Definition: SparkFun_SSD168x_Library.h:631
unsigned int getStringWidth(const char *text)
Get the width of the provided string, using the current font.
Definition: SparkFun_SSD168x_Library.h:604
void pixel(uint8_t x, uint8_t y, uint8_t clr=COLOR_ON)
Set the value of a pixel on the screen.
Definition: SparkFun_SSD168x_Library.h:689
void setFont(const QwiicEpFont *theFont)
Set the current font. The current font is used when calling the text() method on this device.
Definition: SparkFun_SSD168x_Library.h:548
bool isBusy(void)
Read the SSD168x BUSY pin.
Definition: SparkFun_SSD168x_Library.h:493
unsigned int getStringWidth(sfe_string_t &text)
Get the width of the provided string, using the current font.
Definition: SparkFun_SSD168x_Library.h:593
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.
Definition: SparkFun_SSD168x_Library.h:708
grEpRasterOp_t getDrawMode(void)
Get the current draw mode. The draw mode determines how pixels are set on the screen during drawing o...
Definition: SparkFun_SSD168x_Library.h:671
uint8_t getHeight(void)
Get the height, in pixels, of the connected e-Paper device.
Definition: SparkFun_SSD168x_Library.h:415
uint8_t getWidth(void)
Get the width, in pixels, of the connected e-Paper device.
Definition: SparkFun_SSD168x_Library.h:402
void erase(void)
Erase all graphics on the device, placing the display in a blank state.
Definition: SparkFun_SSD168x_Library.h:465
void setXOffset(uint8_t xOffset)
Set the X offset. Call before init().
Definition: qwiic_ssd1680_custom.h:77
void setDisplayHeight(uint8_t displayHeight)
Set the display height. Call before init().
Definition: qwiic_ssd1680_custom.h:83
void setDisplayWidth(uint8_t displayWidth)
Set the display width. Call before init().
Definition: qwiic_ssd1680_custom.h:81
void setYOffset(uint8_t yOffset)
Set the Y offset. Call before init().
Definition: qwiic_ssd1680_custom.h:79
void setDisplayWidth(uint8_t displayWidth)
Set the display width. Call before init().
Definition: qwiic_ssd1681_custom.h:81
void setDisplayHeight(uint8_t displayHeight)
Set the display height. Call before init().
Definition: qwiic_ssd1681_custom.h:83
void setYOffset(uint8_t yOffset)
Set the Y offset. Call before init().
Definition: qwiic_ssd1681_custom.h:79
void setXOffset(uint8_t xOffset)
Set the X offset. Call before init().
Definition: qwiic_ssd1681_custom.h:77
const uint8_t COLOR_ON
Definition: qwiic_grbuffer.cpp:51
const uint8_t COLOR_OFF
Definition: qwiic_grbuffer.cpp:52
enum gr_ep_op_funcs_ grEpRasterOp_t