?? ks0108.c
字號:
U8 i;
U8 dot;
U16 temp;
if(Y>(128-8)){//換行
X += 2;
Y = 0;
}
if(!Nor){
for(i=0;i<8;i++){
if(EnFont == 0){
WriteByte(X,(Y+i),chardot[i+(Char-0x20)*16]);
}else{
dot = chardot[i+(Char-0x20)*16];
temp = Changedot[dot];
//這段代碼把字體縱向放大2倍,外部調用時換行需要加倍
WriteByte(X,(Y+i),(U8)(temp&0x00FF));
WriteByte(X+1,(Y+i),(U8)((temp&0xFF00)>>8));
/*
//這段代碼把字體放大4倍,但由于橫向軸被放大,因此外部調用函數時也需要加倍
WriteByte(X,(Y+i*2),(U8)(temp&0x00FF));
WriteByte(X,(Y+i*2+1),(U8)(temp&0x00FF));
WriteByte(X+1,(Y+i*2),(U8)((temp&0xFF00)>>8));
WriteByte(X+1,(Y+i*2+1),(U8)((temp&0xFF00)>>8));
*/
}
}
for(i=8;i<16;i++){
if(EnFont == 0){
WriteByte(X+1,(Y+i-8),chardot[i+(Char-0x20)*16]);
}else{
dot = chardot[i+(Char-0x20)*16];
temp = Changedot[dot];
WriteByte(X+2,(Y+i-8),(U8)(temp&0x00FF));
WriteByte(X+3,(Y+i-8),(U8)((temp&0xFF00)>>8));
/*
WriteByte(X+2,(Y+(i-8)*2),(U8)(temp&0x00FF));
WriteByte(X+2,(Y+(i-8)*2+1),(U8)(temp&0x00FF));
WriteByte(X+3,(Y+(i-8)*2),(U8)((temp&0xFF00)>>8));
WriteByte(X+3,(Y+(i-8)*2+1),(U8)((temp&0xFF00)>>8));
*/
}
}
}else{
for(i=0;i<8;i++){
if(EnFont == 0){
WriteByte(X,(Y+i),0xFF-chardot[i+(Char-0x20)*16]);
}else{
dot = 0xFF-chardot[i+(Char-0x20)*16];
temp = Changedot[dot];
WriteByte(X*2,(Y+i),(U8)(temp&0x00FF));
WriteByte(X*2,(Y+i+1),(U8)(temp&0x00FF));
WriteByte(X*2+1,(Y+i),(U8)((temp&0xFF00)>>8));
WriteByte(X*2+1,(Y+i+1),(U8)((temp&0xFF00)>>8));
}
}
for(i=8;i<16;i++){
if(EnFont == 0){
WriteByte(X+1,(Y+i-8),0xFF-chardot[i+(Char-0x20)*16]);
}else{
dot = 0xFF-chardot[i+(Char-0x20)*16];
temp = Changedot[dot];
WriteByte((X+1)*2,(Y+i-8+1),(U8)(temp&0x00FF));
WriteByte((X+1)*2,(Y+i-8),(U8)(temp&0x00FF));
WriteByte((X+1)*2+1,(Y+i-8+1),(U8)((temp&0xFF00)>>8));
WriteByte((X+1)*2+1,(Y+i-8),(U8)((temp&0xFF00)>>8));
}
}
}
}
#endif
//--------------------------
#if 0
//-------------顯示普通圖片
//------(圖像 長度 起始位置)
void Display_Image(U8 _CONST_ *IMG)
{
U8 XAddr;
U8 YAddr;
U16 Count;
Count = 0;
for(XAddr=0;XAddr<8;XAddr++){//0--7
for(YAddr=0;YAddr<128;YAddr++){//0--127
WriteByte(XAddr,YAddr,IMG[Count++]);
}
}
}
#endif
/*
*****************************************************************************
* GUI_DrawIcon - 制定位置顯示一個32x32的圖標
* DESCRIPTION: -
*
* @Param x0:X軸坐標
* @Param y0:Y軸坐標 注意邊界!
* @Param Ico:圖標數據
* @Return :
* ----
*****************************************************************************
*/
void GUI_DrawIcon(U8 _CONST_ *Ico,U8 x0,U8 y0)
{
U8 i;
U16 Count;
Count = 0;
if( y0 > 4){//邊界保護
y0 = 4;
}
if(x0 >(LCD_XSIZE-32)){
x0 = LCD_XSIZE-32;
}
for(i=0;i<32;i++){//第一行
Display_Locate(Ico[Count++],x0+i,y0);
}
for(i=0;i<32;i++){//第二行
Display_Locate(Ico[Count++],x0+i,y0+1);
}
for(i=0;i<32;i++){//第三行
Display_Locate(Ico[Count++],x0+i,y0+2);
}
for(i=0;i<32;i++){//第四行
Display_Locate(Ico[Count++],x0+i,y0+3);
}
}
#if 0
/*
*****************************************************************************
* GUI_DispDecAt - 顯示十進制數值
* DESCRIPTION: -
* 處理長度最多5個數字(因為U16--->65536)
* @Param v:顯示的數據
* @Param x:X軸坐標
* @Param y:Y軸坐標 XY 均是起點位置坐標 也就是數值最高位的坐標
* @Param Len:指定的顯示長度1--5內
* @Return :
*
*****************************************************************************
*/
void GUI_DispDecAt(U16 v, U16 x, U16 y, U8 Len)
{
U8 i;
U8 CharBuf[5];
U8 HighByte;
HighByte = 0;
for(i = 0; i < 5; i++){
CharBuf[i] = (U8)(v%10);
v = v/10;
if(CharBuf[i]){
HighByte = i;
}
}
//第0位無論如何也顯示
i = 0;
GUI_DispCharAt(CharBuf[i]+'0',x+((Len-1)-i)*Char_XSIZE,y);
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: -
* 附加有百分比顯示
* @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);
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
/*
// ---- 顯示不帶符號的整數 (數字 起始位置XY,顯示長度) -----------------------------
void Display_Number(U16 Number, U8 X, U8 Y, U8 Lenth)
{
U8 DispNum;
X = ( X + Lenth * 8 - 8 );
for(; Lenth>0; Lenth--)
{
DispNum = Number%10 + 0x30;
Display_ASCII(DispNum, X, Y);
X -= 8;
Number = Number / 10;
}
}
// ---- 顯示帶符號的整數 (數字 起始位置XY,顯示長度) ---------------------------------
void Display_SignedNumber(int Number,U8 X,U16 Y,U8 Lenth)
{
if(Number < 0)
{
Display_ASCII('-', X, Y);
Display_Number(-Number, X+8, Y, Lenth);
}
else
{
Display_ASCII(' ', X, Y);
Display_Number(Number, X+8, Y, Lenth);
}
}
// ---- 顯示不帶符號的小數 (數字 起始位置XY,整數位數,小數位數) ------------------------------
void Display_Decimal(unsigned long int Number, char X, U16 Y, U8 INT, U8 DEC)
{
U8 DispNum, Lenth;
//Y = Y +(( X + INT * 8 + DEC * 8 ) / 84) * 2;
X = ( X + ( INT + DEC ) *8);
// 顯示小數部分
for(Lenth=DEC; Lenth>0; Lenth--)
{
DispNum = Number%10 + 0x30;
Display_ASCII(DispNum, X, Y);
//if (X < 8) {Y -= 2; X += 84;}
X -= 8;
Number = Number / 10;
}
// 顯示小數點
Display_ASCII('.', X, Y);
//if (X < 8) {Y -= 2; X += 84;}
X -= 8;
// 顯示整數部分
for(Lenth=INT; Lenth>0; Lenth--)
{
DispNum = Number%10 + 0x30;
Display_ASCII(DispNum, X, Y);
//if (X < 8) {Y -= 2; X += 84;}
X -= 8;
Number = Number / 10;
}
}
// ---- 顯示帶符號的小數 (數字 起始位置XY,整數位數,小數位數) ------------------------------
void Display_SignedDecimal(long int Number, char X, U16 Y, U8 INT, U8 DEC)
{
if(Number < 0)
{
Display_ASCII('-', X, Y);
Display_Decimal(-Number, X+8, Y, INT, DEC);
}
else
{
Display_ASCII(' ',X,Y);
Display_Decimal(Number, X+8, Y, INT, DEC);
}
}
*/
//--------------
/*
Bar的算法
___
| |
| |
| |<-|-----BarLen
| L
| |
| |
| _|_
Bar的滑動距離是L-BarLen
為了美觀,可以在開始和結尾部分多流出來一些點,那么滑動距離要扣除這些點的長度,并在計算結果
得到0的時候,添加上上端要留出來的點BarRemainDot
2種顯示方式:
一種是BarLen是定長的,
一種BarLen是根據顯示總共的項數定下來的
*/
//--------------
//Bar的長度
//預留出來的點
#define BarRemainDot 3
//數字顯示位置
//#define BarNumPosX (128-8+2)
#define BarNumPosY (7)
//Bar的顯示開始/結束位置
//#define BarBeginPosX (126)
#define BarBeginPosY (0*8)
#define BarEndPosX (126)
#define BarEndPosY (6*8)
U8 _CONST_ BarCode0[]={0xFF,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00};
U8 _CONST_ BarCode1[]={0x00,0x01,0x03,0x07,0x0F,0x1F,0x3F,0x7F,0xFF};
extern U8 ItemBackup_i;
extern U8 ItemBackup[];
void Bar(U8 Item_,U8 ItemNum_,U8 BarPosX,U8 BarNumPosX)
{
U8 U8_temp;
U8 DispFlag;
U8 YOffset;
U16 Temp;
U8 BarLen;
U8 Y;
U8 i;
// U8 CharBuf[5];
// Bool HighBit;
BarLen = (BarEndPosY-BarBeginPosY-BarRemainDot)/(ItemNum_);//BarLen根據ItemNum_得到
if (BarLen == 0) {
BarLen = 5;
}
BarLen = 8;
Temp = Item_*(BarEndPosY-BarBeginPosY-BarLen-BarRemainDot);//BarRemainDot是被扣除的部分
Temp = Temp/(ItemNum_-1);
YOffset = (U8)Temp;
if(!Temp){//頂端,把預留的加上
YOffset = BarRemainDot;
}
for(Y = 0;Y < BarEndPosY/8;Y++){
if((Y != (YOffset/8))&&(Y != (YOffset/8+1))){
Display_Locate(0x00,BarPosX,Y);//清除 X=125 列
Display_Locate(0xFF,BarPosX+1,Y);//X=126列畫線
Display_Locate(0x00,BarPosX+2,Y);//清除 X=127 列
}else{//Y = YOffset/8 Y = YOffset/8+1
Display_Locate(BarCode0[YOffset%8],BarPosX,(YOffset/8));
Display_Locate(0xFF-BarCode0[YOffset%8],BarPosX+1,(YOffset/8));
Display_Locate(BarCode0[YOffset%8],BarPosX+2,(YOffset/8));
if((YOffset/8)+1 < (BarEndPosY/8)){//防止下越界
Display_Locate(BarCode1[YOffset%8],BarPosX,(YOffset/8+1));
Display_Locate(0xFF-BarCode1[YOffset%8],BarPosX+1,(YOffset/8+1));
Display_Locate(BarCode1[YOffset%8],BarPosX+2,(YOffset/8+1));
}
}
}
GUI_SetEnFont(En_5x8);
Item_ += 1;
//顯示Bar數字
/*
for(i = 0; i < 5; i++){
CharBuf[i] = (U8)(Item%10);
Item = Item/10;
}
HighBit = false;
for(i = 0; i < 5; i++){
if(CharBuf[4-i]){//從最高位開始顯示
GUI_DispCharAt(CharBuf[4-i]+'0',x+8*i,y);
HighBit = true;
}else{
if(HighBit == true){
GUI_DispCharAt('0',x+Char_XSIZE*i,y);//如果高位不為0,當前值為0 ,顯示0
}
}
}
*/
DispFlag = false;
U8_temp = (U8)(Item_/100);// 百位
if(U8_temp){
GUI_DispCharAt(U8_temp+'0',BarNumPosX-12,BarNumPosY);
DispFlag = true;//通知低位顯示
}else{
GUI_DispCharAt(' ',BarNumPosX-12,BarNumPosY);
}
Item_ = (Item_-U8_temp*100);//剔除百位
U8_temp = (U8)(Item_/10);// 十位
if(U8_temp||(DispFlag == true)){//本位不為0,或者高位已經顯示,那么必須顯示
GUI_DispCharAt(U8_temp+'0',BarNumPosX-6,BarNumPosY);
DispFlag = 1;
}else{
GUI_DispCharAt(' ',BarNumPosX-6,BarNumPosY);
}
U8_temp = (U8)(Item_%10);// 個位
GUI_DispCharAt(U8_temp+'0',BarNumPosX,BarNumPosY);
//----------------------------------
//顯示歷史索引號
if(ItemBackup_i > 1){//大于1才是
for(i = 0; i <ItemBackup_i-1;i++){//最后一個位于1的位置
Item_ = ItemBackup[ItemBackup_i-1-i]+1; //從備份數據中得到標號,然后加1顯示
U8_temp = (U8)(Item_%10);//
GUI_DispCharAt(U8_temp+'0',BarNumPosX-8*(i+1),BarNumPosY);
Display_Locate(0x10, BarNumPosX-8*(i+1)+8-1, BarNumPosY); //描分隔符
Display_Locate(0x10, BarNumPosX-8*(i+1)+8-0, BarNumPosY);
}
}
//----------------------------------
GUI_SetEnFont(En_8x16);
return;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -