Microchip Technology DM164130-2 Manuale Utente
Hardware Libraries and Drivers
2010 Microchip Technology Inc.
DS41401B-page 25
5.7.2
LCD Function Interface
5.7.2.1
lcd_init
This function configures the LCD peripheral for this board and this glass. Type B
waveforms are used to allow the LCD peripheral to be used for the real-time clock
function. The Timer1 oscillator is configured as the LCD clock source.
waveforms are used to allow the LCD peripheral to be used for the real-time clock
function. The Timer1 oscillator is configured as the LCD clock source.
FIGURE 5-7:
5.7.2.2
lcd_display_digits
This function accepts a BCD_TYPE variable and maps each digit to the correct
segments. Mapping the segments is done in two stages. First, the digit is converted to
the correct 7-segment mapping. Then, the 7-segment mapping is converted to the
actual glass segments with a long series of “if-else” statements. This function will need
extensive work in the “if-else” statements for applications driving different glass.
segments. Mapping the segments is done in two stages. First, the digit is converted to
the correct 7-segment mapping. Then, the 7-segment mapping is converted to the
actual glass segments with a long series of “if-else” statements. This function will need
extensive work in the “if-else” statements for applications driving different glass.
FIGURE 5-8:
5.7.2.3
lcd_display_on / lcd_display_off
These two functions simply turn the LCD peripheral off. The Timer1 oscillator is left
running. One use for these functions is to implement display blinking.
running. One use for these functions is to implement display blinking.
FIGURE 5-9:
System_initialize()
{
lcd_init();
}
void display_int(int t)
{
BCD_TYPE bcd;
bcd.digit0 = t %10;
t /= 10;
bcd.digit1 = t % 10;
t /= 10;
bcd.digit2 = t % 10;
t /= 10;
bcd.digit3 = t%10;
lcd_display_digits(bcd);
}
void update_blinking()
{
if(time(0) % 2) // if an odd number of seconds
{
lcd_display_on();
}
else
{
lcd_display_off();
}
}