📄 uilcd.c
字号:
// // Clear the remainder of the line. // case STATE_CLEAR_LINE: { // // Fill the bitmap with zeros. // for(ulLoop = 0; ulLoop < 11; ulLoop++) { pucBitmap[ulLoop] = 0; } // // Display this column repeatedly until we reach the end of // the line. // ulState = STATE_DISPLAY_COLUMN; ulNext = STATE_DISPLAY_COLUMN; // // We're done with this state. // break; } // // Display the current column to the LCD. // case STATE_DISPLAY_COLUMN: { // // See if this is the last column and we have postset bits. // if(((ulX + 1) == ulEndX) && ulNumPostBits) { // // Loop through the rows of this column. // for(ulLoop = 0; ulLoop < 11; ulLoop++) { // // Mask off the bits that might be filled into the // postset columns. // pucBitmap[ulLoop] &= 0xff << ulNumPostBits; // // Copy the postset bits into the bitmap buffer. // pucBitmap[ulLoop] |= pucPostset[ulLoop]; } } // // Write this column to the LCD. // LCDDisplayImage(pucBitmap, ulX++, ulY, 1, 11); // // If we've reached the last column to be displayed, then stop // drawing the string. // if(ulX == ulEndX) { return; } // // Advance to the next state. // ulState = ulNext; // // We're done with this state. // break; } } }}//****************************************************************************//// LCDDrawMenu displays a menu on the LCD, which appears similar to a property// page in Windows.////****************************************************************************static voidLCDDrawMenu(unsigned long ulX, unsigned long ulY, const char *pcMenuItems, unsigned long ulStart){ const unsigned char *pucImage; unsigned char pucBitmap[13], ucFirst, ucSecond, ucLast; unsigned long ulLoop, ulWidth, ulNumBits, bIsFirst = 1, bDone = 0; char cChar; // // The first column of the menu is a fixed bitmap, so copy it to our bitmap // buffer. // for(ulLoop = 0; ulLoop < 13; ulLoop++) { pucBitmap[ulLoop] = ucMenuStart[0][ulLoop]; } // // If we are not starting with the first menu item, then we need to add the // left arrow to the first column of the menu. // if(ulStart != 0) { for(ulLoop = 0; ulLoop < 7; ulLoop++) { pucBitmap[ulLoop + 3] |= ucArrowLeft[ulLoop]; } } // // Display the first column of the menu. // LCDDisplayImage(pucBitmap, ulX++, ulY, 1, 13); // // The second column of the menu starts with a fixed bitmap, so copy it to // our bitmap buffer. // for(ulLoop = 0; ulLoop < 13; ulLoop++) { pucBitmap[ulLoop] = ucMenuStart[1][ulLoop]; } // // There are two pixels in the second column of the left portion of the // menu bitmap. // ulNumBits = 2; // // Find the first menu item to be displayed. // while(ulStart) { // // Skip past the current string in the string list. // while(*pcMenuItems) { pcMenuItems++; } // // Skip past the NULL at the end of this string. // pcMenuItems++; // // Decrement the count of the number of menu items to skip. // ulStart--; } // // While there are more characters to draw. // while(!bDone) { // // See if the next character is an actual character, or a NULL at the // end of a menu item. // if(*pcMenuItems) { // // Get the next character to be drawn. // cChar = *pcMenuItems++ - 0x1f; if(cChar >= sizeof(ucCharWidth)) { cChar = '_' - 0x1f; } // // Get the width of this character. // ulWidth = ucCharWidth[(unsigned long)cChar]; // // Get the values for the top of the tab. // ucFirst = 0xff << (8 - ulWidth); ucSecond = 0; // // Get a pointer to the image for this character. // pucImage = ucFont[(unsigned long)cChar]; // // See if this is the first menu item to be drawn. // if(bIsFirst) { // // Since this is the first menu item to be drawn, the tab is // open at the bottom (connecting the tab with the main display // area). // ucLast = 0; } else { // // Since this is not the first menu item to be drawn, there is // a line at the bottom of the tab. // ucLast = ucFirst; } } // // Otherwise, this character is a NULL, which means we must draw the // right side of the tab. // else { // // See if this is the first menu item to be drawn. // if(bIsFirst) { // // This is the first menu item to be drawn, so the image to be // drawn is the first spearator. // ucFirst = ucSeparatorFirst[0]; ucSecond = ucSeparatorFirst[1]; pucImage = ucSeparatorFirst + 2; // // There is no line drawn across the bottom. // ucLast = 0; // // The width of the first separator is five. // ulWidth = 5; // // Indicate that we are no longer drawing the first menu item. // bIsFirst = 0; } // // Otherwise, this is not the first menu item to be drawn. // else { // // The image to be drawn is the non-first separator. // ucFirst = ucSeparator[0]; ucSecond = ucSeparator[1]; pucImage = ucSeparator + 2; // // There is a line drawn across the bottom. // ucLast = 0xf0; // // THe width of the non-first separator is four. // ulWidth = 4; } // // Skip to the next character in the menu item string. // pcMenuItems++; // // See if the next character is a NULL. // if(*pcMenuItems) { // // The next character is not a NULL, so we need to also draw // the left portion of the next tab which is not obscured by // the overlapping right portion of this tab. // ucFirst |= 0x10 >> (ulWidth - 4); ucSecond |= 0x20 >> (ulWidth - 4); } else { // // The next character is a NULL, so we've reached the end of // the menu and are done. // bDone = 1; } } // // Copy the bits for the top two rows into the bitmap buffer. // pucBitmap[0] |= ucFirst >> ulNumBits; pucBitmap[1] |= ucSecond >> ulNumBits; // // Copy the bits for this character into the bitmap buffer. // for(ulLoop = 0; ulLoop < 11; ulLoop++) { pucBitmap[ulLoop + 2] |= pucImage[ulLoop] >> ulNumBits; } // // Copy the bits for the last row into the bitmap buffer. // pucBitmap[12] |= ucLast >> ulNumBits; // // Increment the bit position by the width of the character. // ulNumBits += ulWidth; // // If we have filled in all eight columns in the current byte, then // write it out to the LCD. // if(ulNumBits >= 8) { // // See if we've reached the end of the display. // if(ulX == 15) { // // We've reached the end of the display, so clear out the last // five pixels of this column. // for(ulLoop = 0; ulLoop < 13; ulLoop++) { pucBitmap[ulLoop] &= 0xe0; } // // Add the right arrow into this column to indicate that there // are further menu items to be displayed. // for(ulLoop = 0; ulLoop < 7; ulLoop++) { pucBitmap[ulLoop + 3] |= ucArrowRight[ulLoop]; } // // Fill in the top portion of the main area box. // pucBitmap[12] |= 0xfc; } // // Write this column to the LCD. // LCDDisplayImage(pucBitmap, ulX++, ulY, 1, 13); // // If we've reached the last column of the LCD, then stop drawing // the menu. // if(ulX == 16) { return; } // // Decrement the number of bits by eight. // ulNumBits -= 8; // // If there are still bits left, then we need to re-process this // character to get the right-most portion of it. // if(ulNumBits) { // // Copy the bits for first two rows into the bitmap buffer. // pucBitmap[0] = ucFirst << (ulWidth - ulNumBits); pucBitmap[1] = ucSecond << (ulWidth - ulNumBits); // // Copy the bits for this character into the bitmap buffer. // for(ulLoop = 0; ulLoop < 11; ulLoop++) { pucBitmap[ulLoop + 2] = pucImage[ulLoop] << (ulWidth - ulNumBits); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -