/**
 * Inkplate5V2_Dither_Kernel_SD.ino
 * Switch dithering kernel and display image from SD card on Inkplate 5V2.
 */

#ifndef ARDUINO_INKPLATE5V2
#error "Wrong board selection for this example, please select Soldered Inkplate5 V2 in the boards menu."
#endif

#include "Inkplate.h"

Inkplate display(INKPLATE_3BIT); // 3-bit grayscale mode, dithering applies here

void setup()
{
    display.begin();
    display.clearDisplay();
    display.setTextColor(BLACK);
    display.setTextSize(3);

    if (display.sdCardInit())
    {
        display.println("SD Card OK! Reading image...");
        display.display();

        // Available kernels (Image::DitherKernel enum):
        // FloydSteinberg  - default, classic error diffusion
        // JarvisJudiceNinke - wider diffusion, smoother, slower
        // Atkinson        - lighter diffusion, less noise, used on classic Mac
        // Burkes          - simplified JJN variant
        // Stucki          - similar to JJN, sharper
        // SierraLite      - lightweight, fast
        // ReducedDiffusion - minimal diffusion, faster/coarser
        display.image.setDitherKernel(Image::JarvisJudiceNinke);

        display.clearDisplay();
        if (!display.image.draw("picture2.jpg", 0, 0, true)) // dither = true
        {
            display.println("Image open error");
        }
        display.display();
    }
    else
    {
        display.println("SD Card error!");
        display.display();
    }

    display.sdCardSleep();
}

void loop()
{
    // Nothing...
}