/***************************************************************************** * @fn menuClearReservedArea * * @brief A function that easily lets the user clear every reserved area * of the LCD. Note that the last pixel of a reserved page isn't * reserved if an item is present right below it. This is because the * selection area around the item steals one pixel. That means, * if you reserve two pages of 8 pixels in a row, you would get 15 * pixels free, not 16. * * input parameters * * @param pMenu - Menu which you have reserved areas from */ void menuClearReservedArea(const menu_t *pMenu) { uint8 reservedAreas = pMenu->reservedAreas; for(uint8 bit=1;bit<=7;bit++) { if( reservedAreas & (1<<bit) ) { /* Clear page if reserved, but only clear last line of page if the next * page is reserved as well. This is because the inverted selection area * steals one pixel of height from the page above it. */ if( (reservedAreas & (1<<(bit+1))) || bit>7 ) { lcdBufferClearPage(0,(tLcdPage)bit); } else { lcdBufferClearHLine(0,0,LCD_COLS-1,(tLcdPage)bit*8+0); lcdBufferClearHLine(0,0,LCD_COLS-1,(tLcdPage)bit*8+1); lcdBufferClearHLine(0,0,LCD_COLS-1,(tLcdPage)bit*8+2); lcdBufferClearHLine(0,0,LCD_COLS-1,(tLcdPage)bit*8+3); lcdBufferClearHLine(0,0,LCD_COLS-1,(tLcdPage)bit*8+4); lcdBufferClearHLine(0,0,LCD_COLS-1,(tLcdPage)bit*8+5); lcdBufferClearHLine(0,0,LCD_COLS-1,(tLcdPage)bit*8+6); } } } }
void refreshScreen( void ) { RetVal retVal; TimerIntClear( GPTIMER0_BASE, GPTIMER_TIMA_TIMEOUT ); if( !currentMenu ) { return; } if( currentMenu->menuCount > 0 ) { lcdBufferClearPage( 0, lcdState.page ); ( *currentMenu->hoverFunction[lcdState.menuHover] )( &retVal ); switch( retVal.retType ) { case RET_TYPE_INT: lcdBufferPrintInt( 0, retVal.intRet, 0, lcdState.page ); break; case RET_TYPE_FLOAT: lcdBufferPrintFloat( 0, retVal.floatRet, 2, 0, lcdState.page ); break; } } lcdSendBufferPart( 0, 0, 127, lcdState.page, lcdState.page ); }
/************************************************************************************************** * @fn halLcdClear_Line * * @brief clear a line from the LCD * * @param uint8 line - the line to clear * * @return none **************************************************************************************************/ void HalLcdClear_Line(uint8 line) { #if (HAL_LCD == TRUE) // Clear a line in the buffer lcdBufferClearPage( BSP_DEFAULT_BUFFER, (tLcdPage) (line - 1)); // Rewrite buffer to LCD. lcdSendBuffer(BSP_DEFAULT_BUFFER); #endif }
/***************************************************************************** * @fn menuWriteBuffer * * @brief Writes the provided pMenu to the LCD Buffer * * input parameters * * @param pMenu - The menu to be shown on the display */ void menuWriteBuffer(const menu_t *pMenu) { /* Print the header on the first line/page on the LCD if not reserved */ if(!(pMenu->reservedAreas & 1)) { lcdBufferClearPage(0,eLcdPage0); printHeader(pMenu); } /* Which screen and which item is the current on */ int8 nCurrentItem = pMenu->nCurrentItem; int8 screen = pMenu->nScreen; /* Finding first item on screen */ uint8 itemsPerScreen = determineItemsPerScreen(pMenu); uint8 nItem = screen*itemsPerScreen; menuItem_t *pItem = &(pMenu->pItems[nItem]); /* Iterating through items, printing one by one */ tLcdPage page=(tLcdPage)getNextPage(pMenu,0); /* finds first page */ while(nItem<pMenu->nMenuItems && page) { /* write the current item */ lcdBufferClearPage(0,page); printItem(pMenu,nItem,page,0); /* Invert region around item if the item is selected */ if(pItem==&(pMenu->pItems[nCurrentItem])) { lcdBufferSetHLine(0,0,LCD_COLS-1,page*LCD_PAGE_ROWS-1); lcdBufferInvertPage(0,0,LCD_COLS-1,page); } else { if(pMenu->reservedAreas & (1<<(page-1))) { /* if the previous page is reserved, and this page isn't marked, * make sure horizontal line doesn't stick. */ lcdBufferClearHLine(0,0,LCD_COLS-1,page*LCD_PAGE_ROWS-1); } } /* NOTE: if the page over this (marked) item is reserved, the item will * still use 9 pixels of height for the invertion area so that it "steals" * 1 px of height from the reserved page. */ /* If this is a dummy item, invert the region around it if the * master item is selected */ if(pItem->flags & M_EXTEND){ int8 masterNumber = nItem - 1; while(pMenu->pItems[masterNumber].flags & M_EXTEND) { masterNumber--; } if(masterNumber==nCurrentItem) { lcdBufferInvert(0,0,page*LCD_PAGE_ROWS,LCD_COLS-1,(page+1)*LCD_PAGE_ROWS-1); } } /* Iterate */ page = (tLcdPage)getNextPage(pMenu,page); nItem++; pItem = &(pMenu->pItems[nItem]); } /* clearing unused pages that's not reserved */ while(page) { lcdBufferClearPage(0,page); if(pMenu->reservedAreas & (1<<(page-1))) { /* if the previous page is reserved, and this page is empty, * make sure horizontal line doesn't stick. */ lcdBufferClearHLine(0,0,LCD_COLS-1,page*LCD_PAGE_ROWS-1); } page = (tLcdPage)getNextPage(pMenu,page); } }