### Initialize Hardware with display.begin() Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Initializes the e-paper panel and internal components. Must be called once in the setup function. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_1BIT); void setup() { display.begin(); // Initialize display hardware - call ONLY ONCE display.clearDisplay(); // Clear the frame buffer display.display(); // Refresh the screen } void loop() { // Your code here } ``` -------------------------------- ### Build and Install FreeType Library Source: https://github.com/solderedelectronics/inkplate-arduino-library/blob/master/extras/fontconvert/fontconvert_win.md Configure, build, and install the FreeType library using standard Unix-like commands within the MSYS environment. This prepares the library for use by other tools. ```bash ./configure --prefix=/mingw make make install ``` -------------------------------- ### Install Python Serial Library Source: https://github.com/solderedelectronics/inkplate-arduino-library/blob/master/README.md Alternative command for installing the pyserial library if standard installation fails. ```bash apt install python3-serial ``` -------------------------------- ### Install Linux Dependencies Source: https://github.com/solderedelectronics/inkplate-arduino-library/blob/master/README.md Required packages for Inkplate development on Linux systems. ```bash apt install python3-pip pip3 install pyserial apt install python-is-python3 ``` -------------------------------- ### Screen Rotation Example Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Demonstrates how to rotate the display orientation using the setRotation() function. The display can be set to 0, 90, 180, or 270 degrees. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_1BIT); void setup() { display.begin(); display.setTextSize(4); display.setTextColor(BLACK); for (int r = 0; r < 4; r++) { display.setRotation(r); // 0=0°, 1=90°, 2=180°, 3=270° display.clearDisplay(); display.setCursor(10, 50); display.print("Rotation: "); display.print(r); display.display(); delay(3000); } } void loop() {} ``` -------------------------------- ### Color Display Example Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Demonstrates drawing colored rectangles, text, and shapes on the Inkplate 6COLOR display. Initialization does not require a display mode parameter. Full display refresh takes approximately 12-15 seconds. ```cpp #include "Inkplate.h" Inkplate display; // No mode parameter for color display void setup() { display.begin(); display.clearDisplay(); // Fill screen with white background display.fillScreen(INKPLATE_WHITE); // Draw colored rectangles display.fillRect(0, 0, 100, 100, INKPLATE_BLACK); display.fillRect(100, 0, 100, 100, INKPLATE_WHITE); display.fillRect(200, 0, 100, 100, INKPLATE_GREEN); display.fillRect(300, 0, 100, 100, INKPLATE_BLUE); display.fillRect(400, 0, 100, 100, INKPLATE_RED); display.fillRect(500, 0, 100, 100, INKPLATE_YELLOW); display.fillRect(0, 100, 100, 100, INKPLATE_ORANGE); // Draw colored text display.setTextSize(2); display.setTextColor(INKPLATE_RED); display.setCursor(50, 250); display.print("Red Text"); display.setTextColor(INKPLATE_BLUE); display.setCursor(50, 290); display.print("Blue Text"); display.setTextColor(INKPLATE_GREEN); display.setCursor(50, 330); display.print("Green Text"); // Draw colored shapes display.fillCircle(300, 300, 50, INKPLATE_YELLOW); display.drawCircle(300, 300, 60, INKPLATE_BLACK); display.display(); // Color display refresh takes ~12-15 seconds } void loop() {} ``` -------------------------------- ### Peripheral Mode UART Command Example Source: https://github.com/solderedelectronics/inkplate-arduino-library/blob/master/README.md This command is used in Peripheral mode to display an image from an SD card on the Inkplate screen. Ensure the image file exists on the SD card. ```text *#H(000,000,"/img.bmp")** ``` -------------------------------- ### Implement Deep Sleep Mode Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Use deep sleep to achieve ultra-low power consumption. Note that the device restarts from setup() upon waking, so use RTC_DATA_ATTR for persistent variables. ```cpp #include "Inkplate.h" #include "driver/rtc_io.h" // RTC memory survives deep sleep RTC_DATA_ATTR int bootCount = 0; Inkplate display(INKPLATE_3BIT); #define uS_TO_S_FACTOR 1000000 // Microseconds to seconds #define TIME_TO_SLEEP 60 // Sleep for 60 seconds void setup() { display.begin(); display.clearDisplay(); display.setTextSize(3); bootCount++; display.printf("Boot count: %d\n", bootCount); display.display(); // Isolate GPIO12 to reduce power consumption rtc_gpio_isolate(GPIO_NUM_12); // Configure wake-up timer esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR); // Enter deep sleep - program execution stops here esp_deep_sleep_start(); // This line never executes } void loop() { // Never reached when using deep sleep } ``` -------------------------------- ### display.begin() Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Initializes the hardware components of the Inkplate display. ```APIDOC ## display.begin() ### Description Initializes the e-paper panel, I/O expanders, and internal components. Must be called once in the setup function. ### Request Example ```cpp void setup() { display.begin(); display.clearDisplay(); display.display(); } ``` ``` -------------------------------- ### Implement Generic C PNG Decoding Source: https://github.com/solderedelectronics/inkplate-arduino-library/blob/master/src/libs/pngle/README.md Demonstrates the basic workflow of initializing the Pngle object, setting a draw callback, and feeding binary data from a stream. ```c void on_draw(pngle_t *pngle, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint8_t rgba[4]) { uint8_t r = rgba[0]; // 0 - 255 uint8_t g = rgba[1]; // 0 - 255 uint8_t b = rgba[2]; // 0 - 255 uint8_t a = rgba[3]; // 0: fully transparent, 255: fully opaque if (a) printf("put pixel at (%d, %d) with color #%02x%02x%02x\n", x, y, r, g, b); } int main(int argc, char *argv[]) { pngle_t *pngle = pngle_new(); pngle_set_draw_callback(pngle, on_draw); // Feed data to pngle char buf[1024]; int remain = 0; int len; while ((len = read(STDIN_FILENO, buf + remain, sizeof(buf) - remain)) > 0) { int fed = pngle_feed(pngle, buf, remain + len); if (fed < 0) errx(1, "%s", pngle_error(pngle)); remain = remain + len - fed; if (remain > 0) memmove(buf, buf + fed, remain); } pngle_destroy(pngle); return 0; } ``` -------------------------------- ### Configuration Methods Source: https://github.com/solderedelectronics/inkplate-arduino-library/blob/master/src/libs/APDS9960/keywords.txt Methods to configure sensor sensitivity, interrupt pins, and LED boost settings. ```APIDOC ## setGestureSensitivity ### Description Configures the sensitivity for gesture detection. ## setInterruptPin ### Description Configures the interrupt pin for the sensor. ## setLEDBoost ### Description Configures the LED boost setting for the sensor. ``` -------------------------------- ### Basic Text Rendering with Inkplate Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Demonstrates basic text rendering with customizable size, color, and positioning. Supports default and custom fonts, and text wrapping options. ```cpp #include "Inkplate.h" #include "Fonts/FreeSansBold24pt7b.h" Inkplate display(INKPLATE_3BIT); void setup() { display.begin(); display.clearDisplay(); // Basic text display.setTextColor(0); // Black text display.setTextSize(2); // 2x scale (default font is 5x7 pixels) display.setCursor(50, 50); display.print("Hello Inkplate!"); // Text with background color display.setTextColor(0, 7); // Black text on white background display.setTextSize(3); display.setCursor(50, 100); display.print("With Background"); // Inverted text display.setTextColor(7, 0); // White text on black background display.setCursor(50, 170); display.print("Inverted Text"); // Using custom font display.setFont(&FreeSansBold24pt7b); display.setTextColor(2); // Gray color display.setCursor(50, 280); display.print("Custom Font!"); // Reset to default font display.setFont(); display.setTextSize(1); display.setCursor(50, 350); display.print("Back to default"); // Disable text wrapping display.setTextWrap(false); display.display(); } void loop() {} ``` -------------------------------- ### Initialize Inkplate Display Object Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Creates an Inkplate display object. Use INKPLATE_1BIT for black/white, INKPLATE_3BIT for grayscale, or no parameter for color displays. ```cpp #include "Inkplate.h" // For monochrome displays - Black & White mode (faster refresh) Inkplate display(INKPLATE_1BIT); // For monochrome displays - Grayscale mode (8 gray levels, 0-7) Inkplate display(INKPLATE_3BIT); // For color displays (Inkplate 6COLOR) - no mode parameter needed Inkplate display; ``` -------------------------------- ### Build fontconvert.exe Source: https://github.com/solderedelectronics/inkplate-arduino-library/blob/master/extras/fontconvert/fontconvert_win.md Compile the fontconvert.c utility using make after configuring the makefile. This generates the executable file needed for font conversion. ```bash make ``` -------------------------------- ### Library Initialization and Control Source: https://github.com/solderedelectronics/inkplate-arduino-library/blob/master/src/libs/APDS9960/keywords.txt Methods for initializing and terminating the sensor interface. ```APIDOC ## begin ### Description Initializes the APDS9960 sensor. ## end ### Description Terminates the connection to the APDS9960 sensor. ``` -------------------------------- ### display.selectDisplayMode() / display.setDisplayMode() Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Switches the display between 1-bit (BW) and 3-bit (grayscale) modes at runtime. ```APIDOC ## display.selectDisplayMode() / display.setDisplayMode() ### Description Switches between 1-bit (BW) and 3-bit (grayscale) display modes at runtime. Only available on monochrome displays. ### Parameters #### Arguments - **mode** (int) - Required - The display mode to set (e.g., INKPLATE_1BIT or INKPLATE_3BIT). ``` -------------------------------- ### Manage WiFi Connections Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Utilize built-in helpers for connecting to single or multiple WiFi networks with timeout support. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_1BIT); const char* ssid = "YourWiFiSSID"; const char* password = "YourWiFiPassword"; void setup() { display.begin(); display.clearDisplay(); display.setTextSize(2); // Simple WiFi connection with timeout (seconds) and serial debug output if (display.connectWiFi(ssid, password, 30, true)) { display.println("WiFi Connected!"); display.print("IP: "); display.println(WiFi.localIP()); } else { display.println("WiFi Connection Failed!"); } display.display(); // Check connection status if (display.isConnected()) { display.println("Still connected"); } // Disconnect when done display.disconnect(); } void loop() {} // Multi-network example: void connectMultiNetwork() { const char* ssids[] = {"Network1", "Network2", "Network3"}; const char* passwords[] = {"pass1", "pass2", "pass3"}; if (display.connectWiFiMulti(3, ssids, passwords, 30, true)) { // Connected to one of the networks } } ``` -------------------------------- ### Perform Partial Updates with display.partialUpdate() Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Updates only changed areas of the screen in 1-bit mode. Perform a full refresh periodically to prevent ghosting. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_1BIT); int counter = 0; int partialCount = 0; void setup() { display.begin(); display.clearDisplay(); display.display(); // Initial full refresh display.setTextSize(4); display.setTextColor(BLACK, WHITE); } void loop() { display.clearDisplay(); display.setCursor(100, 300); display.print("Counter: "); display.print(counter++); if (partialCount > 9) { display.display(); // Full refresh every 10 updates partialCount = 0; } else { // partialUpdate(forced, leaveOn) // forced: force partial update even in deep sleep // leaveOn: keep e-paper power supply on for faster refresh display.partialUpdate(false, true); partialCount++; } delay(1000); } ``` -------------------------------- ### Navigate to fontconvert Directory Source: https://github.com/solderedelectronics/inkplate-arduino-library/blob/master/extras/fontconvert/fontconvert_win.md Use cd command to navigate to the fontconvert directory within the Adafruit GFX library. This is necessary to run the make command for building the utility. ```bash cd /c/adafruit_gfx_library\fontconvert ``` -------------------------------- ### Initialize and Read Touchscreen Input Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Initializes the capacitive touchscreen on supported Inkplate models and reads touch input. Requires the Inkplate library. The tsInit function powers on the touchscreen after initialization if true is passed. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_1BIT); void setup() { Serial.begin(115200); display.begin(); display.clearDisplay(); display.display(); // Initialize touchscreen (true = power on after init) if (display.tsInit(true)) { Serial.println("Touchscreen OK"); } else { Serial.println("Touchscreen failed"); while(1); } } void loop() { // Check if touch is available if (display.tsAvailable()) { uint16_t x[2], y[2]; // Arrays for up to 2 touch points uint8_t numTouches; // Get touch data numTouches = display.tsGetData(x, y); if (numTouches > 0) { // Draw at touch position display.fillCircle(x[0], y[0], 5, BLACK); display.partialUpdate(); Serial.printf("Touch at (%d, %d)\n", x[0], y[0]); } } } ``` -------------------------------- ### Switch Display Mode (BW/Grayscale) Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Switches between 1-bit (BW) and 3-bit (grayscale) display modes at runtime. This function is only available on monochrome displays. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_1BIT); void setup() { display.begin(); // Start in BW mode display.clearDisplay(); display.fillRect(100, 100, 200, 200, BLACK); display.display(); delay(3000); // Switch to grayscale mode display.selectDisplayMode(INKPLATE_3BIT); display.clearDisplay(); // Draw with grayscale colors (0=black, 7=white) for (int i = 0; i < 8; i++) { display.fillRect(50 + i*80, 100, 70, 200, i); } display.display(); } void loop() {} ``` -------------------------------- ### Drawing Primitives (Adafruit GFX Compatible) Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Standard drawing functions for pixels, lines, rectangles, circles, and triangles. ```APIDOC ## Drawing Primitives ### Description The library is fully compatible with Adafruit GFX, providing standard drawing functions for pixels, lines, rectangles, circles, triangles, and text. Colors are 0 (WHITE) to 1 (BLACK) in 1-bit mode, or 0 (BLACK) to 7 (WHITE) in 3-bit grayscale mode. ``` -------------------------------- ### Refresh Display with display.display() Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Performs a full screen refresh to update the e-paper display from the frame buffer. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_1BIT); void setup() { display.begin(); display.clearDisplay(); // Draw some content display.setTextSize(4); display.setCursor(100, 100); display.print("Hello World!"); // Perform full display refresh display.display(); // Or keep power on for faster subsequent refresh // display.display(true); // leaveOn = true } void loop() {} ``` -------------------------------- ### Draw Images from Web URLs Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Load and display BMP, JPEG, or PNG images directly from a URL. Requires an active WiFi connection. ```cpp #include "Inkplate.h" #include "WiFi.h" Inkplate display(INKPLATE_1BIT); const char* ssid = "YourWiFiSSID"; const char* password = "YourWiFiPassword"; void setup() { display.begin(); display.clearDisplay(); display.setTextSize(2); display.print("Connecting to WiFi..."); display.display(); // Connect to WiFi WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); display.print("."); display.partialUpdate(); } display.println("\nConnected!"); display.partialUpdate(); // Draw image from URL (url, x, y, dither, invert) display.clearDisplay(); if (!display.drawImage("https://example.com/image.bmp", 0, 0, true, false)) { display.println("Image load error"); } display.display(); delay(5000); // Draw JPEG from web display.clearDisplay(); if (!display.drawImage("https://example.com/photo.jpg", 0, 0, true, false)) { display.println("JPEG load error"); } display.display(); // Alternative methods for specific formats: // display.drawBitmapFromWeb(url, x, y, dither, invert); // display.drawJpegFromWeb(url, x, y, dither, invert); // display.drawPngFromWeb(url, x, y, dither, invert); WiFi.disconnect(); } void loop() {} ``` -------------------------------- ### Inkplate Initialization Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Initializes the Inkplate display object with a specific display mode. ```APIDOC ## Inkplate Object Initialization ### Description Creates an Inkplate display object. Monochrome displays support INKPLATE_1BIT (black/white) or INKPLATE_3BIT (8-level grayscale). Color displays do not require a mode parameter. ### Request Example ```cpp // Monochrome Black & White Inkplate display(INKPLATE_1BIT); // Monochrome Grayscale Inkplate display(INKPLATE_3BIT); // Color display Inkplate display; ``` ``` -------------------------------- ### Navigate to FreeType Directory Source: https://github.com/solderedelectronics/inkplate-arduino-library/blob/master/extras/fontconvert/fontconvert_win.md Use MSYS commands to navigate to the extracted FreeType directory. Ensure FreeType is extracted to C:\ft27 for this path. ```bash cd /c cd ft27 ``` -------------------------------- ### display.partialUpdate() Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Performs a fast partial screen update. ```APIDOC ## display.partialUpdate() ### Description Refreshes only changed areas of the screen. Available only in 1-bit mode. Recommended to perform a full refresh every 5-10 partial updates. ### Parameters - **forced** (bool) - Required - Force partial update even in deep sleep. - **leaveOn** (bool) - Required - Keep e-paper power supply on for faster refresh. ### Request Example ```cpp display.partialUpdate(false, true); ``` ``` -------------------------------- ### Drawing Images from Memory Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Display bitmap images stored in program memory (PROGMEM). Use Soldered Image Converter to generate compatible header files. ```APIDOC ## Drawing Images from Memory ### Description Display bitmap images stored in program memory (PROGMEM). Use Soldered Image Converter to generate compatible header files. ### Method N/A (Library functions) ### Endpoint N/A (Library functions) ### Parameters N/A (Library functions) ### Request Example ```cpp #include "Inkplate.h" #include "myImage.h" // Generated with Soldered Image Converter Inkplate display(INKPLATE_3BIT); void setup() { display.begin(); display.clearDisplay(); // For 1-bit images: drawImage(imageArray, x, y, width, height, color, background) // display.drawImage(myBWImage, 100, 100, 200, 150, BLACK, WHITE); // For grayscale 3-bit images: drawBitmap3Bit(x, y, imageArray, width, height) display.drawBitmap3Bit(100, 100, myGrayscaleImage, 400, 300); display.display(); } void loop() {} ``` ### Response N/A (Library functions) ``` -------------------------------- ### BQ27441 Library Methods Source: https://github.com/solderedelectronics/inkplate-arduino-library/blob/master/src/libs/BQ27441/src/libs/SparkFun_BQ27441_Arduino_Library/keywords.txt A collection of methods available in the SparkFun BQ27441 library for interacting with the LiPo gauge hardware. ```APIDOC ## BQ27441 Library Methods ### Description Methods to initialize, configure, and read data from the BQ27441 LiPo fuel gauge. ### Methods - **begin()**: Initialize the library. - **setCapacity(int capacity)**: Set the battery capacity. - **voltage()**: Get battery voltage. - **current()**: Get battery current. - **capacity()**: Get remaining battery capacity. - **power()**: Get battery power consumption. - **soc()**: Get state of charge percentage. - **soh()**: Get state of health. - **temperature()**: Get internal or battery temperature. - **setGPOUTPolarity(bool activeHigh)**: Configure GPOUT pin polarity. - **setGPOUTFunction(int function)**: Configure GPOUT pin function. - **enterConfig()**: Enter configuration mode. - **exitConfig()**: Exit configuration mode. - **flags()**: Read device status flags. - **status()**: Read device status register. ``` -------------------------------- ### Wake from Capacitive Touchpads Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Configure capacitive touchpads to wake the device from deep sleep. Ensure the correct GPIO pin is attached to the interrupt. ```cpp #include "Inkplate.h" #include "driver/rtc_io.h" Inkplate display(INKPLATE_1BIT); void setup() { display.begin(); display.clearDisplay(); display.setTextSize(2); display.println("Touch PAD3 to wake!"); display.display(); // Enable wake on touch (using ESP32 touch pins) // PAD1 = GPIO 10, PAD2 = GPIO 11, PAD3 = GPIO 12 (varies by model) esp_sleep_enable_touchpad_wakeup(); touchAttachInterrupt(GPIO_NUM_12, NULL, 40); // Threshold of 40 // Go to sleep esp_deep_sleep_start(); } void loop() {} ``` -------------------------------- ### Synchronize Time via NTP Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Retrieve accurate time from NTP servers, supporting timezone offsets and daylight savings adjustments. ```cpp #include "Inkplate.h" #include "WiFi.h" Inkplate display(INKPLATE_1BIT); void setup() { display.begin(); display.clearDisplay(); // Connect to WiFi first WiFi.begin("SSID", "password"); while (WiFi.status() != WL_CONNECTED) { delay(500); } // Get time as epoch (Unix timestamp) time_t epochTime; // getNTPEpoch(time_t*, timezone_offset_hours, ntp_server, daylight_savings_hours) if (display.getNTPEpoch(&epochTime, 1, (char*)"pool.ntp.org", 0)) { display.print("Epoch: "); display.println(epochTime); } // Get time as struct tm struct tm dateTime; if (display.getNTPDateTime(&dateTime, 1, (char*)"pool.ntp.org", 1)) { display.setTextSize(3); display.printf("%02d:%02d:%02d\n", dateTime.tm_hour, dateTime.tm_min, dateTime.tm_sec); display.printf("%02d/%02d/%04d\n", dateTime.tm_mday, dateTime.tm_mon + 1, dateTime.tm_year + 1900); } display.display(); } void loop() {} ``` -------------------------------- ### Set Full Update Threshold Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Configures the number of partial updates before a full refresh is automatically triggered to manage image quality and ghosting. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_1BIT); void setup() { display.begin(); display.clearDisplay(); display.display(); // After 10 partial updates, next partialUpdate() will do a full refresh display.setFullUpdateThreshold(10); } void loop() { display.clearDisplay(); display.setCursor(100, 300); display.print(millis()); // Library automatically handles full refresh every 10 calls display.partialUpdate(); delay(500); } ``` -------------------------------- ### Drawing Primitives (Adafruit GFX Compatible) Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Utilizes Adafruit GFX compatible functions for drawing pixels, lines, rectangles, circles, and triangles. Colors range from 0 (WHITE) to 1 (BLACK) in 1-bit mode, or 0 (BLACK) to 7 (WHITE) in 3-bit grayscale mode. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_3BIT); void setup() { display.begin(); display.clearDisplay(); // Draw pixel display.drawPixel(100, 50, 0); // Black pixel // Draw lines display.drawLine(0, 0, 799, 599, 0); // Diagonal line display.drawFastHLine(100, 100, 600, 0); // Horizontal line display.drawFastVLine(100, 100, 400, 0); // Vertical line // Draw rectangles display.drawRect(200, 200, 400, 200, 0); // Outlined rectangle display.fillRect(220, 220, 100, 100, 3); // Filled gray rectangle display.drawRoundRect(350, 220, 100, 100, 10, 0); // Rounded rectangle display.fillRoundRect(480, 220, 100, 100, 10, 2); // Filled rounded rect // Draw circles display.drawCircle(400, 450, 75, 0); // Outlined circle display.fillCircle(550, 450, 50, 4); // Filled gray circle // Draw triangles display.drawTriangle(100, 500, 200, 400, 300, 500, 0); display.fillTriangle(350, 500, 450, 400, 550, 500, 2); display.display(); } void loop() {} ``` -------------------------------- ### Drawing Images from SD Card with Inkplate Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Loads and displays BMP, JPEG, or PNG images from an SD card. Includes SD card initialization, image drawing, and power-saving sleep mode. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_3BIT); void setup() { display.begin(); display.clearDisplay(); display.setTextSize(2); // Initialize SD card if (display.sdCardInit()) { display.println("SD Card OK!"); display.display(); // Draw BMP image (filename, x, y, dither, invert) if (!display.drawImage("photo.bmp", 0, 0, true, false)) { display.println("Error loading BMP"); display.display(); } display.display(); delay(5000); // Draw JPEG image display.clearDisplay(); if (!display.drawImage("photo.jpg", 50, 50, true, false)) { display.println("Error loading JPEG"); } display.display(); delay(5000); // Draw PNG image display.clearDisplay(); if (!display.drawPngFromSd("icon.png", 200, 200, true, false)) { display.println("Error loading PNG"); } display.display(); // Put SD card to sleep to save power display.sdCardSleep(); } else { display.println("SD Card Error!"); display.display(); } } void loop() {} ``` -------------------------------- ### display.display() Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Performs a full refresh of the e-paper display. ```APIDOC ## display.display() ### Description Refreshes the display with the current frame buffer contents. Performs a full update to clear ghosting. ### Parameters - **leaveOn** (bool) - Optional - If true, keeps the e-paper power supply on for faster subsequent updates. ### Request Example ```cpp display.display(); // Full refresh display.display(true); // Full refresh, keep power on ``` ``` -------------------------------- ### Drawing Images from Memory with Inkplate Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Displays bitmap images stored in program memory (PROGMEM). Requires images to be generated using the Soldered Image Converter. ```cpp #include "Inkplate.h" #include "myImage.h" // Generated with Soldered Image Converter Inkplate display(INKPLATE_3BIT); void setup() { display.begin(); display.clearDisplay(); // For 1-bit images: drawImage(imageArray, x, y, width, height, color, background) // display.drawImage(myBWImage, 100, 100, 200, 150, BLACK, WHITE); // For grayscale 3-bit images: drawBitmap3Bit(x, y, imageArray, width, height) display.drawBitmap3Bit(100, 100, myGrayscaleImage, 400, 300); display.display(); } void loop() {} ``` -------------------------------- ### Text Rendering Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Functions for displaying text with customizable size, color, and positioning. Fully compatible with Adafruit GFX font system. ```APIDOC ## Text Rendering ### Description Functions for displaying text with customizable size, color, and positioning. Fully compatible with Adafruit GFX font system. ### Method N/A (Library functions) ### Endpoint N/A (Library functions) ### Parameters N/A (Library functions) ### Request Example ```cpp #include "Inkplate.h" #include "Fonts/FreeSansBold24pt7b.h" Inkplate display(INKPLATE_3BIT); void setup() { display.begin(); display.clearDisplay(); // Basic text display.setTextColor(0); // Black text display.setTextSize(2); // 2x scale (default font is 5x7 pixels) display.setCursor(50, 50); display.print("Hello Inkplate!"); // Text with background color display.setTextColor(0, 7); // Black text on white background display.setTextSize(3); display.setCursor(50, 100); display.print("With Background"); // Inverted text display.setTextColor(7, 0); // White text on black background display.setCursor(50, 170); display.print("Inverted Text"); // Using custom font display.setFont(&FreeSansBold24pt7b); display.setTextColor(2); // Gray color display.setCursor(50, 280); display.print("Custom Font!"); // Reset to default font display.setFont(); display.setTextSize(1); display.setCursor(50, 350); display.print("Back to default"); // Disable text wrapping display.setTextWrap(false); display.display(); } void loop() {} ``` ### Response N/A (Library functions) ``` -------------------------------- ### Read Capacitive Touchpads Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Reads the capacitive touchpads (PAD1, PAD2, PAD3) on Inkplate boards. Returns 1 if touched, 0 otherwise. Requires the Inkplate library. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_1BIT); int value = 0; void setup() { display.begin(); display.clearDisplay(); display.display(); display.setTextSize(5); display.setTextColor(BLACK, WHITE); } void loop() { // Read touchpads using PAD1, PAD2, PAD3 constants // Returns 1 if touched, 0 if not if (display.readTouchpad(PAD1)) { value--; updateDisplay(); } if (display.readTouchpad(PAD2)) { value = 0; updateDisplay(); } if (display.readTouchpad(PAD3)) { value++; updateDisplay(); } delay(100); } void updateDisplay() { display.clearDisplay(); display.setCursor(350, 280); display.print(value); display.partialUpdate(); } ``` -------------------------------- ### Sensor Data Methods Source: https://github.com/solderedelectronics/inkplate-arduino-library/blob/master/src/libs/APDS9960/keywords.txt Methods to check availability and read data from the sensor for gestures, color, and proximity. ```APIDOC ## gestureAvailable ### Description Checks if a gesture is available to be read. ## readGesture ### Description Reads the detected gesture. ## colorAvailable ### Description Checks if color data is available. ## readColor ### Description Reads the detected color values. ## proximityAvailable ### Description Checks if proximity data is available. ## readProximity ### Description Reads the proximity value. ``` -------------------------------- ### display.drawTextBox() Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Renders text within a bounded rectangular area with automatic word wrapping, custom fonts, and optional border. ```APIDOC ## display.drawTextBox() ### Description Renders text within a bounded rectangular area with automatic word wrapping, custom fonts, and optional border. ### Method N/A (Library function) ### Endpoint N/A (Library function) ### Parameters N/A (Library function) ### Request Example ```cpp #include "Inkplate.h" #include "Fonts/FreeSans12pt7b.h" Inkplate display(INKPLATE_3BIT); const char* loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."; void setup() { display.begin(); display.clearDisplay(); display.setTextColor(0); // drawTextBox(x0, y0, x1, y1, text, textSize, font, verticalSpacing, showBorder, fontSize) display.drawTextBox(50, 50, 350, 250, loremIpsum, 1, &FreeSans12pt7b, 5, true, 12); // Simple text box without custom font display.drawTextBox(400, 50, 750, 250, loremIpsum, 2, NULL, 0, true, 8); display.display(); } void loop() {} ``` ### Response N/A (Library function) ``` -------------------------------- ### display.setFullUpdateThreshold() Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Configures the number of partial updates allowed before the library automatically performs a full refresh to clear ghosting. ```APIDOC ## display.setFullUpdateThreshold() ### Description Sets the number of partial updates before the library automatically triggers a full refresh. This helps maintain image quality by periodically clearing ghosting artifacts. ### Parameters #### Arguments - **threshold** (int) - Required - The number of partial updates to perform before a full refresh is triggered. ``` -------------------------------- ### Drawing Images from SD Card Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Load and display BMP, JPEG, or PNG images from an SD card. The library handles image decoding and optional dithering. ```APIDOC ## Drawing Images from SD Card ### Description Load and display BMP, JPEG, or PNG images from an SD card. The library handles image decoding and optional dithering. ### Method N/A (Library functions) ### Endpoint N/A (Library functions) ### Parameters N/A (Library functions) ### Request Example ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_3BIT); void setup() { display.begin(); display.clearDisplay(); display.setTextSize(2); // Initialize SD card if (display.sdCardInit()) { display.println("SD Card OK!"); display.display(); // Draw BMP image (filename, x, y, dither, invert) if (!display.drawImage("photo.bmp", 0, 0, true, false)) { display.println("Error loading BMP"); display.display(); } display.display(); delay(5000); // Draw JPEG image display.clearDisplay(); if (!display.drawImage("photo.jpg", 50, 50, true, false)) { display.println("Error loading JPEG"); } display.display(); delay(5000); // Draw PNG image display.clearDisplay(); if (!display.drawPngFromSd("icon.png", 200, 200, true, false)) { display.println("Error loading PNG"); } display.display(); // Put SD card to sleep to save power display.sdCardSleep(); } else { display.println("SD Card Error!"); display.display(); } } void loop() {} ``` ### Response N/A (Library functions) ``` -------------------------------- ### Control Frontlight Brightness Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Controls the built-in frontlight LED array on Inkplate 6PLUS. Allows setting brightness (0-63) and adjusting it via serial input. Requires the Inkplate library. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_1BIT); void setup() { Serial.begin(115200); // display.setInkplatePowerMode(INKPLATE_USB_PWR_ONLY); // Uncomment for USB-only models display.begin(); display.clearDisplay(); display.display(); // Enable frontlight circuit display.frontlight(true); // Set brightness (0-63) display.setFrontlight(32); // 50% brightness } void loop() { // Adjust brightness based on serial input if (Serial.available()) { char c = Serial.read(); static int brightness = 32; if (c == '+' && brightness < 63) { brightness++; display.setFrontlight(brightness); } if (c == '-' && brightness > 0) { brightness--; display.setFrontlight(brightness); } Serial.printf("Brightness: %d/63\n", brightness); } } ``` -------------------------------- ### Create Custom Font Header File Source: https://github.com/solderedelectronics/inkplate-arduino-library/blob/master/extras/fontconvert/fontconvert_win.md Use the compiled fontconvert executable to convert a TTF font file into a header file compatible with Adafruit GFX library. Specify the TTF file, desired point size, and output header file name. ```bash ./fontconvert yourfonts.ttf 9 > yourfonts9pt7b.h ``` -------------------------------- ### Clear Frame Buffer with display.clearDisplay() Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Clears the internal memory buffer to white. A subsequent call to display() or partialUpdate() is required to reflect changes on the screen. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_1BIT); void setup() { display.begin(); display.clearDisplay(); // Clear frame buffer (not visible yet) display.display(); // Now the screen shows clear/white // Draw something display.fillCircle(400, 300, 100, BLACK); display.display(); delay(3000); // Clear and refresh again display.clearDisplay(); display.display(); } void loop() {} ``` -------------------------------- ### Manage RTC Time and Date Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Use these functions to set and retrieve time and date data from the onboard PCF85063A RTC. Requires an active battery backup to maintain time while powered off. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_1BIT); void setup() { display.begin(); display.clearDisplay(); display.setTextSize(3); // Set initial time (hour, minute, second) display.rtcSetTime(14, 30, 0); // Set initial date (weekday 0=Sunday, day, month, year) display.rtcSetDate(3, 15, 6, 2024); // Wednesday, June 15, 2024 // Alternative: set from Unix epoch // display.rtcSetEpoch(1718457600); } void loop() { // Read all RTC data at once display.rtcGetRtcData(); // Get individual values uint8_t hour = display.rtcGetHour(); uint8_t minute = display.rtcGetMinute(); uint8_t second = display.rtcGetSecond(); uint8_t day = display.rtcGetDay(); uint8_t month = display.rtcGetMonth(); uint16_t year = display.rtcGetYear(); uint8_t weekday = display.rtcGetWeekday(); display.clearDisplay(); display.setCursor(50, 100); display.printf("%02d:%02d:%02d", hour, minute, second); display.setCursor(50, 180); display.printf("%02d/%02d/%04d", day, month, year); display.partialUpdate(); delay(1000); } ``` -------------------------------- ### Read Onboard Temperature Sensor Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Reads the temperature from the onboard sensor available on most Inkplate models. Displays the temperature in both Celsius and Fahrenheit. Requires the Inkplate library. ```cpp #include "Inkplate.h" Inkplate display(INKPLATE_1BIT); void setup() { display.begin(); display.setTextSize(3); } void loop() { display.clearDisplay(); display.setCursor(100, 300); // Read temperature in Celsius (returns int8_t) int8_t temperature = display.readTemperature(); display.print("Temperature: "); display.print(temperature); display.print(" C / "); display.print((temperature * 9/5) + 32); display.println(" F"); display.display(); delay(5000); } ``` -------------------------------- ### display.clearDisplay() Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Clears the internal frame buffer. ```APIDOC ## display.clearDisplay() ### Description Sets all pixels in the internal frame buffer to white. Does not update the physical screen until display() or partialUpdate() is called. ### Request Example ```cpp display.clearDisplay(); display.display(); ``` ``` -------------------------------- ### Configure Makefile for fontconvert Source: https://github.com/solderedelectronics/inkplate-arduino-library/blob/master/extras/fontconvert/fontconvert_win.md Modify the makefile for fontconvert.c to include the FreeType library path and compiler flags. This ensures the compiler can find FreeType headers and link against the library. ```makefile all: fontconvert CC = gcc CFLAGS = -Wall -I c:/mingw/include/freetype2 LIBS = -lfreetype fontconvert: fontconvert.c $(CC) $(CFLAGS) $< $(LIBS) -o $@ clean: rm -f fontconvert ``` -------------------------------- ### Drawing Text Boxes with Inkplate Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Renders text within a specified rectangular area with automatic word wrapping. Supports custom fonts, vertical spacing, borders, and different font sizes. ```cpp #include "Inkplate.h" #include "Fonts/FreeSans12pt7b.h" Inkplate display(INKPLATE_3BIT); const char* loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."; void setup() { display.begin(); display.clearDisplay(); display.setTextColor(0); // drawTextBox(x0, y0, x1, y1, text, textSize, font, verticalSpacing, showBorder, fontSize) display.drawTextBox(50, 50, 350, 250, loremIpsum, 1, &FreeSans12pt7b, 5, true, 12); // Simple text box without custom font display.drawTextBox(400, 50, 750, 250, loremIpsum, 2, NULL, 0, true, 8); display.display(); } void loop() {} ``` -------------------------------- ### Configure RTC Alarms for Deep Sleep Source: https://context7.com/solderedelectronics/inkplate-arduino-library/llms.txt Set alarms to trigger wakeups from deep sleep. Ensure the alarm flag is cleared after waking to prevent immediate re-triggering. ```cpp #include "Inkplate.h" #include "driver/rtc_io.h" Inkplate display(INKPLATE_1BIT); void setup() { display.begin(); display.clearDisplay(); display.setTextSize(2); // Set current time display.rtcSetTime(14, 30, 0); display.rtcSetDate(3, 15, 6, 2024); // Set alarm for 14:31:00 (second, minute, hour, day, weekday) // Use 99 for fields you don't want to match display.rtcSetAlarm(0, 31, 14, 99, 99); // Alarm at 14:31:00 any day // Alternative: set alarm from epoch with match criteria // RTC_ALARM_MATCH_MMSS - match minute and second // RTC_ALARM_MATCH_HHMMSS - match hour, minute, and second // display.rtcSetAlarmEpoch(1718457660, RTC_ALARM_MATCH_HHMMSS); display.println("Alarm set for 14:31:00"); display.println("Going to deep sleep..."); display.display(); // Enable wake on RTC alarm interrupt (GPIO39 on most Inkplates) esp_sleep_enable_ext0_wakeup(GPIO_NUM_39, 0); // Enter deep sleep esp_deep_sleep_start(); } void loop() { // After wake, check if alarm triggered if (display.rtcCheckAlarmFlag()) { display.println("Woke from alarm!"); display.rtcClearAlarmFlag(); // Clear the flag } display.display(); } ```