VC6模拟LCD屏

嵌入式开发工具越来越强大,但目前还是比不上VC方便,至少需要下载,所以很多嵌入式开发工具都提供PC机上模拟的功能。

在console程序上实现lcd模拟也很简单,本文实现了对framebuffer的模拟,当然,因为简单,所以粗糙

#ifdef BS_LCD_SUPPORT
#define fb_w 320
#define fb_h 240
#define fb_s (fb_w*fb_h*2)

HDC g_hDC;
void * g_pFrameBuffer = NULL;

//thread to simulator LCD
DWORD SimLCD(void)
{
DWORD dwInfos[300]={0};
BITMAPINFOHEADER * pMapHeader = (BITMAPINFOHEADER *)dwInfos;
BYTE paaPixel[fb_s];
g_pFrameBuffer = paaPixel;
LibPrintf(" Virtual lcd begin at 0x%x ",g_pFrameBuffer);

pMapHeader -> biSize = sizeof(BITMAPINFOHEADER);
pMapHeader -> biWidth = fb_w;
pMapHeader -> biHeight = -fb_h; //top down
pMapHeader -> biPlanes = 1;
pMapHeader -> biBitCount = 16;
while(TRUE)
{
SetDIBitsToDevice(g_hDC, 320, 0, fb_w, fb_h, 0, 0, 0, fb_h, g_pFrameBuffer, (BITMAPINFO *)dwInfos, 0);
Sleep(300);
}
}
#endif

int main(int argc, char* argv[])
{
#ifdef BS_LCD_SUPPORT
HWND hWnd;
char arg[200]={0};
arg[0]='"';
strcpy(arg+1,argv[0]);
arg[strlen(arg)]='"';
hWnd=FindWindow(NULL,arg); //找到程序运行窗口的句柄
g_hDC=GetDC(hWnd);//通过窗口句柄得到该窗口的设备场境句柄
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE )SimLCD,NULL,0,NULL);
Sleep(100);
#endif
//其他代码

#ifdef BS_LCD_SUPPORT
ReleaseDC( hWnd, g_hDC );
#endif

return 0;
}

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/116625/viewspace-931247/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/116625/viewspace-931247/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值