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

📄 c语言嵌入式系统编程修炼之屏幕操作-开发频道-c-天极网1.htm

📁 C语言嵌入式系统编程修炼,关于如何编写高质量程序的文章,非常好!
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0036)http://dev.yesky.com/9/2018509.shtml -->
<HTML lang=zh-CN xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网</TITLE>
<META 
content="C语言嵌入式系统编程修炼之屏幕操作,开发者网络瞄准中国程序员群体,涵盖软件开发的各个技术层面,从Windows下的应用程序开发,到Java、Web开发、游戏开发和移动开发领域,均有相关教程和实例、技巧。 &#13;&#10;" 
name=description>
<META content=C语言嵌入式系统编程修炼之屏幕操作,软件开发,嵌入式开发,java开发工具,驱动开发,软件工程,IBM,微软,数据库 
name=keywords>
<META content="天极网 | 全球中文IT第一门户" name=author>
<META content="天极网 | 全球中文IT第一门户" name=Copyright>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META http-equiv=Content-Language content=zh-CN><LINK media=all 
href="C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网1.files/y_mobile_content.css" type=text/css 
rel=stylesheet>
<SCRIPT src="C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网1.files/showlay.js"></SCRIPT>

<META content="MSHTML 6.00.2900.3314" name=GENERATOR></HEAD>
<BODY><!--页面头部--><!--头部-->
<DIV>
<SCRIPT 
src="C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网1.files/kingsoft-kuanban-071105.js"></SCRIPT>
</DIV>
<DIV id=topmenu><A href="http://www.yesky.com/">Yesky首页</A>| <A 
href="http://product.yesky.com/">产品报价</A>| <A 
href="http://cseek.yesky.com/">行情</A>| <A href="http://mobile.yesky.com/">手机</A> 
| <A href="http://digital.yesky.com/">数码</A> | <A 
href="http://notebook.yesky.com/">笔记本</A> | <A 
href="http://pc.yesky.com/">台式机</A> | <A href="http://diy.yesky.com/">DIY硬件</A> 
| <A href="http://oa.yesky.com/">外设</A> | <A href="http://net.yesky.com/">网络</A> 
| <A href="http://dh.yesky.com/">数字家庭</A> | <A 
href="http://lab.yesky.com/">评测</A> | <A href="http://soft.yesky.com/">软件</A> | 
<A href="http://fashion.yesky.com/">e时代</A> | <A 
href="http://game.yesky.com/">游戏</A> | <A href="http://pic.yesky.com/">图片</A> | 
<A href="http://desktop.yesky.com/">壁纸</A> | <A 
href="http://q.yesky.com/">群乐</A> | <A href="http://my.yesky.com/">社区</A> | <A 
href="http://blog.yesky.com/">博客</A> | <A 
href="http://www.mydown.com/">下载</A></DIV>
<DIV id=topbox>
<DIV class=tleft><A id=pagelogo href="http://www.yesky.com/"><IMG 
alt=天极Yesky_全球中文IT第一门户 src="C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网1.files/logo.gif" 
border=0></A></DIV>
<DIV class=tad><SPAN id=ad1></SPAN></DIV>
<DIV id=search>
<DIV>
<FORM name=searchform action=http://search.chinabyte.com/search method=get 
target=_blank><INPUT id=searchzz onmouseover=this.focus() onfocus=this.select() 
name=q><INPUT type=hidden value=GB2312 name=encoding><INPUT type=hidden 
value=connect name=dir><INPUT type=hidden value=20002 name=cid><INPUT id=search_btn type=submit value=天极搜索> </FORM></DIV>
<DIV class=tdq>
<DIV class=rightarea><A href="http://bj.yesky.com/">北京</A> <A 
href="http://hd.yesky.com/">上海</A> <A href="http://gd.yesky.com/">广州</A> <A 
href="http://sz.yesky.com/">深圳</A><BR><A href="http://cd.yesky.com/">成都</A> <A 
href="http://cq.yesky.com/">重庆</A> <A href="http://sy.yesky.com/">沈阳</A> <A 
href="http://xa.yesky.com/">西安</A> </DIV>
<DIV class=rightarea_right><A 
href="http://my.yesky.com/">用户<BR>登录</A></DIV></DIV></DIV>
<DIV class=tright>
<DIV class=box1>
<SCRIPT src="C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网1.files/content_text_ad.js" 
type=text/javascript></SCRIPT>
</DIV></DIV></DIV>
<SCRIPT src="C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网1.files/flash.js" 
type=text/javascript></SCRIPT>

<DIV id=childmenu twffan="done"><A href="http://soft.yesky.com/" 
target=_self>软件频道&gt;</A><A href="http://dev.yesky.com/" 
target=_self>程序开发&gt;</A><A href="http://dev.yesky.com/devjava/" 
target=_self>Java</A><A href="http://dev.yesky.com/ysdevvb" 
target=_self>VB</A><A href="http://dev.yesky.com/ysdevvc" target=_self>VC</A><A 
href="http://dev.yesky.com/ysdevdelphi" target=_self>Delphi</A><A 
href="http://dev.yesky.com/ysdevc" target=_self>C/C++</A><A 
href="http://dev.yesky.com/web/" target=_self>Web开发</A><A 
href="http://dev.yesky.com/msdn/" target=_self>微软专栏</A><A 
href="http://dev.yesky.com/devydkf/" target=_self>移动</A><A 
href="http://dev.yesky.com/devsjk/" target=_self>数据库</A><A 
href="http://dev.yesky.com/ysdevcxrs" target=_self>程序人生</A><A 
href="http://dev.yesky.com/ysdevrjgc" target=_self>软件工程</A>|<A 
href="http://soft.yesky.com/lesson/" target=_self>产品中心</A><A 
href="http://www.mydown.com/soft/develop/news.shtml" target=_self>下载</A><A 
href="http://www.ibm.com/developerworks/cn/rational/rationaledge/content/mar06/eeles/?S_TACT=105AGX52&amp;S_CMP=top-yesky">什么是软件架构</A></DIV><!--导航条-->
<DIV id=location>
<DIV class=loleft>您现在的位置: <A href="http://www.yesky.com/" target=_self>天极网</A> 
&gt; <A href="http://dev.yesky.com/" target=_self>开发频道</A> &gt; 
C语言嵌入式系统编程修炼之屏幕操作</DIV>
<DIV class=adright><SPAN id=ad2></SPAN></DIV></DIV><!--内容块开始-->
<DIV id=conbox><!--左边开始-->
<DIV id=conleft>
<DIV id=contopla1>
<DIV id=__001>
<DIV class=qkong></DIV>
<DIV class=qw1>全文</DIV>
<DIV class=zkong>
<DIV class=kl></DIV>
<DIV class=bj><A href="http://dev.yesky.com/9/2018509.shtml#pls" 
target=_self>评论</A></DIV>
<DIV class=kr></DIV><!-- Error -->
<SCRIPT type=text/javascript>
var titiepic ="#";
if (titiepic!="#")
{
document.write("<div class=\"kl\"></div><div class=\"bj\"><a href=\"#\" target=\"_blank\">图片</a></div><div class=\"kr\"></div>");
}
</SCRIPT>
<!-- Error --></DIV></DIV></DIV>
<DIV class=topadbg style="PADDING-BOTTOM: 5px"><SPAN id=ad10></SPAN></DIV><A 
name=top></A>
<DIV id=contitle>
<H1>C语言嵌入式系统编程修炼之屏幕操作</H1></DIV>
<DIV id=conauthor><SPAN>2005-06-20 15:54 </SPAN><SPAN>作者: 宋宝华 </SPAN><SPAN>出处: 
天极网 </SPAN><SPAN>责任编辑:<A title=向本编辑提问 
href="http://comments.yesky.com/t/·&frac12;&Ouml;&Ucirc;/6,324/2018509.shtml" target=_blank>方舟</A> 
</SPAN></DIV>
<DIV class=topadbg><SPAN id=ad9></SPAN></DIV>
<DIV id=conneirong><SPAN id=ad3></SPAN>
<DIV class=guanggao><SPAN 
id=contentAdv></SPAN></DIV>  <B>汉字处理</B><BR><BR>  现在要解决的问题是,嵌入式系统中经常要使用的并非是完整的汉字库,往往只是需要提供数量有限的汉字供必要的显示功能。例如,一个微波炉的LCD上没有必要提供显示"电子邮件"的功能;一个提供汉字显示功能的空调的LCD上不需要显示一条"短消息",诸如此类。但是一部手机、小灵通则通常需要包括较完整的汉字库。<BR><BR>  如果包括的汉字库较完整,那么,由内码计算出汉字字模在库中的偏移是十分简单的:汉字库是按照区位的顺序排列的,前一个字节为该汉字的区号,后一个字节为该字的位号。每一个区记录94个汉字,位号则为该字在该区中的位置。因此,汉字在汉字库中的具体位置计算公式为:94*(区号-1)+位号-1。减1是因为数组是以0为开始而区号位号是以1为开始的。只需乘上一个汉字字模占用的字节数即可,即:(94*(区号-1)+位号-1)*一个汉字字模占用字节数,以16*16点阵字库为例,计算公式则为:(94*(区号-1)+(位号-1))*32。汉字库中从该位置起的32字节信息记录了该字的字模信息。<BR><BR>  对于包含较完整汉字库的系统而言,我们可以以上述规则计算字模的位置。但是如果仅仅是提供少量汉字呢?譬如几十至几百个?最好的做法是:<BR><BR>  定义宏:<BR><BR>
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf border=1>
  <TBODY>
  <TR>
    <TD># define EX_FONT_CHAR(value) <BR># define EX_FONT_UNICODE_VAL(value) 
      (value),<BR># define EX_FONT_ANSI_VAL(value) 
(value),</TD></TR></TBODY></TABLE><BR>  定义结构体:<BR><BR>
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf border=1>
  <TBODY>
  <TR>
    <TD>typedef struct _wide_unicode_font16x16 <BR>{<BR> WORD value; /* 内码 
      */<BR> BYTE data[32]; /* 字模点阵 */<BR>}Unicode;<BR>#define CHINESE_CHAR_NUM 
      … /* 汉字数量 */</TD></TR></TBODY></TABLE><BR>  字模的存储用数组:<BR><BR>
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf border=1>
  <TBODY>
  <TR>
    <TD>Unicode chinese[CHINESE_CHAR_NUM] 
      =<BR>{<BR>{<BR>EX_FONT_CHAR("业")<BR>EX_FONT_UNICODE_VAL(0x4e1a)<BR>{0x04, 
      0x40, 0x04, 0x40, 0x04, 0x40, 0x04, 0x44, 0x44, 0x46, 0x24, 0x4c, 0x24, 
      0x48, 0x14, 0x50, 0x1c, 0x50, 0x14, 0x60, 0x04, 0x40, 0x04, 0x40, 0x04, 
      0x44, 0xff, 0xfe, 0x00, 0x00, 0x00, 
      0x00}<BR>},<BR>{<BR>EX_FONT_CHAR("中")<BR>EX_FONT_UNICODE_VAL(0x4e2d)<BR>{0x01, 
      0x00, 0x01, 0x00, 0x21, 0x08, 0x3f, 0xfc, 0x21, 0x08, 0x21, 0x08, 0x21, 
      0x08, 0x21, 0x08, 0x21, 0x08, <BR>0x3f, 0xf8, 0x21, 0x08, 0x01, 0x00, 
      0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 
      0x00}<BR>},<BR>{<BR>EX_FONT_CHAR("云")<BR>EX_FONT_UNICODE_VAL(0x4e91)<BR>{0x00, 
      0x00, 0x00, 0x30, 0x3f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0xff, 
      0xfe, 0x03, 0x00, 0x07, 0x00, <BR><BR>0x06, 0x40, 0x0c, 0x20, 0x18, 0x10, 
      0x31, 0xf8, 0x7f, 0x0c, 0x20, 0x08, 0x00, 
      0x00}<BR>},<BR>{<BR>EX_FONT_CHAR("件")<BR>EX_FONT_UNICODE_VAL(0x4ef6)<BR>{0x10, 
      0x40, 0x1a, 0x40, 0x13, 0x40, 0x32, 0x40, 0x23, 0xfc, 0x64, 0x40, 0xa4, 
      0x40, 0x28, 0x40, 0x2f, 0xfe, <BR><BR>0x20, 0x40, 0x20, 0x40, 0x20, 0x40, 
      0x20, 0x40, 0x20, 0x40, 0x20, 0x40, 0x20, 
0x40}<BR>}<BR>}</TD></TR></TBODY></TABLE><BR>  要显示特定汉字的时候,只需要从数组中查找内码与要求汉字内码相同的即可获得字模。如果前面的汉字在数组中以内码大小顺序排列,那么可以以二分查找法更高效的查找到汉字的字模。<BR><BR>  这是一种很有效的组织小汉字库的方法,它可以保证程序有很好的结构。<BR><BR>  <B>系统时间显示</B><BR><BR>  从NVRAM中可以读取系统的时间,系统一般借助NVRAM产生的秒中断每秒读取一次当前时间并在LCD上显示。关于时间的显示,有一个效率问题。因为时间有其特殊性,那就是60秒才有一次分钟的变化,60分钟才有一次小时变化,如果我们每次都将读取的时间在屏幕上完全重新刷新一次,则浪费了大量的系统时间。<BR><BR>  一个较好的办法是我们在时间显示函数中以静态变量分别存储小时、分钟、秒,只有在其内容发生变化的时候才更新其显示。<BR><BR>
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf border=1>
  <TBODY>
  <TR>
    <TD>extern void DisplayTime(…)<BR>{<BR> static BYTE 
      byHour,byMinute,bySecond;<BR> BYTE byNewHour, byNewMinute, 
      byNewSecond;<BR> byNewHour = GetSysHour();<BR> byNewMinute = 
      GetSysMinute();<BR> byNewSecond = GetSysSecond();<BR> <BR> if(byNewHour!= 
      byHour)<BR> {<BR>  … /* 显示小时 */<BR>  byHour = 
      byNewHour;<BR> }<BR> if(byNewMinute!= byMinute)<BR> {<BR>  … /* 显示分钟 
      */<BR>  byMinute = byNewMinute;<BR> }<BR> if(byNewSecond!= 
      bySecond)<BR> {<BR>  … /* 显示秒钟 */<BR>  bySecond = 
    byNewSecond;<BR> }<BR>}</TD></TR></TBODY></TABLE><BR>  这个例子也可以顺便作为C语言中static关键字强大威力的证明。当然,在C++语言里,static具有了更加强大的威力,它使得某些数据和函数脱离"对象"而成为"类"的一部分,正是它的这一特点,成就了软件的无数优秀设计。<BR><BR>
<DIV class=right>共3页。 <A class=page href="http://dev.yesky.com/9/2018509.shtml" 
target=_self><FONT color=#666666><B>1</B></FONT></A> <A class=page 
href="http://dev.yesky.com/9/2018509_1.shtml" target=_self><B>2</B></A> <A 
class=page href="http://dev.yesky.com/9/2018509_2.shtml" 
target=_self><B>3</B></A> <A class=page 
href="http://dev.yesky.com/9/2018509_1.shtml" target=_self><FONT 
face=Webdings>8</FONT></A> <A class=page 
href="http://dev.yesky.com/9/2018509_2.shtml" target=_self><FONT 
face=Webdings>:</FONT></A></DIV></DIV><!--广告代码开始-->
<SCRIPT>
var ad_cid;
if (window.location.search.substring(1) != "")
{
ad_cid = window.location.search.substring(1);
} else {
ad_cid = 412;
}
</SCRIPT>
<!--小通栏:c-scolumn顶部500*90--><SPAN id=span_ad1>
<SCRIPT language=JavaScript>
document.write("<script src=\"http://vd.yesky.com/html/"+ad_cid+"/"+ad_cid+"_c-scolumn.js\"><\/script>");</SCRIPT>
</SPAN>
<SCRIPT language=JavaScript>
document.getElementById("ad1").innerHTML=document.getElementById("span_ad1").innerHTML;
document.getElementById("span_ad1").innerHTML="";
</SCRIPT>
<!--c-pip文章正文中间240*200--><SPAN id=span_ad3>
<SCRIPT language=JavaScript>
document.write("<script src=\"http://vd.yesky.com/html/"+ad_cid+"/"+ad_cid+"_c-pip.js\"><\/script>");</SCRIPT>
</SPAN>
<SCRIPT>
if(document.getElementById("contentAdv")) {
document.getElementById("contentAdv").innerHTML=document.getElementById("span_ad3").innerHTML;
document.getElementById("span_ad3").innerHTML="";
} else {

⌨️ 快捷键说明

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