新手上路
- 积分
- 25
- 金钱
- 25
- 注册时间
- 2024-12-19
- 在线时间
- 4 小时
|
1金钱
//绘制矩形 RGB565
void LCD_Window(uint16_t x_start,uint16_t x_end,uint16_t y_start,uint16_t y_end)
{
NT35510_Write_Cmd(0x2A00);
NT35510_Write_Date((uint8_t)(x_start >> 8) & 0xFF);
NT35510_Write_Cmd(0x2A01);
NT35510_Write_Date((uint8_t)x_start & 0xFF);
NT35510_Write_Cmd(0x2A02);
NT35510_Write_Date((uint8_t)((x_start + x_end - 1) >> 8) & 0xFF);
NT35510_Write_Cmd(0x2A03);
NT35510_Write_Date((uint8_t)(x_start + x_end - 1) & 0xFF);
NT35510_Write_Cmd(0x2B00);
NT35510_Write_Date((uint8_t)(y_start >> 8) & 0xFF);
NT35510_Write_Cmd(0x2B01);
NT35510_Write_Date((uint8_t)y_start & 0xFF);
NT35510_Write_Cmd(0x2B02);
NT35510_Write_Date((uint8_t)((y_start + y_end - 1) >> 8) & 0xFF);
NT35510_Write_Cmd(0x2B03);
NT35510_Write_Date((uint8_t)(y_start + y_end- 1) & 0xFF);
}
//显示一个字符
void NT35510_DisChar(uint16_t X, uint16_t Y,const char cChar)
{
uint16_t i, j, fontLength = 0;
uint16_t ucRelativePositon = 0;
uint8_t *Pfont = NULL;
//字体偏移量
ucRelativePositon = cChar - ' ';
//每个字模的字节数
fontLength = (LCD_Currentfonts->FONT_HIGHT * LCD_Currentfonts->FONT_WIDTH) / 8;
//字模首地址
Pfont = (uint8_t *)&LCD_Currentfonts->table[ucRelativePositon * fontLength];
LCD_Window(X, LCD_Currentfonts->FONT_WIDTH, Y, LCD_Currentfonts->FONT_HIGHT);
NT35510_Write_Cmd(0x2C00); //写入像素命令
for (i = 0; i < fontLength; i++)
{
for ( j = 0; j < 8; j++ )
{
if ( Pfont[i & (0x80>>j) )
NT35510_Write_Date(SET_FONT_COLOR_POINT);
else
NT35510_Write_Date(SET_FONT_COLOR_BACK);
}
}
}
//显示字符串
void NT35510_DisString(uint16_t X, uint16_t Y, char *str)
{
while (*str != '\0')
{
if ((X + LCD_Currentfonts->FONT_WIDTH) > LCD_X_LENGTH) //LCD_Currentfonts->FONT_WIDTH == 16
{
X = NT35510_X_Star;
Y = Y + 1 + LCD_Currentfonts->FONT_HIGHT;
}
if ((Y + LCD_Currentfonts->FONT_HIGHT) > LCD_Y_LENGTH) //LCD_Currentfonts->FONT_HIGHT == 32
{
Y = NT35510_Y_Star; // NT35510_Y_Star == 0
X = NT35510_X_Star;
}
NT35510_DisChar(X, Y, *str);
str++;
X = X + LCD_Currentfonts->FONT_WIDTH;
}
DEBUG_DELAY();
}
|
|