/** * @brief Displays characters in currently active layer. * @param Xpos X position (in pixel) * @param Ypos Y position (in pixel) * @param Text Pointer to string to display on LCD * @param Mode Display mode * This parameter can be one of the following values: * @arg CENTER_MODE * @arg RIGHT_MODE * @arg LEFT_MODE */ void UTIL_LCD_DisplayStringAt(uint32_t Xpos, uint32_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode) { uint32_t refcolumn = 1, i = 0; uint32_t size = 0, xsize = 0; uint8_t *ptr = Text; /* Get the text size */ while (*ptr++) size ++ ; /* Characters number per line */ xsize = (DrawProp->LcdXsize/DrawProp[DrawProp->LcdLayer].pFont->Width); switch (Mode) { case CENTER_MODE: { refcolumn = Xpos + ((xsize - size)* DrawProp[DrawProp->LcdLayer].pFont->Width) / 2; break; } case LEFT_MODE: { refcolumn = Xpos; break; } case RIGHT_MODE: { refcolumn = - Xpos + ((xsize - size)*DrawProp[DrawProp->LcdLayer].pFont->Width); break; } default: { refcolumn = Xpos; break; } } /* Check that the Start column is located in the screen */ if ((refcolumn < 1) || (refcolumn >= 0x8000)) { refcolumn = 1; } /* Send the string character by character on LCD */ while ((*Text != 0) & (((DrawProp->LcdXsize - (i*DrawProp[DrawProp->LcdLayer].pFont->Width)) & 0xFFFF) >= DrawProp[DrawProp->LcdLayer].pFont->Width)) { /* Display one character on LCD */ UTIL_LCD_DisplayChar(refcolumn, Ypos, *Text); /* Decrement the column position by 16 */ refcolumn += DrawProp[DrawProp->LcdLayer].pFont->Width; /* Point on the next character */ Text++; i++; } }
时间: 2024-03-30 13:35:31 浏览: 403
Introduction.to.Java.Programming,.Brief.Version
这段代码是用于在 LCD 上显示字符串的函数,可以根据指定的位置和显示模式将字符串显示在屏幕上。其中,Xpos 和 Ypos 是字符串的起始位置坐标,Text 是指向要显示的字符串的指针,Mode 是显示模式,可以是 CENTER_MODE(居中显示)、LEFT_MODE(左对齐显示)或 RIGHT_MODE(右对齐显示)。该函数会根据字符串的长度和指定的显示模式计算出每个字符的位置,并逐个将字符显示在屏幕上。
阅读全文