E-Ink Display shows image zoomed in

Setup:
ESP32 WROOM 32 Devkit V1
Waveshare 4.2inch e-Paper Module rev2.2, b/w 4 gray with logic converter /added: Link to display
Waveshare demo library (Waveshare Download)
Waveshare demo library (github e-paper )

Software:
Photoshop to set the image size (400 x 300 pixels) and then convert to 4 gray scale
Image2lcd v3.2 to convert the image to c array and reverse the color for the display

Rightio guys, basically at the end of my tether with this one. Was hoping to make this as a gift for someone, however it's proved to be more challenging than I expected.

I have tried a number of library's to no avail, this includes the famous GxEPD library by @ZinggJM and I must say, the library and examples are written very well, however I have come to the conclusion that my revision of the display is not included, and so I have found that the demo from waveshare themselves seems to work to some extent. Documentation regarding commands and such seems to be lacking or I am just struggling to get my head around it.

My issue that I am coming up against is that when I generate my own bmp images and then convert them to c arrays, the image shows up zoomed in, however, when I use the images from the demo, there is no issues at all. so I am at a loss.

Any help is much appreciated! Thanks

Here is my code so far, it is basic, I am just trying to display an image at the moment...

/* Includes ------------------------------------------------------------------*/
#include "DEV_Config.h"
#include "EPD.h"
#include "GUI_Paint.h"
#include "imagedata.h"
#include <stdlib.h>

/* Entry point ----------------------------------------------------------------*/
void setup()
{
    printf("EPD_4IN2_V2_test Demo\r\n");
    DEV_Module_Init();

    printf("e-Paper Init and Clear...\r\n");
    EPD_4IN2_V2_Init();
    EPD_4IN2_V2_Clear();
    DEV_Delay_ms(500);

    //Create a new image cache
    UBYTE *BlackImage;
    /* you have to edit the startup_stm32fxxx.s file and set a big enough heap size */
    UWORD Imagesize = ((EPD_4IN2_V2_WIDTH % 8 == 0)? (EPD_4IN2_V2_WIDTH / 8 ): (EPD_4IN2_V2_WIDTH / 8 + 1)) * EPD_4IN2_V2_HEIGHT;
    if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
        printf("Failed to apply for black memory...\r\n");
        while (1);
    }
    printf("Paint_NewImage\r\n");
    Paint_NewImage(BlackImage, EPD_4IN2_V2_WIDTH, EPD_4IN2_V2_HEIGHT, 0, WHITE);

#if 1  // show bmp
    // printf("show window BMP-----------------\r\n");
    Paint_SelectImage(BlackImage);
    Paint_Clear(WHITE);
    Paint_DrawBitMap(gImage_barb);
    Paint_DrawImage(gImage_barb, 0, 0, 400, 300); 
    EPD_4IN2_V2_Display(BlackImage);
    DEV_Delay_ms(2000);
    
#endif        

    // EPD_4IN2_V2_Init();
    // EPD_4IN2_V2_Clear();
    // printf("Goto Sleep...\r\n");
    EPD_4IN2_V2_Sleep();
    free(BlackImage);
    BlackImage = NULL;

}

Following on from this, here is the BMP image I am using as a placeholder for now, it will not allow me to upload the BMP so here is the original image.

This is the c array code after I have set the size to 400 x 300 and converted the image to 4 gray scale

barb.c (150.2 KB)

And finally what i see in the screen of the display

My Settings on Image2LCD v3.2

Quick thought: try rotating the image. By default these sort of displays seem to be portrait, not landscape.

Alternatively, the library might allow you to set rotation somehow.

Edit: for future reference, this was an "off-the-cuff" response, and after a few moments of research I suspect that this is untrue and irrelevant for this display.

I have made some progress... by adding the 4 lines after the first comment, it will now drawer about half the image on the display

#if 1  // show bmp
    // printf("show window BMP-----------------\r\n");
    EPD_4IN2_V2_Init_4Gray();
    Paint_SelectImage(BlackImage);
    DEV_Delay_ms(2000);
    Paint_Clear(WHITE);
    
    // Paint_DrawBitMap(gImage_barb); 
    Paint_DrawImage(gImage_barb, 0, 0, 400, 300); 
    EPD_4IN2_V2_Display_4Gray(BlackImage);
    // EPD_4IN2_V2_Display(BlackImage);
    DEV_Delay_ms(2000);
    
#endif    

@toddnz if i rotate it in photoshop and then tell the esp to rotate it again will it make a difference?

Issue has been resolved. I don't understand if all this code is necessary, however it has the expected results now.

Good luck and have fun kids!

/* Includes ------------------------------------------------------------------*/
#include "DEV_Config.h"
#include "EPD.h"
#include "GUI_Paint.h"
#include "imagedata.h"
#include <stdlib.h>

/* Entry point ----------------------------------------------------------------*/
void setup()
{    
    printf("Beginning Setup------------------\r\n");
    DEV_Module_Init();      //Needs to be present
    EPD_4IN2_V2_Init();     //Needs to be present
    EPD_4IN2_V2_Clear();    //Needs to be present - Clears display on boot
    // DEV_Delay_ms(500);      //Needs to be present - Waits some time to let display chill


    //Setup the environment and catch errors
    UBYTE *BlackImage;
    UWORD Imagesize = ((EPD_4IN2_V2_WIDTH % 8 == 0)? (EPD_4IN2_V2_WIDTH / 8 ): (EPD_4IN2_V2_WIDTH / 8 + 1)) * EPD_4IN2_V2_HEIGHT;
    if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
        printf("Failed to apply for black memory...\r\n");
        while (1);
    }
    //End Environment setup
    printf("Setup Complete-------------------\r\n");

    

#if 1

    printf("show Image-----------------------\r\n");
    EPD_4IN2_V2_Init_4Gray();
    free(BlackImage);
    BlackImage = NULL;
    Imagesize = ((EPD_4IN2_V2_WIDTH % 8 == 0)? (EPD_4IN2_V2_WIDTH / 4 ): (EPD_4IN2_V2_WIDTH / 4 + 1)) * EPD_4IN2_V2_HEIGHT;
    if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) {
        printf("Failed to apply for black memory...\r\n");
        while (1);
    }
    Paint_NewImage(BlackImage, EPD_4IN2_V2_WIDTH, EPD_4IN2_V2_HEIGHT, 0, WHITE);
    Paint_SetScale(4);
    Paint_Clear(WHITE);
    EPD_4IN2_V2_Display_4Gray(BlackImage);
    DEV_Delay_ms(2000);

    Paint_Clear(WHITE);
    Paint_DrawBitMap(gImage_barb);
    EPD_4IN2_V2_Display_4Gray(BlackImage);
    DEV_Delay_ms(2000);

#endif

    // EPD_4IN2_V2_Init();
    // EPD_4IN2_V2_Clear();
    printf("Goto Sleep...\r\n");
    EPD_4IN2_V2_Sleep();
    free(BlackImage);
    BlackImage = NULL;

}

/* The main loop -------------------------------------------------------------*/
void loop()
{
  //
}

1 Like

Well spotted!

This seems to be key. Glancing at the Waveshare library code, it seems that GUI_Paint is storing the 4 shades of gray in one continuous array, rather than separating them. If Paint_SetScale() is not changed to 4 (from the default of 2), the BlackImage array is being filled twice as fast as it should, causing only half of the image to display.

now that you explain it, it makes a lot of sense! glad this is solved now

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.