📄
字号:
}
AddTxt+="[/list] ";
AddText(AddTxt);
}
}
}
function showfont(font) {
if (helpstat){
alert("字体标记\n给文字设置字体.\n用法: [face="+font+"]改变文字字体为"+font+"[/face]");
} else if (basic) {
AddTxt="[face="+font+"][/face]";
AddText(AddTxt);
} else {
txt=prompt("要设置字体的文字"+font,"文字");
if (txt!=null) {
AddTxt="[face="+font+"]"+txt;
AddText(AddTxt);
AddTxt="[/face]";
AddText(AddTxt);
}
}
}
function underline() {
if (helpstat) {
alert("下划线标记\n给文字加下划线.\n用法: [u]要加下划线的文字[/u]");
} else if (basic) {
AddTxt="[u][/u]";
AddText(AddTxt);
} else {
txt=prompt("下划线文字.","文字");
if (txt!=null) {
AddTxt="[u]"+txt;
AddText(AddTxt);
AddTxt="[/u]";
AddText(AddTxt);
}
}
}
function setfly() {
if (helpstat){
alert("飞翔标记\n使文字飞行.\n用法: [fly]文字为这样文字[/fly]");
} else if (basic) {
AddTxt="[fly][/fly]";
AddText(AddTxt);
} else {
txt=prompt("飞翔文字","文字");
if (txt!=null) {
AddTxt="[fly]"+txt;
AddText(AddTxt);
AddTxt="[/fly]";
AddText(AddTxt);
}
}
}
function move() {
if (helpstat) {
alert("移动标记\n使文字产生移动效果.\n用法: [move]要产生移动效果的文字[/move]");
} else if (basic) {
AddTxt="[move][/move]";
AddText(AddTxt);
} else {
txt=prompt("要产生移动效果的文字","文字");
if (txt!=null) {
AddTxt="[move]"+txt;
AddText(AddTxt);
AddTxt="[/move]";
AddText(AddTxt);
}
}
}
function shadow() {
if (helpstat) {
alert("阴影标记\n使文字产生阴影效果.\n用法: [SHADOW=宽度, 颜色, 边界]要产生阴影效果的文字[/SHADOW]");
} else if (basic) {
AddTxt="[SHADOW=255,blue,1][/SHADOW]";
AddText(AddTxt);
} else {
txt2=prompt("文字的长度、颜色和边界大小","255,blue,1");
if (txt2!=null) {
txt=prompt("要产生阴影效果的文字","文字");
if (txt!=null) {
if (txt2=="") {
AddTxt="[SHADOW=255, blue, 1]"+txt;
AddText(AddTxt);
AddTxt="[/SHADOW]";
AddText(AddTxt);
} else {
AddTxt="[SHADOW="+txt2+"]"+txt;
AddText(AddTxt);
AddTxt="[/SHADOW]";
AddText(AddTxt);
}
}
}
}
}
function glow() {
if (helpstat) {
alert("光晕标记\n使文字产生光晕效果.\n用法: [GLOW=宽度, 颜色, 边界]要产生光晕效果的文字[/GLOW]");
} else if (basic) {
AddTxt="[glow=255,red,2][/glow]";
AddText(AddTxt);
} else {
txt2=prompt("文字的长度、颜色和边界大小","255,red,2");
if (txt2!=null) {
txt=prompt("要产生光晕效果的文字.","文字");
if (txt!=null) {
if (txt2=="") {
AddTxt="[glow=255,red,2]"+txt;
AddText(AddTxt);
AddTxt="[/glow]";
AddText(AddTxt);
} else {
AddTxt="[glow="+txt2+"]"+txt;
AddText(AddTxt);
AddTxt="[/glow]";
AddText(AddTxt);
}
}
}
}
}
function openscriphtml()
{
if (navigator.appName!="Microsoft Internet Explorer")
alert("此功能 Netscape 用户不能使用!")
else
{newwin=window.open('htmledit/editor.html','','width=544,height=294');
newwin.focus();
}
}
function runEx(){
//alert('请注意,按下确定将生成页面,按下后请稍后....');
var winEx = window.open("", "winEx", "width=600,height=400,status=yes,menubar=yes,scrollbars=yes,resizable=yes"); winEx.document.open("text/html", "replace");
winEx.document.write(unescape(event.srcElement.parentElement.children[2].value));
winEx.document.close();
}
function openScript(url, width, height) {
var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=yes,status=yes' );
}
</SCRIPT>
<SCRIPT language=Javascript>
<!-- hide
function insertsmilie(smilieface){
document.frmAnnounce.body.value+=smilieface;
}
// -->
</SCRIPT>
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content=单片机,单片机坐标 name=keywords>
<META content=单片机,单片机坐标 name=description>
<META content=单片机,单片机坐标 name=Author><LINK href="片机准PC机的C51程序.files/style.css"
rel=stylesheet></HEAD>
<BODY leftMargin=0 background=片机准PC机的C51程序.files/bg01.gif topMargin=0><BR>
<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
<TBODY>
<TR>
<TD>
<TABLE class=border cellSpacing=0 cellPadding=4 width="100%" border=0>
<TBODY>
<TR>
<TD class=title colSpan=2>| <A
href="http://www.mcuzb.com/article/index.ASP?classid=9"> <FONT
color=red>单片机坐标</FONT> </A>| </TD></TR>
<TR>
<TD class=title2 colSpan=2>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width=*>| <A
href="http://www.mcuzb.com/article/article.ASP?classid=9">单片机坐标</A>
>> <A
href="http://www.mcuzb.com/article/article.ASP?classid=9&Nclassid=14">芯片驱动</A>
>> 单片机驱动标准PC机键盘的C51程序 </TD>
<TD width=50><IMG src="片机准PC机的C51程序.files/printpage.gif"
align=absMiddle> <A
href="http://www.mcuzb.com/article/printpage.asp?id=222"
target=_blank>打印</A></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD colSpan=2>
<CENTER><B><FONT size=3>单片机驱动标准PC机键盘的C51程序</FONT></B><BR><BR><FONT
face=Verdana>www.mcuzb.com</FONT> 2003-5-28 单片机坐标</CENTER>
<P>
<BLOCKQUOTE><BR><FONT
class=b1>/*---------------------------------------------------------------------------------------------------<BR>功能:实现pc机键盘(p/s2接口)与8位单片机连接使用<BR>原理:键盘时钟接在p3.2口,既8051的外部中断int0上,键盘数据接到p1.0上<BR>每次按键,键盘会向单片机发脉冲使单片机发生外部中断,数据有p1.0口一位一位传进来<BR>传回的数据格式为:1位开始位(0),8位数据位(所按按键的通码,用来识别按键),1位校验位(奇校验)<BR>1位结束位(1)<BR>实现:将键盘发回的数据放到一个缓冲区里(数组),当按键结束后发生内部中断来处理所按的按键<BR>缺点:由于51单片机的容量有限所以缓冲区不可以开的太大,这就导致可以记录键盘的按键次数过少,<BR>也就是容错性一般。不过如果正常使用键盘是不会出错的<BR>版本:1.0<BR>最后修改时间:2003年5月<BR>开发人:鞠春阳<BR>版权:哈尔滨众邦龙开发有限公司
www.hitzbl.com
单片机坐标网www.mcuzb.com<BR>====================================================================================================*/</P><P>//#include"reg51.h"<BR>#include
"intrins.h"<BR>#include "ku.h" //按键通码与ascii对照表<BR>sbit sda= p1^0;
//键盘数据线</P><P>unsigned char dat=0,dat1=0,dat2=0;
//接收键盘数据变量? 存储通码变量 接受连续通码变量<BR>unsigned char
count=0,num=9,temp[5],shu=0; //中数次数 中断控制变量 缓冲区数组 缓冲区指针<BR>unsigned
char key=0; //按键最终值</P><P>void zhongduan() interrupt 0
//外部中断0 用来接受键盘发来的数据<BR>{<BR>dat>>=1; //接受数据
低->高<BR>if(sda)
dat|=0x80;<BR>count++;<BR>if(count==num)<BR>{<BR>if(count==9)<BR>{<BR>dat1=dat;
//中断9次后为键盘所按按键的通码(开始位始终为0在第一次中断时右移中忽略)<BR>num=20;
//使中断可以继续中断11次<BR>}<BR>if(count==20)<BR>{<BR>dat2=dat;
//取回第二个通码<BR>if(dat1==0xe0 || dat2==0xf0)
//第一个通码是0xe0则证明所按按键为功能键,第二个通码是0xf0证明按键结束<BR>{<BR>temp[shu]=dat1;temp[shu+1]=dat2;
shu+=2; //将所按按键存到缓冲区中<BR>ie=0x82;
//关闭外部中断并打开内部中断来处理所按按键<BR>tr0=1;<BR>}<BR>else<BR>{<BR>temp[shu]=dat1;temp[shu+1]=dat2;
shu+=2;
//如果shift键被按下则记录与它同时按下的那个键<BR>count=0;<BR>}<BR>if((temp[0]==18 ||
temp[0]==89) && (temp[2]==18 || temp[2]==89) ) tr0=1;
//如果缓冲区中有两个间隔的shift键则证明需要的铵键结束<BR>}<BR>}<BR>}</P><P><BR>void
getkey() interrupt 1 //内部中断0 用来处理缓冲区里的数据<BR>{<BR>unsigned char
i=0;<BR>tr0=0;<BR>th0=0;<BR>tl0=0;<BR>count=0;
//中断记数则0<BR>if((temp[0]==18 || temp[0]==89) &&
temp[1]!=0xf0 ) //shift被按下<BR>{
<BR>for(i=0;i<21;i++)<BR>{<BR>if(addshift[i][0]==temp[1])
//搜索shift被按下的表<BR>{<BR>key=addshift[i][1];<BR>ie=0x83;
//打开外部中断<BR>return;<BR>}<BR>}<BR>}<BR>else if(temp[0]==0xe0)
//所按下的按键是功能键<BR>{<BR>for(i=0;i<80;i++)<BR>{<BR>if(noshift[i][0]==temp[1])
//功能键的通码在缓冲区的第二位<BR>{<BR>key=noshift[i][1];<BR>ie=0x83;<BR>return;<BR>}<BR>}<BR>}<BR>else
//普通按键<BR>{<BR>for(i=0;i<80;i++)<BR>{<BR>if(noshift[i][0]==temp[0])
//普按键的通码在缓冲区的第一位<BR>{<BR>key=noshift[i][1];<BR>ie=0x83;<BR>return;<BR>}<BR>}<BR>}
<BR>for(i=0;i<5;i++) <BR>{<BR>temp[i]=0;<BR>} <BR>}
<P></P>
<P></FONT><BR><BR>
<P align=right>原作者:鞠春阳<BR>来
源:http://www.mcuzb.com<BR>共有4594位读者阅读过此文 <BR><BR>【<A
href="http://www.mcuzb.com/article/sendmail.asp?id=222"
target=_blank>告诉好友</A>】 </P></BLOCKQUOTE><IMG height=16
src="片机准PC机的C51程序.files/gb.gif" width=20>欢迎您到我们的<A
href="http://bbs.5boy.com/" target=_blank><FONT
color=#ff0000><B>技术论坛</B></FONT></A>来发表您的高见……
<P>
<LI>上篇文章:<A
href="http://www.mcuzb.com/article/list.asp?id=221">最新的x25045驱动,双通道读写驱动程序!</A>
<BR>
<LI>下篇文章:<A
href="http://www.mcuzb.com/article/list.asp?id=223">PC机键盘按键通码与ASCII对照表</A>
</LI></TD></TR>
<TR>
<TD class=title3 width="50%">□- 本周热门文章 </TD>
<TD class=title3 width="50%">□- 相关文章 </TD></TR>
<TR class=tdbg>
<TD vAlign=top width="50%"></TD>
<TD vAlign=top width="50%"><A
href="http://www.mcuzb.com/article/list.asp?id=237">7279驱动8个数码管及64个按键电路</A><BR><A
href="http://www.mcuzb.com/article/list.asp?id=236">数字调节低功耗有源滤波器</A><BR><A
href="http://www.mcuzb.com/article/list.asp?id=235">声控开关及放大器</A><BR><A
href="http://www.mcuzb.com/article/list.asp?id=234">声频噪声发生器</A><BR><A
href="http://www.mcuzb.com/article/list.asp?id=233">简易镍氢充电器</A><BR><A
href="http://www.mcuzb.com/article/list.asp?id=231">红外数据传输设置</A><BR><A
href="http://www.mcuzb.com/article/list.asp?id=230">红外发射机
接收机电路</A><BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -