📄 kitronix320x240x16_ssd2119_8bit.c
字号:
//
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;
}
//
// We are being passed data in the display's native format. Merely
// write it directly to the display. This is a special case which is
// not used by the graphics library but which is helpful to
// applications which may want to handle, for example, JPEG images.
//
case 16:
{
unsigned short usByte;
//
// 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.
//
usByte = *((unsigned short *)pucData);
pucData += 2;
//
// Translate this palette entry and write it to the screen.
//
WriteData(usByte);
}
}
}
}
//*****************************************************************************
//
//! 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.
//
//*****************************************************************************
static void
Kitronix240x320x16_SD60154LineDrawH(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(S6D0154_ENTRY_MODE_REG);
WriteData(MAKE_ENTRY_MODE(HORIZ_DIRECTION));
//
// Set the starting X address of the display cursor.
//
WriteCommand(S6D0154_H_RAM_ADDR_REG);
WriteData(MAPPED_X(lX1, lY));
//
// Set the Y address of the display cursor.
//
WriteCommand(S6D0154_V_RAM_ADDR_REG);
WriteData(MAPPED_Y(lX1, lY));
//
// Write the data RAM write command.
//
WriteCommand(S6D0154_RAM_DATA_REG);
//
// 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.
//
//*****************************************************************************
static void
Kitronix240x320x16_SD60154LineDrawV(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(S6D0154_ENTRY_MODE_REG);
WriteData(MAKE_ENTRY_MODE(VERT_DIRECTION));
//
// Set the X address of the display cursor.
//
WriteCommand(S6D0154_H_RAM_ADDR_REG);
WriteData(MAPPED_X(lX, lY1));
//
// Set the starting Y address of the display cursor.
//
WriteCommand(S6D0154_V_RAM_ADDR_REG);
WriteData(MAPPED_Y(lX, lY1));
//
// Write the data RAM write command.
//
WriteCommand(S6D0154_RAM_DATA_REG);
//
// 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.
//
//*****************************************************************************
static void
Kitronix240x320x16_SD60154RectFill(void *pvDisplayData, const tRectangle *pRect,
unsigned long ulValue)
{
long lCount;
//
// Write the Y extents of the rectangle.
//
WriteCommand(S6D0154_ENTRY_MODE_REG);
WriteData(MAKE_ENTRY_MODE(HORIZ_DIRECTION));
//
// Write the X extents of the rectangle.
//
WriteCommand(S6D0154_H_WINDOW_START_REG);
#if (defined PORTRAIT) || (defined LANDSCAPE)
WriteData(MAPPED_X(pRect->sXMax, pRect->sYMax));
#else
WriteData(MAPPED_X(pRect->sXMin, pRect->sYMin));
#endif
WriteCommand(S6D0154_H_WINDOW_END_REG);
#if (defined PORTRAIT) || (defined LANDSCAPE)
WriteData(MAPPED_X(pRect->sXMin, pRect->sYMin));
#else
WriteData(MAPPED_X(pRect->sXMax, pRect->sYMax));
#endif
//
// Write the Y extents of the rectangle
//
WriteCommand(S6D0154_V_WINDOW_START_REG);
#if (defined LANDSCAPE_FLIP) || (defined PORTRAIT)
WriteData(MAPPED_Y(pRect->sXMin, pRect->sYMin));
#else
WriteData(MAPPED_Y(pRect->sXMax, pRect->sYMax));
#endif
WriteCommand(S6D0154_V_WINDOW_END_REG);
#if (defined LANDSCAPE_FLIP) || (defined PORTRAIT)
WriteData(MAPPED_Y(pRect->sXMax, pRect->sYMax));
#else
WriteData(MAPPED_Y(pRect->sXMin, pRect->sYMin));
#endif
//
// Set the display cursor to the upper left of the rectangle (in application
// coordinate space).
//
WriteCommand(S6D0154_H_RAM_ADDR_REG);
WriteData(MAPPED_X(pRect->sXMin, pRect->sYMin));
WriteCommand(S6D0154_V_RAM_ADDR_REG);
WriteData(MAPPED_Y(pRect->sXMin, pRect->sYMin));
//
// Tell the controller we are about to write data into its RAM.
//
WriteCommand(S6D0154_RAM_DATA_REG);
//
// Loop through the pixels of this filled rectangle.
//
for(lCount = ((pRect->sXMax - pRect->sXMin + 1) *
(pRect->sYMax - pRect->sYMin + 1)); lCount >= 0; lCount--)
{
//
// Write the pixel value.
//
WriteData(ulValue);
}
//
// Reset the X extents to the entire screen.
//
WriteCommand(S6D0154_H_WINDOW_END_REG);
WriteData(0x00ef);
WriteCommand(S6D0154_H_WINDOW_START_REG);
WriteData(0x0000);
//
// Reset the Y extent to the full screen
//
WriteCommand(S6D0154_V_WINDOW_END_REG);
WriteData(0x013f);
WriteCommand(S6D0154_V_WINDOW_START_REG);
WriteData(0x0000);
}
//*****************************************************************************
//
//! Translates a 24-bit RGB color to a display driver-specific color.
//!将颜色转换成RGB的值
//! \param pvDisplayData is a pointer to the driver-specific data for this
//! display driver.
//! \param ulValue is the 24-bit RGB color. The least-significant byte is the
//! blue channel, the next byte is the green channel, and the third byte is the
//! red channel.
//!最低位为
//! This function translates a 24-bit RGB color into a value that can be
//! written into the display's frame buffer in order to reproduce that color,
//! or the closest possible approximation of that color.
//!
//! \return Returns the display-driver specific color.
//
//*****************************************************************************
static unsigned long
Kitronix240x320x16_SD60154ColorTranslate(void *pvDisplayData,
unsigned long ulValue)
{
//
// Translate from a 24-bit RGB color to a 5-6-5 RGB color.
//
return(DPYCOLORTRANSLATE(ulValue));
}
//*****************************************************************************
//
//! Flushes any cached drawing operations.
//!
//! \param pvDisplayData is a pointer to the driver-specific data for this
//! display driver.
//!
//! This functions flushes any cached drawing operations to the display. This
//! is useful when a local frame buffer is used for drawing operations, and the
//! flush would copy the local frame buffer to the display. For the SSD2119
//! driver, the flush is a no operation.
//!
//! \return None.
//刷新
//*****************************************************************************
static void
Kitronix240x320x16_SD60154Flush(void *pvDisplayData)
{
//
// There is nothing to be done.
//
}
//*****************************************************************************
//
//! The display structure that describes the driver for the Kitronix
//! K350QVG-V1-F TFT panel with an SSD2119 controller.
//
//*****************************************************************************
const tDisplay g_sKitronix320x240x16_SSD2119 =
{
sizeof(tDisplay),
0,
#if defined(PORTRAIT) || defined(PORTRAIT_FLIP)
320,
240,
#else
240,
320,
#endif
Kitronix240x320x16_SD60154PixelDraw,
Kitronix240x320x16_SD60154PixelDrawMultiple,
Kitronix240x320x16_SD60154LineDrawH,
Kitronix240x320x16_SD60154LineDrawV,
Kitronix240x320x16_SD60154RectFill,
Kitronix240x320x16_SD60154ColorTranslate,
Kitronix240x320x16_SD60154Flush
};
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -