LCD_functions.c File Reference


Detailed Description

Additional LCD functions, scrolling text and write data.

Application note:
AVR064: A Temperature Monitoring System with LCD Output
Documentation:
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Name
RELEASE_1_1
Revision
1.3
RCSfile
LCD_functions.c,v
Date
2006/02/16 18:11:22

Definition in file LCD_functions.c.

#include "Main.h"
#include "Lcd_functions.h"
#include "Lcd_driver.h"

Include dependency graph for LCD_functions.c:

Go to the source code of this file.

Functions

void LCD_update (void)
 Checks if the LCD is ready for new data.
void LCDscrollMsg (void)
 Make a text-string scroll over the LCD-display. The text-string will scroll one step to the left each time this funciton is executed.
void LCDsetupData (void)
 Set up the text to be displayed (if any).
void LCDwriteData (void)
 Writes date from the Transmit Buffer to the LCD_displayData.

Variables

__flash unsigned char BlinkTable [3][6]
unsigned char Clear_cnt
unsigned char Colon = FALSE
__flash unsigned char DataTable [5][6]
unsigned char LCD_displayData []
unsigned char LCD_Menu1
unsigned char LCD_Menu2
unsigned char LCD_Menu3
unsigned char NumberOfScroll
unsigned char * String
unsigned char String_cnt
unsigned char * String_Table [6] = {"Clock", "Date", "Setpoint", "Temperature", "Offset", "Contrast"}
unsigned char TransmitBuffer [50]


Function Documentation

void LCD_update void   ) 
 

Checks if the LCD is ready for new data.

Definition at line 75 of file LCD_functions.c.

References Colon, FALSE, LCD_AllSegments(), LCD_Menu1, LCD_SET_COLON, LCD_status, LCDscrollMsg(), LCDwriteData(), NumberOfScroll, TRUE, _LCD_status::updateComplete, and _LCD_status::updateRequired.

Referenced by main().

00076 {
00077     if( LCD_status.updateComplete ) // if the LCD is ready for new data
00078     {
00079         if( NumberOfScroll )    //if there is a text to be scrolled
00080         {
00081             LCD_status.updateRequired = FALSE;  // block LCD updating while updating the LCD_displaydata
00082             LCD_AllSegments(FALSE);             // disable all segments
00083             LCDscrollMsg();                     // call the scroll function
00084             LCD_status.updateComplete = FALSE;  // indicate that new data are not presented on the LCD
00085             LCD_status.updateRequired = TRUE;   // enable LCD_displayData to be lacthed to the LCD data Regs
00086         }
00087         else                    //else write the data from the Transmit Buffer
00088         {
00089             if( LCD_Menu1-1 < 5 )               // if not the CONTRAST is to be displayed
00090             {
00091                 LCD_status.updateRequired = FALSE;  // block LCD updating while updating the LCD_displaydata
00092                 LCD_SET_COLON(Colon);               // set/clear colons depending on the varibale Colon (TRUE/FALSE)
00093                 LCDwriteData();                     // call the write data funciton
00094                 LCD_status.updateComplete = FALSE;  // indicate that new data are not presented on the LCD
00095                 LCD_status.updateRequired = TRUE;   // enable LCD_displayData to be lacthed to the LCD data Regs
00096             }
00097             else                                    // else set all the segments
00098                 LCD_AllSegments(TRUE);
00099         }
00100     }
00101 }

Here is the call graph for this function:

void LCDscrollMsg void   ) 
 

Make a text-string scroll over the LCD-display. The text-string will scroll one step to the left each time this funciton is executed.

Definition at line 183 of file LCD_functions.c.

References Clear_cnt, LCD_WriteDigit(), String, and String_cnt.

Referenced by LCD_update().

00184 {
00185     unsigned char LCD_digit_cnt;  // keeps track of which of the six LCD-digits to write
00186     unsigned char Temp;           // local storage for the global String_cnt
00187 
00188         if(*(String + String_cnt))  // until the string ends
00189         {
00190             LCD_digit_cnt = 8;          // start with writing to the last digit
00191 
00192             Temp = String_cnt;          // store the global String_cnt to the local Temp
00193 
00194             while(LCD_digit_cnt > 2)    // while the all digits on LCD has been written once
00195             {
00196                 LCD_digit_cnt--;            // decrease the digit counter
00197 
00198                 if(Temp != 0xFF)            // if the Temp is not 0xFF, not end of the string
00199                     LCD_WriteDigit(*(String + Temp--), LCD_digit_cnt);  //write a character and decrease the Temp
00200                 else                        // else it is the end of the string
00201                     LCD_WriteDigit( ' ', LCD_digit_cnt );    // fill the digit with a ASCII-space
00202             }
00203             String_cnt++;                   // increment the global string counter
00204             Clear_cnt = (String_cnt + 6);   // set the
00205         }
00206         else if(Clear_cnt - String_cnt)     // else when the whole string has been displayed, make the string fade out
00207         {                                   // by filling the display with ASCII-space ' '(0x20)
00208             Clear_cnt--;                        // decrease number of characters left to fade out
00209 
00210             LCD_digit_cnt = 8;
00211             Temp = 1;
00212 
00213             while(LCD_digit_cnt > 2)        // while the all digits on LCD has been written once
00214             {
00215                 LCD_digit_cnt--;                // decrease the digit counter
00216 
00217                 if( (LCD_digit_cnt - 2) >= (Clear_cnt - String_cnt))    // if the digit counter is greater or equal to the number characters that are cleared (' ') minus
00218                 {                                                       // the number of characters left in the string
00219                     LCD_WriteDigit( ' ' , LCD_digit_cnt );                  // write a ASCII-space this LCD-digit
00220                 }
00221                 else
00222                 {
00223                     LCD_WriteDigit( *(String + (String_cnt - Temp)) , LCD_digit_cnt ); // write the remaining charaters in the string
00224                     Temp++;   // increment the temporary string counter
00225                 }
00226             }
00227         }
00228         else    // when the whole string has been scrolled one time
00229         {
00230             String_cnt = 0;             // clear the global string counter
00231 
00232             if(NumberOfScroll != 0xFF)  // if not infinite scrolling is enabled
00233                 NumberOfScroll--;           // drecrease the number of times to scroll the string
00234         }
00235 }

Here is the call graph for this function:

void LCDsetupData void   ) 
 

Set up the text to be displayed (if any).

Definition at line 151 of file LCD_functions.c.

References Colon, FALSE, LCD_Menu1, LCD_Menu2, LCD_Menu3, NumberOfScroll, String, String_cnt, String_Table, and TRUE.

Referenced by Initialization().

00152 {
00153     if( !LCD_Menu1 )        // if LCD_Menu1 is not active
00154     {
00155         String_cnt = 0;           // set String_cnt to point a the first character
00156         String = "STK502 example application for ATmega169";
00157         NumberOfScroll = 0xFF;    // enable infnite scrolling
00158     }
00159     else if( !LCD_Menu2 )   // if LCD_Menu2 is not active
00160     {
00161         NumberOfScroll = 1;       // scroll the new text only once
00162         String = String_Table[LCD_Menu1-1]; // load the new text to be scrolled
00163         String_cnt = 0;           // set String_cnt to point a the first character
00164         Colon = TRUE;               // enable the colons
00165 
00166         if( LCD_Menu1 == 3 | LCD_Menu1 == 5 ) // if displaying the Set point or the offset
00167             Colon = FALSE;
00168     }
00169     else if( !LCD_Menu3 )   // if LCD_Menu3 is not active
00170     {
00171         Colon = TRUE;           // enable the colons
00172     }
00173     else                    // if LCD_Menu3 is active
00174     {
00175         Colon = FALSE;          // disable the colons
00176     }
00177 }

void LCDwriteData void   ) 
 

Writes date from the Transmit Buffer to the LCD_displayData.

Definition at line 106 of file LCD_functions.c.

References LCD_Menu1, and LCD_WriteDigit().

Referenced by LCD_update().

00107 {
00108     unsigned char LCD_digit_cnt = 8;  // counter to LCD Segments
00109 
00110     if( ( LCD_Menu1 > 2 ) && ( LCD_Menu1 < 6 ) )    // if Set Point, Temperature or Offset is to be displayed
00111     {                                               // set the "degree Celsius".
00112         LCD_WriteDigit( 'C' , 7 );                      // write ".C" to the last digits
00113         LCD_WriteDigit( '.' , 6 );
00114 
00115         LCD_digit_cnt = 6;                          // decrease the number of digits to write
00116     }
00117 
00118     while( LCD_digit_cnt > 2 )  // while there are number of digits left to wrtie
00119     {
00120         LCD_digit_cnt--;  // decrease the number of digits to write
00121 
00122         if( LCD_Menu1 > 3 )         // if displaying the temperature or offset
00123             LCD_status.blinkLCD = FALSE;    // turn off the possibility to blink
00124 
00125         if( LCD_status.blinkLCD && ( LCD_Menu1 == 3 ) && LCD_Menu2 )  // if the Set Point is displayed and Menu2 is active
00126         {
00127             LCD_WriteDigit( ' ', LCD_digit_cnt );             // blink all the digits when Menu2 and LCD_status.blinkLCd is active
00128         }
00129         else if( LCD_status.blinkLCD && ( BlinkTable[LCD_Menu2-1][LCD_digit_cnt - 2] ) && LCD_Menu2)   // if LCD_status.blinkLCd and Menu2 is active
00130         {
00131             LCD_WriteDigit( ' ', LCD_digit_cnt ); // blink the digit that is to be written according to BlinkTable[]
00132         }
00133         else
00134         {
00135             if( !(DataTable[LCD_Menu1-1][LCD_digit_cnt - 2]) )    // if the DataTable contains 0
00136             {
00137                 if(TCCR1A & 0x80)                               // check the TCCR1A register to find out if the Heater or Cooler pin is active
00138                     LCD_WriteDigit( '-' , LCD_digit_cnt );          // if the Heater pin is active, write '-'
00139                 else
00140                     LCD_WriteDigit( '+' , LCD_digit_cnt );          // if the Cooler pin is active, write '+'
00141             }
00142             else    // write data from the transmitbuffer
00143                 LCD_WriteDigit( TransmitBuffer[DataTable[LCD_Menu1-1][LCD_digit_cnt - 2]] , LCD_digit_cnt );
00144         }
00145     }
00146 }

Here is the call graph for this function:


Variable Documentation

__flash unsigned char BlinkTable[3][6]
 

Initial value:



                             {{ 1,      1,      0,      0,      0,      0   },
                              { 0,      0,      1,      1,      0,      0   },
                              { 0,      0,      0,      0,      1,      1   }}

Definition at line 50 of file LCD_functions.c.

unsigned char Clear_cnt
 

Definition at line 41 of file LCD_functions.c.

Referenced by LCDscrollMsg().

unsigned char Colon = FALSE
 

Definition at line 44 of file LCD_functions.c.

Referenced by LCD_update(), and LCDsetupData().

__flash unsigned char DataTable[5][6]
 

Initial value:




                             {{ 7,      8,      10,     11,     13,     14  },

                              { 16,     17,     19,     20,     25,     26  },

                              { 6,      6,      28,     29,     0,      0   },

                              { 31,     32,     34,     35,     0,      0   },

                              { 6,      0,      37,     38,     0,      0   }}

Definition at line 58 of file LCD_functions.c.

unsigned char LCD_displayData[]
 

Definition at line 32 of file LCD_driver.c.

Referenced by LCD_AllSegments(), LCD_SOF_interrupt(), and LCD_WriteDigit().

unsigned char LCD_Menu1
 

Definition at line 39 of file Buttons.c.

Referenced by CheckButtons(), Execute(), LCD_update(), LCDsetupData(), and LCDwriteData().

unsigned char LCD_Menu2
 

Definition at line 40 of file Buttons.c.

Referenced by CheckButtons(), Execute(), and LCDsetupData().

unsigned char LCD_Menu3
 

Definition at line 41 of file Buttons.c.

Referenced by CheckButtons(), and LCDsetupData().

unsigned char NumberOfScroll
 

Definition at line 43 of file LCD_functions.c.

Referenced by LCD_update(), and LCDsetupData().

unsigned char* String
 

Definition at line 42 of file LCD_functions.c.

Referenced by LCDscrollMsg(), and LCDsetupData().

unsigned char String_cnt
 

Definition at line 40 of file LCD_functions.c.

Referenced by LCDscrollMsg(), and LCDsetupData().

unsigned char* String_Table[6] = {"Clock", "Date", "Setpoint", "Temperature", "Offset", "Contrast"}
 

Definition at line 47 of file LCD_functions.c.

Referenced by LCDsetupData().

unsigned char TransmitBuffer[50]
 

Definition at line 32 of file UART.c.

Referenced by Send_TX_data(), and USART0_UDRE_interrupt().


Generated on Fri Feb 17 12:28:30 2006 for AVR064: A Temperature Monitoring System with LCD Output by  doxygen 1.4.5