|
我用的是原子的戰(zhàn)艦V4板,lcd顯示屏是在網(wǎng)上買的5寸屏幕,854*480的程序是正點(diǎn)提供的官方emwin例程,lcd的驅(qū)動(dòng)程序事先驗(yàn)證過(guò)能夠正常顯示包括字符串文字
lcd的畫點(diǎn)函數(shù)以及讀點(diǎn)函數(shù)等都是用的正點(diǎn)的函數(shù),只是改了底層配置
但是跟著正點(diǎn)加入emwin的程序后就不能正常顯示移植黑屏,有沒(méi)有大佬知道具體的原因
代碼如下:
這里是單片機(jī)主程序
int main(void)
{
HAL_Init(); /* 初始化HAL庫(kù) */
sys_stm32_clock_init(RCC_PLL_MUL9); /* 設(shè)置時(shí)鐘, 72Mhz */
delay_init(72); /* 延時(shí)初始化 */
usart_init(115200); /* 串口初始化為115200 */
usmart_dev.init(72); /* 初始化USMART */
led_init(); /* 初始化LED */
lcd_init(); /* 初始化LCD */
key_init(); /* 初始化按鍵 */
sram_init(); /* SRAM初始化 */
my_mem_init(SRAMIN); /* 初始化內(nèi)部SRAM內(nèi)存池 */
my_mem_init(SRAMEX); /* 初始化外部SRAM內(nèi)存池 */
btim_timx_int_init(999,71); /* 定時(shí)1ms */
__HAL_RCC_CRC_CLK_ENABLE(); /* 使能CRC時(shí)鐘 */
GUI_Init(); /* emWin 初始化 */
// GUIDEMO_Main();
GUI_SetBkColor(GUI_RED); /* 設(shè)置背景顏色 */
GUI_SetColor(GUI_BLUE);
GUI_Clear(); /* 清屏 */
GUI_SetColor(GUI_BLACK); /* 設(shè)置顏色 */
GUI_SetFont(&GUI_Font32_ASCII); /* 設(shè)置字體 */
GUI_DispStringAt("Hello emWin!", 0, 0); /* 在指定位置顯示字符串 */
while(1);
}
下面是顯示相關(guān)的函數(shù)
static void _SetPixelIndex(GUI_DEVICE * pDevice, int x, int y, LCD_PIXELINDEX PixelIndex) {
#ifdef WIN32
LCDSIM_SetPixelIndex(x, y, PixelIndex, pDevice->LayerIndex);
#else
//
// Convert logical into physical coordinates (Dep. on LCDConf.h)
//
#if (LCD_MIRROR_X == 1) || (LCD_MIRROR_Y == 1) || (LCD_SWAP_XY == 1)
int xPhys, yPhys;
xPhys = LOG2PHYS_X(x, y);
yPhys = LOG2PHYS_Y(x, y);
#else
#define xPhys x
#define yPhys y
#endif
GUI_USE_PARA(pDevice);
GUI_USE_PARA(x);
GUI_USE_PARA(y);
GUI_USE_PARA(PixelIndex);
{
//
// Write into hardware ... Adapt to your system
//
// TBD by customer...
//
lcd_draw_point(x,y,PixelIndex);
}
#if (LCD_MIRROR_X == 0) && (LCD_MIRROR_Y == 0) && (LCD_SWAP_XY == 0)
#undef xPhys
#undef yPhys
#endif
#endif
}
static LCD_PIXELINDEX _GetPixelIndex(GUI_DEVICE * pDevice, int x, int y) {
LCD_PIXELINDEX PixelIndex;
#ifdef WIN32
PixelIndex = LCDSIM_GetPixelIndex(x, y, pDevice->LayerIndex);
#else
//
// Convert logical into physical coordinates (Dep. on LCDConf.h)
//
#if (LCD_MIRROR_X == 1) || (LCD_MIRROR_Y == 1) || (LCD_SWAP_XY == 1)
int xPhys, yPhys;
xPhys = LOG2PHYS_X(x, y);
yPhys = LOG2PHYS_Y(x, y);
#else
#define xPhys x
#define yPhys y
#endif
GUI_USE_PARA(pDevice);
GUI_USE_PARA(x);
GUI_USE_PARA(y);
{
//
// Write into hardware ... Adapt to your system
//
// TBD by customer...
//
PixelIndex = lcd_read_point(x,y);
}
#if (LCD_MIRROR_X == 0) && (LCD_MIRROR_Y == 0) && (LCD_SWAP_XY == 0)
#undef xPhys
#undef yPhys
#endif
#endif
return PixelIndex;
}
static void _FillRect(GUI_DEVICE * pDevice, int x0, int y0, int x1, int y1) {
int x;
if (GUI_pContext->DrawMode & LCD_DRAWMODE_XOR)
{
for (; y0 <= y1; y0++)
{
for (x = x0; x <= x1; x++)
{
_XorPixel(pDevice, x, y0);
}
}
}
else
{
lcd_fill(x0,y0,x1,y1,LCD_COLORINDEX);
}
}
static void _DrawBitLine16BPP(GUI_DEVICE * pDevice, int x, int y, U16 const * p, int xsize) {
LCD_PIXELINDEX pixel;
lcd_set_cursor(x,y);
*(__IO uint16_t *)(UCGUI_LCD_CMD) = lcddev.wramcmd; /* 寫入顏色值 */
for (;xsize > 0; xsize --, x++, p++)
{
pixel = *p;
*(__IO uint16_t *)(UCGUI_LCD_DATA) = pixel;
}
}
|
|