📄 ui.c
字号:
// pixel columns of data in the temporary buffer.
//
ulPos += g_pucFont24x32Width[ucChar] + 3;
//
// If there are more than eight pixel columns of data in the temporary
// buffer, then some of the data needs to be copied to the LCD.
//
if(ulPos >= 8)
{
//
// Determine the number of byte columns to transfer to the LCD.
//
ulFirst = ulPos / 8;
//
// If the number of byte columns of data exceeds the specified
// maximum width, then limit the number of byte colums to be
// transferred to the LCD.
//
if((ulX + ulFirst) > ulWidth)
{
ulFirst = ulWidth - ulX;
}
//
// Blit the image to the LCD.
//
LCDVBlit(g_pucTemp, ulX, ulY, ulFirst, 32, bBackLayer);
//
// Increment the starting column position by the number of byte
// columns that were just blitted to the LCD.
//
ulX += ulFirst;
//
// If the maximum width was just reached then return without any
// further processing.
//
if(ulX == ulWidth)
{
return;
}
//
// See if four full byte columns were transferred to the LCD.
//
if(ulFirst == 4)
{
//
// Clear the temporary buffer.
//
for(ulIdx = 0; ulIdx < 32; ulIdx++)
{
g_pucTemp[ulIdx] = 0;
}
}
else
{
//
// Compute the starting offset of the next byte column in the
// temporary buffer.
//
ulFirst *= 32;
//
// Transfer the next byte column to the first byte in the
// temporary buffer.
//
for(ulIdx = 0; ulIdx < 32; ulIdx++)
{
g_pucTemp[ulIdx] = g_pucTemp[ulIdx + ulFirst];
}
}
//
// Reduce the number of valid pixel columns in the temporary buffer
// by the number of pixel columns that were just blitted to the
// LCD.
//
ulPos &= 7;
}
}
//
// If there is any residual data in the temporary buffer then blit it to
// the LCD.
//
if(ulPos != 0)
{
LCDVBlit(g_pucTemp, ulX, ulY, 1, 32, bBackLayer);
}
}
//*****************************************************************************
//
//! Draws a button with a character label on it.
//!
//! \param ucLabel is the character to draw on the button.
//! \param ulX is the horizontal location to display the button, specified in
//! bytes (groups of eight columns) to the right of the left column.
//! \param ulY is the vertical location to display the button, specified in
//! scan lines down from the top scan line.
//!
//! This will draw a square button with rounded off corners and a single text
//! character in the middle of it (or a reasonable approximation thereof).
//!
//! \return None.
//
//*****************************************************************************
static void
UILabeledButton(unsigned char ucLabel, unsigned long ulX, unsigned long ulY)
{
const unsigned char *pucFont;
unsigned long ulIdx;
//
// Decompress the glyph for this character and get a pointer to it. For
// '.' and ',', skip the first four scan lines (so that the entire of the
// ',' is displayed).
//
UIDecompress(ucLabel - ' ');
pucFont = g_pucChar;
if((ucLabel == '.') || (ucLabel == ','))
{
pucFont += 4 * 3;
}
//
// Fill in the top and bottom scan lines of the button image with the
// appropriate static data.
//
((unsigned long *)g_pucTemp)[0] = 0x20100f00;
((unsigned long *)g_pucTemp)[7] = 0x000f1020;
((unsigned long *)g_pucTemp)[8] = 0x0000ff00;
((unsigned long *)g_pucTemp)[15] = 0x00ff0000;
((unsigned long *)g_pucTemp)[16] = 0x0000ff00;
((unsigned long *)g_pucTemp)[23] = 0x00ff0000;
((unsigned long *)g_pucTemp)[24] = 0x0408f000;
((unsigned long *)g_pucTemp)[31] = 0x00f00804;
//
// Loop through the middle scan lines of the button image.
//
for(ulIdx = 4; ulIdx < 28; ulIdx++)
{
//
// Fill in this scan line of the button image with the static button
// graphic and the image data from the character glyph.
//
g_pucTemp[ulIdx] = (pucFont[0] >> 4) | 0x40;
g_pucTemp[ulIdx + 32] = (pucFont[0] << 4) | (pucFont[1] >> 4);
g_pucTemp[ulIdx + 64] = (pucFont[1] << 4) | (pucFont[2] >> 4);
g_pucTemp[ulIdx + 96] = (pucFont[2] << 4) | 0x02;
//
// Skip to the next scan line of the character glyph.
//
pucFont += 3;
}
//
// Blit the button image to the LCD.
//
LCDVBlit(g_pucTemp, ulX, ulY, 4, 32, false);
}
//*****************************************************************************
//
//! Draws a space bar.
//!
//! \param ulX is the horizontal location to display the space bar, specified
//! in bytes (groups of eight columns) to the right of the left column.
//! \param ulY is the vertical location to display the space bar, specified in
//! scan lines down from the top scan line.
//!
//! This will draw a space bar which is the width of four labeled buttons.
//!
//! \return None.
//
//*****************************************************************************
static void
UISpaceBar(unsigned long ulX, unsigned long ulY)
{
unsigned long ulIdx;
//
// Clear out the portion of the image buffer that will not contain the
// lines for the space bar.
//
for(ulIdx = 9; ulIdx < 31; ulIdx++)
{
((unsigned long *)g_pucTemp)[ulIdx] = 0;
}
//
// Fill in the static data for the left portion of the space bar.
//
((unsigned long *)g_pucTemp)[0] = 0x20100f00;
((unsigned long *)g_pucTemp)[1] = 0x40404040;
((unsigned long *)g_pucTemp)[2] = 0x40404040;
((unsigned long *)g_pucTemp)[3] = 0x40404040;
((unsigned long *)g_pucTemp)[4] = 0x40404040;
((unsigned long *)g_pucTemp)[5] = 0x40404040;
((unsigned long *)g_pucTemp)[6] = 0x40404040;
((unsigned long *)g_pucTemp)[7] = 0x000f1020;
((unsigned long *)g_pucTemp)[8] = 0x0000ff00;
((unsigned long *)g_pucTemp)[15] = 0x00ff0000;
((unsigned long *)g_pucTemp)[16] = 0x0000ff00;
((unsigned long *)g_pucTemp)[23] = 0x00ff0000;
((unsigned long *)g_pucTemp)[24] = 0x0000ff00;
((unsigned long *)g_pucTemp)[31] = 0x00ff0000;
//
// Blit the left four columns of the space bar to the LCD.
//
LCDVBlit(g_pucTemp, ulX, ulY, 4, 32, false);
//
// Copy the second column of the image buffer to the first column.
//
for(ulIdx = 0; ulIdx < 8; ulIdx++)
{
((unsigned long *)g_pucTemp)[ulIdx] =
((unsigned long *)g_pucTemp)[ulIdx + 8];
}
//
// Blit the middle eight columns of the space bar to the LCD>
//
LCDVBlit(g_pucTemp, ulX + 4, ulY, 4, 32, false);
LCDVBlit(g_pucTemp, ulX + 8, ulY, 4, 32, false);
//
// Fill in the static data for the right portion of the space bar.
//
((unsigned long *)g_pucTemp)[24] = 0x0408f000;
((unsigned long *)g_pucTemp)[25] = 0x02020202;
((unsigned long *)g_pucTemp)[26] = 0x02020202;
((unsigned long *)g_pucTemp)[27] = 0x02020202;
((unsigned long *)g_pucTemp)[28] = 0x02020202;
((unsigned long *)g_pucTemp)[29] = 0x02020202;
((unsigned long *)g_pucTemp)[30] = 0x02020202;
((unsigned long *)g_pucTemp)[31] = 0x00f00804;
//
// Blit the right four columns of the space bar to the LCD.
//
LCDVBlit(g_pucTemp, ulX + 12, ulY, 4, 32, false);
}
//*****************************************************************************
//
//! Finds the button that corresponds to the given X/Y position.
//!
//! \param psButtons is a pointer to the array of buttons visible on the
//! screen.
//! \param ulCount is the number of buttons in the psButtons array.
//! \param ulX is the X position on the screen, specified in columns from the
//! left.
//! \param ulY is the Y position on the screen, specified in rows from the top.
//!
//! This function determines the button that corresponds to the given screen
//! coordinates. There is a dead space of three pixels around each button,
//! which is internal to the space occupied by the button.
//!
//! \return Returns the index to the corresponding button, or 0xffffffff if the
//! given position does not correspond to a button.
//
//*****************************************************************************
static unsigned long
UIFindButton(const tButton *psButtons, unsigned long ulCount,
unsigned long ulX, unsigned long ulY)
{
unsigned long ulIdx, ulWidth;
//
// Loop through the array of buttons.
//
for(ulIdx = 0; ulIdx < ulCount; ulIdx++)
{
//
// The space bar is extra wide, so allow for the extra width.
//
if(psButtons[ulIdx].ucLabel == ' ')
{
ulWidth = 3 * 32;
}
else
{
ulWidth = 0;
}
//
// If the given position is within this button then return the label
// for the button.
//
if((ulX > ((psButtons[ulIdx].ucX * 8) + 2)) &&
(ulX < ((psButtons[ulIdx].ucX * 8) + ulWidth + 29)) &&
(ulY > (psButtons[ulIdx].ucY + 2)) &&
(ulY < (psButtons[ulIdx].ucY + 29)))
{
return(ulIdx);
}
}
//
// No button was found, so return a failure.
//
return(0xffffffff);
}
//*****************************************************************************
//
//! Handles screen press events for diagnostic mode.
//!
//! \param ulX is the horizontal screen coordinate of the screen press.
//! \param ulY is the vertical screen coordinate of the screen press.
//!
//! This function is used in diagnostic mode to take a screen press (or
//! release) event and determine what actions to take (if any) as a result of
//! that user action.
//!
//! \return None.
//
//*****************************************************************************
static void
UIDiagPressHandler(unsigned long ulX, unsigned long ulY)
{
unsigned long ulTemp;
//
// See if the debounced touch state is down, indicating that the touch
// screen is being touched.
//
if(HWREGBITW(&g_ulUIFlags, UI_FLAG_DOWN) == 1)
{
//
// Find the button that was pressed.
//
ulTemp = UIFindButton(g_sDiagButtons,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -