Tuesday 7 June 2011

LCD Tutorial 6


Tutorial 6 - Marquee part 1      

Another function prototype such as command_shift has specifically added in this tutorial. This prototype function is designed to shift the character either left or right. According to the command set table, the fifth row indicates that 0x18 and 0x17 would be used for shifting left and right respectively.

In the character mode prototype function has been slightly modified as the global variable such as size_G is used to count the maximum character in text. Then the size_G add with the local variable such n=16 because of the number characters in the LCD module. 

Basically the code below just shift the text across the LCD module from right to left. In the 'do' section includes the delay_loop which allow the text stay on the LCD module for few seconds then shift again. When the text disappear from the screen, the 0x01 is executed in order to clear the display screen and repeat the above process again. 

// Global Variable
int size_G;

void main(void)
{
        int n;

       
// Configure LCD module into 2 lines, 8-Bits and 5x7 Pixels
        function_set();

        // Blinking and underline cursor

        display_cursor(0x08);

        while(1)
        {
        // Place character on $00
        display_address(0x80);
        // Enter characters
        character_mode("TEST");
        // Determine the max length of characters
        n=16+size_G;

        // Blinking and underline cursor

        display_cursor(0x0c);

        do
        {
        Delay_Loop(20);
        // Shifting text from right to left
        command_shift(0x18);
        n--;
        }       while(n !=0x00);

        // Clear display
        DATA=0x01;
        pulse_e();
        } 
}

No comments:

Post a Comment