lightsCTRL(int i) /* 信号灯控制 */
{
int s1,s2;
switch(i)
{
case 0:s1=0;s2=0;break;
case 1:s1=0;s2=1;break;
case 2:s1=1;s2=0;break;
case 3:s1=2;s2=2;break;
default:printf("error!");
}
switch(s1) /* 垂直方向行人通行信号灯控制 */
{
case 0:setcolor(RED);setfillstyle(SOLID_FILL,RED);break;
case 1:setcolor(GREEN);setfillstyle(SOLID_FILL,GREEN);break;
case 2:setcolor(YELLOW);setfillstyle(SOLID_FILL,YELLOW);break;
default:printf("error!");
}
bar(220,200,260,209); /* 绘制斑马线 */
bar(220,218,260,227);
bar(220,236,260,245);
bar(220,254,260,263);
bar(220,272,260,280);
void communication2() /* 发送源信号 */
{
int sletter=(AD_state()/2);
int status;
status=inportb(ctrl51);//获取8253 TXRDY 状态
if((status&0x01)!=0)//已准备好,则将键入的字符发送出去
{
outportb(data51,sletter);/* 发送采集到的数据 */
}
}
int communication(void)
{
char i,rletter='z';
int j,status;
status=inportb(ctrl51);/*已准备好,即有数据传送过来,则接收1个字符*/
if((status&0x02)!=0)
{
rletter=inportb(data51);
printf("\n%c",rletter);
}
i=rletter;
if(i=='1')return(1);
else
if(i=='2')return(2);
else return(3);
}
void main(void)
{
int i=1,k;
/*initscreen();*/
ST_8253();
ST_8251();
ST_8255();
for(;;)
{
for(k=100;k>0;k--)
{
i=communication();
printf("receive=%d",i);
}
communication2();printf("sent");
/*if(i==3)
{
clrscr();
exit(1);
}*/
/*display(i);*/
}
}
Turbo Link Version 5.1 Copyright (c) 1992 Borland International
Error: Underfined symbol _setcolor in module c:\temp\cpp\cpp1.cpp
Error: Underfined symbol _setfillstyle in module c:\temp\cpp\cpp1.cpp
Error: Underfined symbol _bar in module c:\temp\cpp\cpp1.cpp
Error: Underfined symbol _line in module c:\temp\cpp\cpp1.cpp
Error: Underfined symbol _cleardevice in module c:\temp\cpp\cpp1.cpp
Error: Underfined symbol _initgraph in module c:\temp\cpp\cpp1.cpp
Error: Underfined symbol _pieslice in module c:\temp\cpp\cpp1.cpp
Available memory 4054152