?? ks0108.lst
字號(hào):
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 - 顯示一個(gè)數(shù)據(jù)的十六進(jìn)制值
* DESCRIPTION: -
* 最大長(zhǎng)度4個(gè)
* @Param v:數(shù)據(jù)
* @Param x:X軸坐標(biāo)
* @Param y:Y軸坐標(biāo) XY均是起點(diǎn)坐標(biāo) 也就是數(shù)據(jù)最高字節(jié)坐標(biāo)
* @Param Len:長(zhǎng)度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 - 顯示一個(gè)水平的進(jìn)度條
* DESCRIPTION: -
C51 COMPILER V7.20 KS0108 09/04/2007 22:35:41 PAGE 21
* 附加有百分比顯示
* @Param x0:進(jìn)度條起點(diǎn)X軸坐標(biāo) 0-->127
* @Param x1:進(jìn)度條結(jié)束點(diǎn)X坐標(biāo) 0-->127 必須大于x0 百分比顯示于該坐標(biāo)之后
* @Param y:進(jìn)度條Y軸坐標(biāo) 0--7
* @Param percent:當(dāng)前百分值 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;//這個(gè)計(jì)算做法在430上能用,但C51下似乎必須用浮點(diǎn)算
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.20 KS0108 09/04/2007 22:35:41 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
坐標(biāo)應(yīng)該跟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 // ---- 顯示不帶符號(hào)的整數(shù) (數(shù)字 起始位置XY,顯示長(zhǎng)度) -----------------------------
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 // ---- 顯示帶符號(hào)的整數(shù) (數(shù)字 起始位置XY,顯示長(zhǎng)度) ---------------------------------
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 // ---- 顯示不帶符號(hào)的小數(shù) (數(shù)字 起始位置XY,整數(shù)位數(shù),小數(shù)位數(shù)) ------------------------------
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 // 顯示小數(shù)部分
1356 for(Lenth=DEC; Lenth>0; Lenth--)
C51 COMPILER V7.20 KS0108 09/04/2007 22:35:41 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 // 顯示小數(shù)點(diǎn)
1365 Display_ASCII('.', X, Y);
1366 //if (X < 8) {Y -= 2; X += 84;}
1367 X -= 8;
1368 // 顯示整數(shù)部分
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 // ---- 顯示帶符號(hào)的小數(shù) (數(shù)字 起始位置XY,整數(shù)位數(shù),小數(shù)位數(shù)) ------------------------------
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的滑動(dòng)距離是L-BarLen
1408 為了美觀,可以在開始和結(jié)尾部分多流出來(lái)一些點(diǎn),那么滑動(dòng)距離要扣除這些點(diǎn)的長(zhǎng)度,并在計(jì)算結(jié)果
1409 得到0的時(shí)候,添加上上端要留出來(lái)的點(diǎn)BarRemainDot
1410 2種顯示方式:
1411 一種是BarLen是定長(zhǎng)的,
1412 一種BarLen是根據(jù)顯示總共的項(xiàng)數(shù)定下來(lái)的
1413 */
1414
1415
1416 //--------------
1417 //Bar的長(zhǎng)度
1418 //預(yù)留出來(lái)的點(diǎn)
C51 COMPILER V7.20 KS0108 09/04/2007 22:35:41 PAGE 24
1419 #define BarRemainDot 3
1420 //數(shù)字顯示位置
1421 //#define BarNumPosX (128-8+2)
1422 #define BarNumPosY (7)
1423 //Bar的顯示開始/結(jié)束位置
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根據(jù)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){//頂端,把預(yù)留的加上
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數(shù)字
1478 1 /*
1479 1 for(i = 0; i < 5; i++){
1480 1 CharBuf[i] = (U8)(Item%10);
C51 COMPILER V7.20 KS0108 09/04/2007 22:35:41 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[
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -