/**
 **************************************************
 * @file        Inkplate2_Image_Converter.ino
 * @brief       Example showing how to display an image on Inkplate 2
 *              using the Soldered Image Converter tool.
 *
 * @details     This example demonstrates how to use the Soldered Image
 *              Converter to prepare an image for display on Inkplate 2.
 *              The tool converts any image into a C byte array stored in
 *              a header file (.h) which can be directly included in your
 *              Arduino sketch.
 *
 *              Tool workflow:
 *              1. Open the Image Converter at https://tools.soldered.com/tools/image-converter/
 *              2. Upload your image and select "Inkplate 2" as the target board.
 *              3. Choose the display mode:
 *                 - Color mode — black, white, and red
 *              4. Adjust dithering, resize, and other options as needed.
 *              5. Save the generated header file (image.h) and place it
 *                 in the same folder as this sketch.
 *
 * Requirements:
 * - Board:      Soldered Inkplate 2
 * - Hardware:   Inkplate 2, USB cable
 * - Extra:      The image header file (image.h) generated by the tool
 *
 * Configuration:
 * - Boards Manager -> Inkplate Boards -> Soldered Inkplate2
 *
 * Don't have Inkplate Boards in Arduino Boards Manager?
 * See https://docs.soldered.com/inkplate/2/quick-start-guide/
 *
 * How to use:
 * 1) Generate image.h using the Image Converter at https://tools.soldered.com/tools/image-converter/
 * 2) Place image.h in the same folder as this sketch.
 * 3) Select "Soldered Inkplate2" from Tools → Board.
 * 4) Upload the sketch to Inkplate 2.
 * 5) The image appears on the display after initialization.
 *
 * Expected output:
 * - Your converted image displayed on the Inkplate 2 e-paper screen.
 *
 * Notes:
 * - image_w and image_h are automatically defined in the generated image.h.
 * - display.clearDisplay() clears only the internal framebuffer.
 * - display.display() must be called to push the framebuffer to the screen.
 *
 * Docs:         https://docs.soldered.com/inkplate
 * Support:      https://soldered.com/pages/contact
 * Image tool:   https://tools.soldered.com/tools/image-converter/
 *
 * @author      Soldered
 * @date        April 2026
 * @license     GNU GPL V3
 **************************************************/

// Next 3 lines are a precaution, you can ignore those, and the example would also work without them
#ifndef ARDUINO_INKPLATE2
#error "Wrong board selection for this example, please select Soldered Inkplate2 in the boards menu."
#endif

#include "Inkplate.h" // Include the Inkplate library
#include "image.h"    // Include the image header generated by the Image Converter tool

Inkplate display; // Create an Inkplate object for Inkplate 2

void setup() {
    display.begin();        // Initialize the display hardware
    display.clearDisplay(); // Clear the frame buffer (does NOT clear the physical screen)

    display.image.draw(image, 0, 0, image_w, image_h); // Arguments are: array variable name, start X, start Y,  size X, size Y

    display.display(); // Refresh the e-paper display to show the image
}

void loop() {
    // No code needed here for this example
}
