📄 Ȧ-
字号:
//! contains 24-bit RGB values that must be translated before being written to
//! the display.
//!
//! \return None.
//
//*****************************************************************************
void Formike240x320x16_ILI9320PixelDrawMultiple(void *pvDisplayData, long lX,
long lY, long lX0, long lCount,
long lBPP,
const unsigned char *pucData,
const unsigned char *pucPalette)
{
unsigned long ulByte;
//
// Set the cursor increment to left to right, followed by top to bottom.
//
WriteCommand(0x03);
#ifdef PORTRAIT
WriteData(0x0030);
#endif
#ifdef LANDSCAPE
WriteData(0x0028);
#endif
#ifdef PORTRAIT_FLIP
WriteData(0x0000);
#endif
#ifdef LANDSCAPE_FLIP
WriteData(0x0018);
#endif
//
// Set the starting X address of the display cursor.
//
WriteCommand(0x20);
#ifdef PORTRAIT
WriteData(lX);
#endif
#ifdef LANDSCAPE
WriteData(239 - lY);
#endif
#ifdef PORTRAIT_FLIP
WriteData(239 - lX);
#endif
#ifdef LANDSCAPE_FLIP
WriteData(lY);
#endif
//
// Set the Y address of the display cursor.
//
WriteCommand(0x21);
#ifdef PORTRAIT
WriteData(lY);
#endif
#ifdef LANDSCAPE
WriteData(lX);
#endif
#ifdef PORTRAIT_FLIP
WriteData(319 - lY);
#endif
#ifdef LANDSCAPE_FLIP
WriteData(319 - lX);
#endif
//
// Write the data RAM write command.
//
WriteCommand(0x22);
//
// Determine how to interpret the pixel data based on the number of bits
// per pixel.
//
switch(lBPP)
{
//
// The pixel data is in 1 bit per pixel format.
//
case 1:
{
//
// Loop while there are more pixels to draw.
//
while(lCount)
{
//
// Get the next byte of image data.
//
ulByte = *pucData++;
//
// Loop through the pixels in this byte of image data.
//
for(; (lX0 < 8) && lCount; lX0++, lCount--)
{
//
// Draw this pixel in the appropriate color.
//
WriteData(((unsigned long *)pucPalette)[(ulByte >>
(7 - lX0)) & 1]);
}
//
// Start at the beginning of the next byte of image data.
//
lX0 = 0;
}
//
// The image data has been drawn.
//
break;
}
//
// The pixel data is in 4 bit per pixel format.
//
case 4:
{
//
// Loop while there are more pixels to draw. "Duff's device" is
// used to jump into the middle of the loop if the first nibble of
// the pixel data should not be used. Duff's device makes use of
// the fact that a case statement is legal anywhere within a
// sub-block of a switch statement. See
// http://en.wikipedia.org/wiki/Duff's_device for detailed
// information about Duff's device.
//
switch(lX0 & 1)
{
case 0:
while(lCount)
{
//
// Get the upper nibble of the next byte of pixel data
// and extract the corresponding entry from the
// palette.
//
ulByte = (*pucData >> 4) * 3;
ulByte = (*(unsigned long *)(pucPalette + ulByte) &
0x00ffffff);
//
// Translate this palette entry and write it to the
// screen.
//
WriteData(DPYCOLORTRANSLATE(ulByte));
//
// Decrement the count of pixels to draw.
//
lCount--;
//
// See if there is another pixel to draw.
//
if(lCount)
{
case 1:
//
// Get the lower nibble of the next byte of pixel
// data and extract the corresponding entry from
// the palette.
//
ulByte = (*pucData++ & 15) * 3;
ulByte = (*(unsigned long *)(pucPalette + ulByte) &
0x00ffffff);
//
// Translate this palette entry and write it to the
// screen.
//
WriteData(DPYCOLORTRANSLATE(ulByte));
//
// Decrement the count of pixels to draw.
//
lCount--;
}
}
}
//
// The image data has been drawn.
//
break;
}
//
// The pixel data is in 8 bit per pixel format.
//
case 8:
{
//
// Loop while there are more pixels to draw.
//
while(lCount--)
{
//
// Get the next byte of pixel data and extract the
// corresponding entry from the palette.
//
ulByte = *pucData++ * 3;
ulByte = *(unsigned long *)(pucPalette + ulByte) & 0x00ffffff;
//
// Translate this palette entry and write it to the screen.
//
WriteData(DPYCOLORTRANSLATE(ulByte));
}
//
// The image data has been drawn.
//
break;
}
}
}
//*****************************************************************************
//
//! Draws a horizontal line.
//!
//! \param pvDisplayData is a pointer to the driver-specific data for this
//! display driver.
//! \param lX1 is the X coordinate of the start of the line.
//! \param lX2 is the X coordinate of the end of the line.
//! \param lY is the Y coordinate of the line.
//! \param ulValue is the color of the line.
//!
//! This function draws a horizontal line on the display. The coordinates of
//! the line are assumed to be within the extents of the display.
//!
//! \return None.
//
//*****************************************************************************
void Formike240x320x16_ILI9320LineDrawH(void *pvDisplayData, long lX1, long lX2,
long lY, unsigned long ulValue)
{
//
// Set the cursor increment to left to right, followed by top to bottom.
//
WriteCommand(0x03);
#ifdef PORTRAIT
WriteData(0x0030);
#endif
#ifdef LANDSCAPE
WriteData(0x0028);
#endif
#ifdef PORTRAIT_FLIP
WriteData(0x0000);
#endif
#ifdef LANDSCAPE_FLIP
WriteData(0x0018);
#endif
//
// Set the starting X address of the display cursor.
//
WriteCommand(0x20);
#ifdef PORTRAIT
WriteData(lX1);
#endif
#ifdef LANDSCAPE
WriteData(239 - lY);
#endif
#ifdef PORTRAIT_FLIP
WriteData(239 - lX1);
#endif
#ifdef LANDSCAPE_FLIP
WriteData(lY);
#endif
//
// Set the Y address of the display cursor.
//
WriteCommand(0x21);
#ifdef PORTRAIT
WriteData(lY);
#endif
#ifdef LANDSCAPE
WriteData(lX1);
#endif
#ifdef PORTRAIT_FLIP
WriteData(319 - lY);
#endif
#ifdef LANDSCAPE_FLIP
WriteData(319 - lX1);
#endif
//
// Write the data RAM write command.
//
WriteCommand(0x22);
//
// Loop through the pixels of this horizontal line.
//
while(lX1++ <= lX2)
{
//
// Write the pixel value.
//
WriteData(ulValue);
}
}
//*****************************************************************************
//
//! Draws a vertical line.
//!
//! \param pvDisplayData is a pointer to the driver-specific data for this
//! display driver.
//! \param lX is the X coordinate of the line.
//! \param lY1 is the Y coordinate of the start of the line.
//! \param lY2 is the Y coordinate of the end of the line.
//! \param ulValue is the color of the line.
//!
//! This function draws a vertical line on the display. The coordinates of the
//! line are assumed to be within the extents of the display.
//!
//! \return None.
//
//*****************************************************************************
void Formike240x320x16_ILI9320LineDrawV(void *pvDisplayData, long lX, long lY1,
long lY2, unsigned long ulValue)
{
//
// Set the cursor increment to top to bottom, followed by left to right.
//
WriteCommand(0x03);
#ifdef PORTRAIT
WriteData(0x0038);
#endif
#ifdef LANDSCAPE
WriteData(0x0020);
#endif
#ifdef PORTRAIT_FLIP
WriteData(0x0008);
#endif
#ifdef LANDSCAPE_FLIP
WriteData(0x0010);
#endif
//
// Set the X address of the display cursor.
//
WriteCommand(0x20);
#ifdef PORTRAIT
WriteData(lX);
#endif
#ifdef LANDSCAPE
WriteData(239 - lY1);
#endif
#ifdef PORTRAIT_FLIP
WriteData(239 - lX);
#endif
#ifdef LANDSCAPE_FLIP
WriteData(lY1);
#endif
//
// Set the starting Y address of the display cursor.
//
WriteCommand(0x21);
#ifdef PORTRAIT
WriteData(lY1);
#endif
#ifdef LANDSCAPE
WriteData(lX);
#endif
#ifdef PORTRAIT_FLIP
WriteData(319 - lY1);
#endif
#ifdef LANDSCAPE_FLIP
WriteData(319 - lX);
#endif
//
// Write the data RAM write command.
//
WriteCommand(0x22);
//
// Loop through the pixels of this vertical line.
//
while(lY1++ <= lY2)
{
//
// Write the pixel value.
//
WriteData(ulValue);
}
}
//*****************************************************************************
//
//! Fills a rectangle.
//!
//! \param pvDisplayData is a pointer to the driver-specific data for this
//! display driver.
//! \param pRect is a pointer to the structure describing the rectangle.
//! \param ulValue is the color of the rectangle.
//!
//! This function fills a rectangle on the display. The coordinates of the
//! rectangle are assumed to be within the extents of the display, and the
//! rectangle specification is fully inclusive (in other words, both sXMin and
//! sXMax are drawn, along with sYMin and sYMax).
//!
//! \return None.
//
//*****************************************************************************
void Formike240x320x16_ILI9320RectFill(void *pvDisplayData, const tRectangle *pRect,
unsigned long ulValue)
{
long lCount;
//
// Write the X extents of the rectangle.
//
WriteCommand(0x50);//发送命令
#ifdef PORTRAIT
WriteData(pRect->uiXMin);//X 起始坐标
#endif
#ifdef LANDSCAPE
WriteData(239 - pRect->uiYMax);
#endif
#ifdef PORTRAIT_FLIP
WriteData(239 - pRect->uiXMax);
#endif
#ifdef LANDSCAPE_FLIP
WriteData(pRect->uiYMin);
#endif
WriteCommand(0x51);//发送命令
#ifdef PORTRAIT
WriteData(pRect->uiXMax);//X 结束坐标
#endif
#ifdef LANDSCAPE
WriteData(239 - pRect->uiYMin);
#endif
#ifdef PORTRAIT_FLIP
WriteData(239 - pRect->uiXMin);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -