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

📄 ks0108.lst

📁 一个占用内存极少的菜单系统的实现
💻 LST
📖 第 1 页 / 共 5 页
字号:
                  for(i = 1; i < Len; i++){
                      if(CharBuf[i]){
                          GUI_DispCharAt(CharBuf[i]+'0',x+((Len-1)-i)*Char_XSIZE,y);
                      }else if(i > HighByte){
                          GUI_DispCharAt(' ',x+((Len-1)-i)*Char_XSIZE,y);
                      }
                  }
              
              }
              
              /*
              *****************************************************************************
              * GUI_DispHexAt - 显示一个数据的十六进制值
              * DESCRIPTION: -
              * 最大长度4个
              * @Param v:数据
              * @Param x:X轴坐标
              * @Param y:Y轴坐标  XY均是起点坐标 也就是数据最高字节坐标
              * @Param Len:长度1--4
              * @Return :
              *
              *****************************************************************************
              */
              void GUI_DispHexAt(U32 v, U8 x, U8 y, U8 Len)
              {
                  U8 i;
                  U8 HexData;
                  if(Len > 8){//限制范围
                      Len = 8;
                  }
                  for(i = 0; i < Len; i++){
                      HexData = v&0x0F;
                      v = v >>4;
                      if(HexData < 0x0A){
                          GUI_DispCharAt(HexData+'0',x+Char_XSIZE*(Len-1-i),y);
                      }else{
                          GUI_DispCharAt(HexData-0x0A+'A',x+Char_XSIZE*(Len-1-i),y);
                      }
                  }
              }
              /*
              *****************************************************************************
              * HBar - 显示一个水平的进度条
              * DESCRIPTION: -
C51 COMPILER V7.06   KS0108                                                                04/16/2008 17:32:01 PAGE 21  

              * 附加有百分比显示
              * @Param x0:进度条起点X轴坐标   0-->127
              * @Param x1:进度条结束点X坐标   0-->127  必须大于x0  百分比显示于该坐标之后
              * @Param y:进度条Y轴坐标        0--7
              * @Param percent:当前百分值     0-->100
              * @Return :
              *
              *****************************************************************************
              */
              void HBar(U8 y, U8 x0, U8 x1,U8 percent)
              {
                  U8 U8Temp;
                  U8 i;
                  float Center;
                  Center = (x1-x0);
                  Center *= percent;
                  Center /= 100;
              //    U8Temp = (x1-x0)*percent/100;//这个计算做法在430上能用,但C51下似乎必须用浮点算
                  U8Temp = (U8)Center;
                  Display_Locate(0xFF, x0, y);
                  Display_Locate(0xFF, x1, y);
                  for(i = 1; i < U8Temp; i++){
                      Display_Locate(0xBD, x0+i, y);
                  }
                  for(i = x0+U8Temp+1; i < x1; i++){
                      Display_Locate(0x81, i, y);
                  }
              }
              /*                  x1 +3
              |-------------------|
              |                   ||
              |                   |||
              |                   ||||
              |                   ||||
              --------------------
               -------------------
                ------------------
              x0--->x1+3
              y0--->y1
              
              
              */
              
              void TipDisp( U8 x0, U8 y0, U8 x1, U8 y1)
              {
                  U8 i;
                  for(i = 0; i < x1-x0+4; i++){
                      Display_Locate(0x01, x0+i, y0);
                      Display_Locate(0x0F, x0+i, y1);
                  }
                  Display_Locate(0x01, x0+0, y1);
                  Display_Locate(0x01, x0+1, y1);
                  Display_Locate(0x03, x0+2, y1);
                  Display_Locate(0x03, x0+3, y1);
                  Display_Locate(0x07, x0+4, y1);
                  Display_Locate(0x07, x0+5, y1);
              
                  for(i = 0; i < y1-y0; i++){
                      Display_Locate(0xFF, x0, y0+i);
                      Display_Locate(0xFF, x1, y0+i);
                      Display_Locate(0xFF, x1+1, y0+i);
                      Display_Locate(0xFF, x1+2, y0+i);
C51 COMPILER V7.06   KS0108                                                                04/16/2008 17:32:01 PAGE 22  

                      Display_Locate(0xFF, x1+3, y0+i);
                  }
                  Display_Locate(0xFC, x1+1, y0);
                  Display_Locate(0xF0, x1+2, y0);
                  Display_Locate(0xC0, x1+3, y0);
              }
              
              /*
              清空Tip
              坐标应该跟TipDisp一样
              */
              void TipClr( U8 x0, U8 y0, U8 x1, U8 y1)
              {
                  U8 i;
                  U8 j;
                  for(i = 0; i <= x1+3-x0; i++){
                      for(j = 0; j <= y1-y0; j++){
                          Display_Locate(0x00, x0+i, y0+j);
                      }
                  }
              
              }
              #endif
1318          /*
1319          // ---- 显示不带符号的整数  (数字 起始位置XY,显示长度) -----------------------------
1320          void Display_Number(U16 Number, U8 X, U8 Y, U8 Lenth)
1321          {
1322            U8 DispNum;
1323          
1324            X = ( X + Lenth * 8 - 8 );
1325            for(; Lenth>0; Lenth--)
1326            {
1327              DispNum = Number%10 + 0x30;
1328              Display_ASCII(DispNum, X, Y);
1329              X -= 8;
1330              Number = Number / 10;
1331            }
1332          }
1333          
1334          // ---- 显示带符号的整数  (数字 起始位置XY,显示长度) ---------------------------------
1335          void Display_SignedNumber(int Number,U8 X,U16 Y,U8 Lenth)
1336          {
1337            if(Number < 0)
1338            {
1339              Display_ASCII('-', X, Y);
1340              Display_Number(-Number, X+8, Y, Lenth);
1341            }
1342            else
1343            {
1344              Display_ASCII(' ', X, Y);
1345              Display_Number(Number, X+8, Y, Lenth);
1346            }
1347          }
1348          
1349          // ---- 显示不带符号的小数 (数字 起始位置XY,整数位数,小数位数) ------------------------------
1350          void Display_Decimal(unsigned long int Number, char X, U16 Y, U8 INT, U8 DEC)
1351          {
1352            U8 DispNum, Lenth;
1353            //Y = Y +(( X + INT * 8 + DEC * 8 ) / 84) * 2;
1354            X = ( X + ( INT + DEC ) *8);
1355            // 显示小数部分
1356            for(Lenth=DEC; Lenth>0; Lenth--)
C51 COMPILER V7.06   KS0108                                                                04/16/2008 17:32:01 PAGE 23  

1357            {
1358              DispNum = Number%10 + 0x30;
1359              Display_ASCII(DispNum, X, Y);
1360              //if (X < 8) {Y -= 2; X += 84;}
1361              X -= 8;
1362              Number = Number / 10;
1363            }
1364            // 显示小数点
1365            Display_ASCII('.', X, Y);
1366            //if (X < 8) {Y -= 2; X += 84;}
1367              X -= 8;
1368            // 显示整数部分
1369            for(Lenth=INT; Lenth>0; Lenth--)
1370            {
1371              DispNum = Number%10 + 0x30;
1372              Display_ASCII(DispNum, X, Y);
1373              //if (X < 8) {Y -= 2; X += 84;}
1374              X -= 8;
1375              Number = Number / 10;
1376            }
1377          }
1378          
1379          // ---- 显示带符号的小数 (数字 起始位置XY,整数位数,小数位数) ------------------------------
1380          void Display_SignedDecimal(long int Number, char X, U16 Y, U8 INT, U8 DEC)
1381          {
1382            if(Number < 0)
1383            {
1384              Display_ASCII('-', X, Y);
1385              Display_Decimal(-Number, X+8, Y, INT, DEC);
1386            }
1387            else
1388            {
1389            Display_ASCII(' ',X,Y);
1390            Display_Decimal(Number, X+8, Y, INT, DEC);
1391            }
1392          }
1393          */
1394          
1395          
1396          //--------------
1397          /*
1398          Bar的算法
1399              ___
1400           |   |
1401           |   |
1402          | |<-|-----BarLen
1403           |   L
1404           |   |
1405           |   |
1406           |  _|_
1407          Bar的滑动距离是L-BarLen
1408          为了美观,可以在开始和结尾部分多流出来一些点,那么滑动距离要扣除这些点的长度,并在计算结果
1409          得到0的时候,添加上上端要留出来的点BarRemainDot
1410          2种显示方式:
1411          一种是BarLen是定长的,
1412          一种BarLen是根据显示总共的项数定下来的
1413          */
1414          
1415          
1416          //--------------
1417          //Bar的长度
1418          //预留出来的点
C51 COMPILER V7.06   KS0108                                                                04/16/2008 17:32:01 PAGE 24  

1419          #define BarRemainDot  3
1420          //数字显示位置
1421          //#define BarNumPosX (128-8+2)
1422          #define BarNumPosY (7)
1423          //Bar的显示开始/结束位置
1424          //#define BarBeginPosX (126)
1425          #define BarBeginPosY (0*8)
1426          #define BarEndPosX (126)
1427          #define BarEndPosY (6*8)
1428          
1429          U8 _CONST_ BarCode0[]={0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00};
1430          U8 _CONST_ BarCode1[]={0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF};
1431          extern U8 ItemBackup_i;
1432          extern U8 ItemBackup[];
1433          
1434          void Bar(U8 Item_,U8 ItemNum_,U8 BarPosX,U8 BarNumPosX)
1435          {
1436   1          U8 U8_temp;
1437   1          U8 DispFlag;
1438   1          U8 YOffset;
1439   1          U16 Temp;
1440   1          U8 BarLen;
1441   1          U8 Y;
1442   1          U8 i;
1443   1      //    U8 CharBuf[5];
1444   1      //    Bool HighBit;
1445   1      
1446   1          BarLen = (BarEndPosY-BarBeginPosY-BarRemainDot)/(ItemNum_);//BarLen根据ItemNum_得到
1447   1          if (BarLen == 0) {
1448   2              BarLen = 5;
1449   2          }
1450   1          BarLen = 8;
1451   1          Temp = Item_*(BarEndPosY-BarBeginPosY-BarLen-BarRemainDot);//BarRemainDot是被扣除的部分
1452   1          Temp = Temp/(ItemNum_-1);
1453   1          YOffset = (U8)Temp;
1454   1          if(!Temp){//顶端,把预留的加上
1455   2              YOffset = BarRemainDot;
1456   2          }
1457   1      
1458   1          for(Y = 0;Y < BarEndPosY/8;Y++){
1459   2              if((Y != (YOffset/8))&&(Y != (YOffset/8+1))){
1460   3                  Display_Locate(0x00,BarPosX,Y);//清除 X=125 列
1461   3                  Display_Locate(0xFF,BarPosX+1,Y);//X=126列画线
1462   3                  Display_Locate(0x00,BarPosX+2,Y);//清除 X=127 列
1463   3              }else{//Y = YOffset/8 Y = YOffset/8+1
1464   3                  Display_Locate(BarCode0[YOffset%8],BarPosX,(YOffset/8));
1465   3                  Display_Locate(0xFF-BarCode0[YOffset%8],BarPosX+1,(YOffset/8));
1466   3                  Display_Locate(BarCode0[YOffset%8],BarPosX+2,(YOffset/8));
1467   3                  if((YOffset/8)+1 < (BarEndPosY/8)){//防止下越界
1468   4                      Display_Locate(BarCode1[YOffset%8],BarPosX,(YOffset/8+1));
1469   4                      Display_Locate(0xFF-BarCode1[YOffset%8],BarPosX+1,(YOffset/8+1));
1470   4                      Display_Locate(BarCode1[YOffset%8],BarPosX+2,(YOffset/8+1));
1471   4                  }
1472   3              }
1473   2          }
1474   1      
1475   1          GUI_SetEnFont(En_5x8);
1476   1          Item_ += 1;
1477   1          //显示Bar数字
1478   1      /*
1479   1          for(i = 0; i < 5; i++){
1480   1              CharBuf[i] = (U8)(Item%10);
C51 COMPILER V7.06   KS0108                                                                04/16/2008 17:32:01 PAGE 25  

1481   1              Item = Item/10;
1482   1          }
1483   1          HighBit = false;
1484   1          for(i = 0; i < 5; i++){
1485   1              if(CharBuf[

⌨️ 快捷键说明

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