Add dithered function for 3.7 inch display

This commit is contained in:
mbartlett21 2022-10-03 11:00:23 +10:00
parent 7fc8527b4d
commit 1db3516bac
2 changed files with 53 additions and 0 deletions

View File

@ -536,6 +536,58 @@ void EPD_3IN7_1Gray_Display(const UBYTE *Image)
EPD_3IN7_ReadBusy_HIGH();
}
/******************************************************************************
function : Sends a 16-colour image to the display and dithers it to
black and white
parameter:
Ditherer:
Set to 0 to use Sierra-Lite dithering
Set to 1 to use Floyd-Steinberg dithering
******************************************************************************/
void EPD_3IN7_1Gray_Display_Dithered(const UBYTE *Image, int Ditherer)
{
int i;
int IMAGE_COUNTER = EPD_3IN7_WIDTH * EPD_3IN7_HEIGHT / 2; /* 4-bit */
int ditherdat = 0;
if (Ditherer == 0) /* Sierra-Lite */
ditherdat = 0x80;
else if (Ditherer == 1) /* Floyd-Steinberg */
ditherdat = 0x83;
else {
Debug("Ditherer can only be 0 or 1");
return;
}
EPD_3IN7_SendCommand(0x4E);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x4F);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x4D); /* Dithering engine start/stop */
EPD_3IN7_SendData(ditherdat);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x78);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendCommand(0x25); /* Write dithering RAM */
for (i = 0; i < IMAGE_COUNTER; i++)
EPD_3IN7_SendData(Image[i]);
EPD_3IN7_SendCommand(0x4D); /* Dithering engine start/stop */
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x00);
EPD_3IN7_SendData(0x78);
EPD_3IN7_SendData(0x00);
EPD_3IN7_Load_LUT(1); /* Do a full refresh of the display */
EPD_3IN7_SendCommand(0x20);
EPD_3IN7_ReadBusy_HIGH();
}
/******************************************************************************
function : Sends part the image buffer in RAM to e-Paper and displays
notes:

View File

@ -45,6 +45,7 @@ void EPD_3IN7_1Gray_Clear(void);
void EPD_3IN7_1Gray_Init(void);
void EPD_3IN7_1Gray_Display(const UBYTE *Image);
void EPD_3IN7_1Gray_Display_Part(const UBYTE *Image, UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend);
void EPD_3IN7_1Gray_Display_Dithered(const UBYTE *Image, int Ditherer);
void EPD_3IN7_Sleep(void);