⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 writebuf.cpp

📁 一个通过PCI卡向LED屏发送股票实时行情的系统
💻 CPP
字号:
#include "stdafx.h" 

#include "Writebuf.h"
#include <conio.h>
#include <stdio.h>

WriteLed::WriteLed()//CAdd * padd,BYTE m_hei)
{
	m_dp=(PDWORD)0xd0000;
	m_pdp=(PCHAR)m_dp;
	m_ep=(PDWORD)0xe0000;
	m_pep=(PCHAR)m_ep;

	ClearAddress();
    m_height=44;	//行数
	m_width=32;		//列宽
	m_linelen=32;	//列数
	m_count=m_width*m_height*16;
    
	m_redbuf=new BYTE[m_count];
	m_greenbuf=new BYTE[m_count];
	memset(m_redbuf,0,m_count);
	memset(m_greenbuf,0,m_count);
	m_redbuf1=new BYTE[m_count];
	m_greenbuf1=new BYTE[m_count];
	memset(m_redbuf1,0,m_count);
	memset(m_greenbuf1,0,m_count);
}

WriteLed::~WriteLed()
{
	if(m_redbuf)
		delete m_redbuf;
	if(m_greenbuf)
		delete m_greenbuf;
	if(m_redbuf1)
		delete m_redbuf1;
	if(m_greenbuf1)
		delete m_greenbuf1;
}

void WriteLed::ClearAddress()
{
	memset(m_pdp,0,0xffff);
	memset(m_pep,0,0xffff);
}

int WriteLed::ReadAddress()
{
	static  char    *szProFile="c:\\windows\\sjshq.ini";
	char    cTemp[15],temp[20];
	char  *m_str2;

	GetPrivateProfileString("PalyFile_Parameter","Address_L_Segment","",Address_L_Seg,sizeof(Address_L_Seg),szProFile);
	GetPrivateProfileString("PalyFile_Parameter","Address_R_Segment","",Address_R_Seg,sizeof(Address_R_Seg),szProFile);

	strcpy(cTemp, "LRedAddress");
	for(int i=0;i<44;i++)
	{
		itoa(i+1,&cTemp[11],10);
		GetPrivateProfileString("Address_Red_L",cTemp,"0000",temp,
								sizeof(temp),szProFile);
        m_RedAddress[i]=strtol(temp,&m_str2,16);  
	}
	strcpy(cTemp, "LGreenAddress");
	for(i=0;i<44;i++)
	{
		itoa(i+1,&cTemp[13],10);
		GetPrivateProfileString("Address_Green_L",cTemp,"0000",temp,
								sizeof(temp),szProFile);
        m_GreenAddress[i]=strtol(temp,&m_str2,16);  
	}
	strcpy(cTemp, "RRedAddress");
	for(i=0;i<44;i++)
	{
		itoa(i+1,&cTemp[11],10);
		GetPrivateProfileString("Address_Red_R",cTemp,"0000",temp,
								sizeof(temp),szProFile);
        m_RedAddress1[i]=strtol(temp,&m_str2,16);  
	}
	strcpy(cTemp, "RGreenAddress");
	for(i=0;i<44;i++)
	{
		itoa(i+1,&cTemp[13],10);
		GetPrivateProfileString("Address_Green_R",cTemp,"0000",temp,
								sizeof(temp),szProFile);
        m_GreenAddress1[i]=strtol(temp,&m_str2,16);  
	}
	return 1;
}

void WriteLed::WriteOneAddres(unsigned char *m_videop,char *m_ledp,int m_len)
{
   	int i,j;
	for (j=0;j<m_len;j++)
		for(i=0;i<16;i++) 
			memcpy(m_ledp+i*32+j,m_videop+i*m_len+j,1);

}

void WriteLed::WriteToLed()
{
	int ii;
  	for(ii=0;ii<m_height;ii++)
	{
		if(Address_L_Seg[0]=='e')
		{
			WriteOneAddres(m_redbuf+ii*16*m_linelen,m_pep+m_RedAddress[ii],m_width);
			WriteOneAddres(m_greenbuf+ii*16*m_linelen,m_pep+m_GreenAddress[ii],m_width);
		}
		else
		{
			WriteOneAddres(m_redbuf+ii*16*m_linelen,m_pdp+m_RedAddress[ii],m_width);
			WriteOneAddres(m_greenbuf+ii*16*m_linelen,m_pdp+m_GreenAddress[ii],m_width);
		}
		if(Address_R_Seg[0]=='e')
		{
			WriteOneAddres(m_redbuf1+ii*16*m_linelen,m_pep+m_RedAddress1[ii],m_width);
			WriteOneAddres(m_greenbuf1+ii*16*m_linelen,m_pep+m_GreenAddress1[ii],m_width);
		}
		else
		{
			WriteOneAddres(m_redbuf1+ii*16*m_linelen,m_pdp+m_RedAddress1[ii],m_width);
			WriteOneAddres(m_greenbuf1+ii*16*m_linelen,m_pdp+m_GreenAddress1[ii],m_width);
		}
	} 
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -