Main Page | Data Structures | File List | Data Fields | Globals

ATAVRBFLY_FILES/LCD_functions.c

Go to the documentation of this file.
00001 // This file has been prepared for Doxygen automatic documentation generation. 00023 // Include files 00024 #include"iom169.h" 00025 #include"main.h" 00026 #include"Lcd_driver.h" 00027 #include"Lcd_functions.h" 00028 #include"BCD.h" 00029 00030 #define FALSE 0 00031 #define TRUE (!FALSE) 00032 00033 char CONTRAST = LCD_INITIAL_CONTRAST; 00034 00035 // Start-up delay before scrolling a string over the LCD. "LCD_driver.c" 00036 extern char gLCD_Start_Scroll_Timer; 00037 00038 /**************************************************************************** 00039 * 00040 * Function name : LCD_puts_f 00041 * 00042 * Returns : None 00043 * 00044 * Parameters : pFlashStr: Pointer to the string in flash 00045 * scrollmode: Not in use 00046 * 00047 * Purpose : Writes a string stored in flash to the LCD 00048 * 00049 *****************************************************************************/ 00050 00051 void LCD_puts_f(char __flash *pFlashStr, char scrollmode) 00052 { 00053 char i; 00054 00055 while (gLCD_Update_Required); // Wait for access to buffer 00056 00057 for (i = 0; pFlashStr[i] && i < TEXTBUFFER_SIZE; i++) 00058 { 00059 gTextBuffer[i] = pFlashStr[i]; 00060 } 00061 00062 gTextBuffer[i] = '\0'; 00063 00064 if (i > 6) 00065 { 00066 gScrollMode = 1; // Scroll if text is longer than display size 00067 gScroll = 0; 00068 gLCD_Start_Scroll_Timer = 3; //Start-up delay before scrolling the text 00069 } 00070 else 00071 { 00072 gScrollMode = 0; 00073 gScroll = 0; 00074 } 00075 00076 gLCD_Update_Required = 1; 00077 } 00078 00079 00080 /**************************************************************************** 00081 * 00082 * Function name : LCD_puts 00083 * 00084 * Returns : None 00085 * 00086 * Parameters : pStr: Pointer to the string 00087 * scrollmode: Not in use 00088 * 00089 * Purpose : Writes a string to the LCD 00090 * 00091 *****************************************************************************/ 00092 void LCD_puts(char *pStr, char scrollmode) 00093 { 00094 char i; 00095 00096 while (gLCD_Update_Required); // Wait for access to buffer 00097 00098 for (i = 0; pStr[i] && i < TEXTBUFFER_SIZE; i++) 00099 { 00100 gTextBuffer[i] = pStr[i]; 00101 } 00102 00103 gTextBuffer[i] = '\0'; 00104 00105 if (i > 6) 00106 { 00107 gScrollMode = 1; // Scroll if text is longer than display size 00108 gScroll = 0; 00109 gLCD_Start_Scroll_Timer = 3; //Start-up delay before scrolling the text 00110 } 00111 else 00112 { 00113 gScrollMode = 0; 00114 gScroll = 0; 00115 } 00116 00117 gLCD_Update_Required = 1; 00118 } 00119 00120 00121 /**************************************************************************** 00122 * 00123 * Function name : LCD_putc 00124 * 00125 * Returns : None 00126 * 00127 * Parameters : digit: Which digit to write on the LCD 00128 * character: Character to write 00129 * 00130 * Purpose : Writes a character to the LCD 00131 * 00132 *****************************************************************************/ 00133 void LCD_putc(char digit, char character) 00134 { 00135 if (digit < TEXTBUFFER_SIZE) 00136 gTextBuffer[digit] = character; 00137 } 00138 00139 00140 /**************************************************************************** 00141 * 00142 * Function name : LCD_Clear 00143 * 00144 * Returns : None 00145 * 00146 * Parameters : None 00147 * 00148 * Purpose : Clear the LCD 00149 * 00150 *****************************************************************************/ 00151 void LCD_Clear(void) 00152 { 00153 char i; 00154 00155 for (i=0; i<TEXTBUFFER_SIZE; i++) 00156 gTextBuffer[i] = ' '; 00157 } 00158 00159 00160 /**************************************************************************** 00161 * 00162 * Function name : LCD_Colon 00163 * 00164 * Returns : None 00165 * 00166 * Parameters : show: Enables the colon if TRUE, disable if FALSE 00167 * 00168 * Purpose : Enable/disable colons on the LCD 00169 * 00170 *****************************************************************************/ 00171 void LCD_Colon(char show) 00172 { 00173 gColon = show; 00174 } 00175 00176 00177 /**************************************************************************** 00178 * 00179 * Function name : LCD_UpdateRequired 00180 * 00181 * Returns : None 00182 * 00183 * Parameters : update: TRUE/FALSE 00184 * scrollmode: not in use 00185 * 00186 * Purpose : Tells the LCD that there is new data to be presented 00187 * 00188 *****************************************************************************/ 00189 void LCD_UpdateRequired(char update, char scrollmode) 00190 { 00191 00192 while (gLCD_Update_Required); 00193 00194 gScrollMode = scrollmode; 00195 gScroll = 0; 00196 00197 gLCD_Update_Required = update; 00198 } 00199 00200 00201 /**************************************************************************** 00202 * 00203 * Function name : LCD_FlashReset 00204 * 00205 * Returns : None 00206 * 00207 * Parameters : None 00208 * 00209 * Purpose : This function resets the blinking cycle of a flashing digit 00210 * 00211 *****************************************************************************/ 00212 void LCD_FlashReset(void) 00213 { 00214 gFlashTimer = 0; 00215 } 00216 00217 00218 00219 /**************************************************************************** 00220 * 00221 * Function name : SetContrast 00222 * 00223 * Returns : char ST_state (to the state-machine) 00224 * 00225 * Parameters : char input (from joystick) 00226 * 00227 * Purpose : Adjust the LCD contrast 00228 * 00229 *****************************************************************************/ 00230 char SetContrast(char input) 00231 { 00232 static char enter = 1; 00233 char CH, CL; 00234 00235 if (enter) 00236 { 00237 LCD_Clear(); 00238 enter = 0; 00239 } 00240 00241 CH = CHAR2BCD2(CONTRAST); 00242 CL = (CH & 0x0F) + '0'; 00243 CH = (CH >> 4) + '0'; 00244 00245 LCD_putc(0, 'C'); 00246 LCD_putc(1, 'T'); 00247 LCD_putc(2, 'R'); 00248 LCD_putc(3, ' '); 00249 LCD_putc(4, CH); 00250 LCD_putc(5, CL); 00251 00252 LCD_UpdateRequired(TRUE, 0); 00253 00254 if (input == KEY_PLUS) 00255 CONTRAST++; 00256 else if (input == KEY_MINUS) 00257 CONTRAST--; 00258 00259 if (CONTRAST == 255) 00260 CONTRAST = 0; 00261 if (CONTRAST > 15) 00262 CONTRAST = 15; 00263 00264 LCD_CONTRAST_LEVEL(CONTRAST); 00265 00266 00267 00268 00269 return 1; 00270 }

Generated on Tue Nov 1 16:21:39 2005 for AVR323 Interfacing GSM modems by doxygen 1.3.7