📄 lcd.c
字号:
// beginning of the second frame buffer.
//
LCDCommandWrite(CMD_CSRW);
LCDDataWrite(0x00);
LCDDataWrite(0x30);
//
// Send the MWRITE command, which is used to fill the second frame buffer
// memory with all zeros (i.e. a blank display).
//
LCDCommandWrite(CMD_MWRITE);
for(ulIdx = 0; ulIdx < (40 * 240); ulIdx++)
{
LCDDataWrite(0x00);
}
//
// Send the DISPLAY_ON command to turn on the display and enables both
// frame buffers.
//
LCDCommandWrite(CMD_DISPLAY_ON);
LCDDataWrite(0x14);
//
// Send the CSRFORM command, which defines the size and appearance of the
// cursor.
//
LCDCommandWrite(CMD_CSRFORM);
LCDDataWrite(0x04);
LCDDataWrite(0x86);
}
//*****************************************************************************
//
//! Clears the screen.
//!
//! This functions clears the screen, turning off all pixels.
//!
//! \return None.
//
//*****************************************************************************
void
LCDClear(void)
{
unsigned long ulIdx;
//
// Send the CSR_RIGHT command, which set the auto-increment of the frame
// buffer data pointer to +1 (i.e. each subsequent data write will be
// one byte to the right of the previous).
//
LCDCommandWrite(CMD_CSR_RIGHT);
//
// Send the CSRW command, which sets the write cursor address to the
// beginning of the first frame buffer.
//
LCDCommandWrite(CMD_CSRW);
LCDDataWrite(0x00);
LCDDataWrite(0x00);
//
// Send the MWRITE command, which is used to fill the first frame buffer
// memory with all zeros (i.e. a blank display).
//
LCDCommandWrite(CMD_MWRITE);
for(ulIdx = 0; ulIdx < (40 * 240); ulIdx++)
{
LCDDataWrite(0x00);
}
//
// Send the CSRW command, which sets the write cursor address to the
// beginning of the second frame buffer.
//
LCDCommandWrite(CMD_CSRW);
LCDDataWrite(0x00);
LCDDataWrite(0x30);
//
// Send the MWRITE command, which is used to fill the second frame buffer
// memory with all zeros (i.e. a blank display).
//
LCDCommandWrite(CMD_MWRITE);
for(ulIdx = 0; ulIdx < (40 * 240); ulIdx++)
{
LCDDataWrite(0x00);
}
}
//*****************************************************************************
//
//! Display a horizontally organized graphic image on the LCD.
//!
//! \param pucData is a pointer to the image to be displayed.
//! \param ulX is the horizontal location to display the image, specified in
//! bytes (groups of eight columns) to the right of the left column.
//! \param ulY is the vertical location to display the image, specified in
//! scan lines down from the top scan line.
//! \param ulWidth is the width of the image, specified in bytes (groups of
//! eight columns).
//! \param ulHeight is the height of the image, specified in scan lines.
//! \param bBackLayer is a boolean that is true of the image should be
//! displayed on the second frame buffer (i.e. the back layer) and false if it
//! should be displayed on the first frame buffer.
//!
//! This performs a bitblit of the specified image onto the screen. The image
//! is arranged with the MSB of each byte being the left-most pixel of the byte
//! and all bytes of a scan line appearing from left to right in contiguous
//! memory locations before the data for the next scan line. This can be
//! thought of as a horizontal bitblit, since the data is read sequencially
//! from system memory and displayed on the panel horizontally on each scan
//! line in sequence. The image data must not contain any unused bytes between
//! scan lines.
//!
//! An image that is three columns wide and three rows tall would be arranged
//! as follows in memory:
//!
//! \verbatim
//! +--------+--------+--------+
//! | Byte 0 | Byte 1 | Byte 2 |
//! +--------+--------+--------+
//! | Byte 3 | Byte 4 | Byte 5 |
//! +--------+--------+--------+
//! | Byte 6 | Byte 7 | Byte 8 |
//! +--------+--------+--------+
//! \endverbatim
//!
//! \return None.
//
//*****************************************************************************
void
LCDBlit(const unsigned char *pucData, unsigned long ulX, unsigned long ulY,
unsigned long ulWidth, unsigned long ulHeight, tBoolean bBackLayer)
{
unsigned long ulIdx, ulPos;
//
// Determine the location within the LCD frame buffer memory for the upper
// left corner of the image.
//
ulPos =(bBackLayer ? 0x3000 : 0x0000) + (ulY * 40) + ulX;
//
// Set the cursor movement to the right (i.e. blit across a row before
// moving to the next row.
//
LCDCommandWrite(CMD_CSR_RIGHT);
//
// Loop over the rows.
//
while(ulHeight--)
{
//
// Set the cursor address.
//
LCDCommandWrite(CMD_CSRW);
LCDDataWrite(ulPos & 255);
LCDDataWrite(ulPos / 256);
//
// Write this row of data to the panel.
//
LCDCommandWrite(CMD_MWRITE);
for(ulIdx = 0; ulIdx < ulWidth; ulIdx++)
{
LCDDataWrite(*pucData++);
}
//
// Advance the cursor position to the next row.
//
ulPos += 40;
}
}
//*****************************************************************************
//
//! Display a vertically organized graphic image on the LCD.
//!
//! \param pucData is a pointer to the image to be displayed.
//! \param ulX is the horizontal location to display the image, specified in
//! bytes (groups of eight columns) to the right of the left column.
//! \param ulY is the vertical location to display the image, specified in
//! scan lines down from the top scan line.
//! \param ulWidth is the width of the image, specified in bytes (groups of
//! eight columns).
//! \param ulHeight is the height of the image, specified in scan lines.
//! \param bBackLayer is a boolean that is true of the image should be
//! displayed on the second frame buffer (i.e. the back layer) and false if it
//! should be displayed on the first frame buffer.
//!
//! This performs a bitblit of the specified image onto the screen. The image
//! is arranged with the MSB of each byte being the left-most pixel of the byte
//! and all bytes of a column appearing from left to right in contiguous memory
//! locations before the data for the next column. This can be thought of as a
//! vertical bitblit, since the data is read sequencially from system memory
//! and displayed on the panel vertically on each column in sequence. The
//! image data must not contain any unused bytes between columns.
//!
//! An image that is three columns wide and three rows tall would be arranged
//! as follows in memory:
//!
//! \verbatim
//! +--------+--------+--------+
//! | Byte 0 | Byte 3 | Byte 6 |
//! +--------+--------+--------+
//! | Byte 1 | Byte 4 | Byte 7 |
//! +--------+--------+--------+
//! | Byte 2 | Byte 5 | Byte 8 |
//! +--------+--------+--------+
//! \endverbatim
//!
//! \return None.
//
//*****************************************************************************
void
LCDVBlit(const unsigned char *pucData, unsigned long ulX, unsigned long ulY,
unsigned long ulWidth, unsigned long ulHeight, tBoolean bBackLayer)
{
unsigned long ulIdx, ulPos;
//
// Determine the location within the LCD frame buffer memory for the upper
// left corner of the image.
//
ulPos = (bBackLayer ? 0x3000 : 0x0000) + (ulY * 40) + ulX;
//
// Set the cursor movement to down (i.e. blit down a column before moving
// to the next column).
//
LCDCommandWrite(CMD_CSR_DOWN);
//
// Loop over the columns.
//
while(ulWidth--)
{
//
// Set the cursor address.
//
LCDCommandWrite(CMD_CSRW);
LCDDataWrite(ulPos & 255);
LCDDataWrite(ulPos / 256);
//
// Write this column of data to the panel.
//
LCDCommandWrite(CMD_MWRITE);
for(ulIdx = 0; ulIdx < ulHeight; ulIdx++)
{
LCDDataWrite(*pucData++);
}
//
// Advance the cursor position to the next column.
//
ulPos++;
}
}
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -