diff --git a/RaspberryPi_JetsonNano/c/examples/EPD_3in7_test.c b/RaspberryPi_JetsonNano/c/examples/EPD_3in7_test.c index 347d72b..b6f3a7a 100644 --- a/RaspberryPi_JetsonNano/c/examples/EPD_3in7_test.c +++ b/RaspberryPi_JetsonNano/c/examples/EPD_3in7_test.c @@ -51,10 +51,13 @@ int EPD_3in7_test(void) //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_3IN7_WIDTH % 4 == 0)? (EPD_3IN7_WIDTH / 4 ): (EPD_3IN7_WIDTH / 4 + 1)) * EPD_3IN7_HEIGHT; + + // Allocate enough for for 4 bits for each pixel (16 gray) + // If you don't use the dithering, this will only need to be 2 bits per pixel + // you may have to edit the startup_stm32fxxx.s file and set a big enough heap size + int Imagesize = (EPD_3IN7_WIDTH + 1) / 2 * EPD_3IN7_HEIGHT; if((BlackImage = (UBYTE *)malloc(Imagesize)) == NULL) { - printf("Failed to apply for black memory...\r\n"); + printf("Failed to apply for memory...\r\n"); return -1; } @@ -154,6 +157,27 @@ int EPD_3in7_test(void) DEV_Delay_ms(500); } +#if 1 // show dithered bmp + EPD_3IN7_4Gray_Init(); // Clear + EPD_3IN7_4Gray_Clear(); + + EPD_3IN7_1Gray_Init(); //init 1 Gray mode + EPD_3IN7_1Gray_Clear(); + + Paint_NewImage(BlackImage, 280, 480, 0, WHITE); + Paint_SetScale(16); + Paint_Clear(WHITE); + + printf("show dithered BMP with Sierra-Lite\r\n"); + GUI_ReadBmp_16Gray("./pic/3in7_4bit1.bmp", 0, 0); + EPD_3IN7_1Gray_Display_Dithered(BlackImage, 0); + DEV_Delay_ms(4000); + + printf("show dithered BMP with Floyd-Steinberg\r\n"); + EPD_3IN7_1Gray_Display_Dithered(BlackImage, 1); + DEV_Delay_ms(4000); +#endif + #endif EPD_3IN7_4Gray_Init(); printf("Clear...\r\n"); diff --git a/RaspberryPi_JetsonNano/c/pic/3in7_4bit1.bmp b/RaspberryPi_JetsonNano/c/pic/3in7_4bit1.bmp new file mode 100644 index 0000000..62e7248 Binary files /dev/null and b/RaspberryPi_JetsonNano/c/pic/3in7_4bit1.bmp differ