00001 00005 #include "display.h" 00006 #include "lcd.h" 00007 #include "board.h" 00008 #include "string.h" 00009 00010 volatile xdata char displayPosition; 00011 xdata char displayTitle[16]; 00012 xdata char displayText[DS_TEXTLENGTH+1]; 00013 xdata char displayLength; 00014 xdata char displayStyle; 00015 xdata char displayValue; 00016 00017 00018 00019 00020 00021 00023 char InitDisplay(char style, char *title, char *text, int value){ 00024 00025 LcdReset(); 00026 00027 //Init display title array 00028 for(displayPosition=0; displayPosition<8; displayPosition++){ 00029 displayTitle[displayPosition]=' '; 00030 } 00031 displayTitle[8]=0; //ending zero 00032 strcpy(displayTitle, title); 00033 00034 00035 displayLength = strlen(text); 00036 //Init display text array 00037 //Clear display text array to spaces 00038 for(displayPosition=0; displayPosition<DS_TEXTLENGTH; displayPosition++){ 00039 displayText[displayPosition]=' '; 00040 } 00041 displayText[DS_TEXTLENGTH] = 0; //ending zero 00042 strcpy(displayText, text); 00043 00044 00045 displayPosition = 0; 00046 displayStyle = style; 00047 displayValue = value; 00048 LcdPutString(displayTitle); 00049 LcdLocateLine2(); 00050 LcdPutString(displayText); 00051 UpdateDisplay(); 00052 00053 return 0; 00054 } 00055 00056 00058 void UpdateDisplay(){ 00059 00060 signed char temp; 00061 00062 LcdLocateHome(); 00063 LcdPutChar(displayTitle[0]); 00064 LcdPutChar(displayTitle[1]); 00065 LcdPutChar(displayTitle[2]); 00066 LcdPutChar(displayTitle[3]); 00067 LcdPutChar(displayTitle[4]); 00068 LcdPutChar(displayTitle[5]); 00069 LcdPutChar(displayTitle[6]); 00070 LcdPutChar(displayTitle[7]); 00071 LcdLocateLine2(); 00072 00073 if (displayStyle == DS_STATIC){ 00074 for (temp=0; temp<8; temp++){ 00075 LcdPutChar(displayText[temp]); 00076 } 00077 } 00078 00079 if (displayStyle == DS_TEXT){ 00080 for (temp=displayPosition; temp<displayPosition + 8; temp++){ 00081 if (temp<0){ 00082 LcdPutChar(' '); 00083 }else{ 00084 if (displayText[temp]){ 00085 LcdPutChar(displayText[temp]); 00086 }else{ 00087 LcdPutChar(' '); 00088 } 00089 } 00090 } 00091 } 00092 00093 if (displayStyle == DS_NUMERIC){ 00094 LcdPutUInt(displayValue); 00095 LcdPutConstantString(" "); 00096 } 00097 00098 if (displayStyle == DS_NO_YES){ 00099 LcdPutConstantString(" No<>Yes"); 00100 } 00101 00102 if (displayStyle == DS_ARROWS){ 00103 LcdPutConstantString(" <- ->"); 00104 } 00105 00106 if (displayStyle == DS_PERCENTAGE){ 00107 unsigned char majorp, minorp; 00108 if (displayValue>100){ 00109 displayValue=100; 00110 } 00111 00112 majorp = (displayValue-4) / 12; 00113 minorp = ((displayValue-4) % 12) >> 1; 00114 for (temp=0; temp<8; temp++){ 00115 if (majorp>temp){ 00116 LcdPutChar(4); 00117 }else{ 00118 if (majorp<temp){ 00119 LcdPutChar(' '); 00120 }else{ 00121 switch(minorp){ 00122 case 0: 00123 LcdPutChar(' '); 00124 break; 00125 case 1: 00126 LcdPutChar(0); 00127 break; 00128 case 2: 00129 LcdPutChar(1); 00130 break; 00131 case 3: 00132 LcdPutChar(2); 00133 break; 00134 case 4: 00135 LcdPutChar(3); 00136 break; 00137 case 5: 00138 LcdPutChar(4); 00139 break; 00140 }//switch 00141 } 00142 } 00143 } 00144 //LcdPutUInt(displayValue); 00145 //LcdPutConstantString("% "); 00146 } 00147 00148 if (displayStyle==DS_RAWTEXT){ 00149 LcdPutChar(displayTitle[8]); 00150 LcdPutChar(displayTitle[9]); 00151 LcdPutChar(displayTitle[10]); 00152 LcdPutChar(displayTitle[11]); 00153 LcdPutChar(displayTitle[12]); 00154 LcdPutChar(displayTitle[13]); 00155 LcdPutChar(displayTitle[14]); 00156 LcdPutChar(displayTitle[15]); 00157 } 00158 00159 00160 }