lcd on microcontroller program

Embed Size (px)

Citation preview

  • 7/29/2019 lcd on microcontroller program

    1/6

    /******************************************************************************

    eXtreme Electronics xAPI(TM)

    xAPI is a Powerful but easy to use C library to program the xBoard(TM)series of AVR development board. The library has support for commonly use taskslike:

    *LCD interfacing*MUXED 7 segment displays.*Remote Control*Serial Communication*DC Motor Controls with Speed Control*Analog Measurement for Sensor Interface.*Temperature Measurement.*I2C Communication.*EEPROM Interface*Real Time Clock (RTC Interface)

    The APIs are highly documented and easy to use even by a beginner.

    For More Info Log On towww.eXtremeElectronics.co.in

    Copyright 20082010 eXtreme Electronics India

    LCD Core

    This module is used for interfacing with Standard Alpha Numeric LCD Modules.For More information please see supplied tutorials and videos.

    NOTICE

    NO PART OF THIS WORK CAN BE COPIED, DISTRIBUTED OR PUBLISHED WITHOUT A

    WRITTEN PERMISSION FROM EXTREME ELECTRONICS INDIA. THE LIBRARY, NOR ANY PARTOF IT CAN BE USED IN COMMERCIAL APPLICATIONS. IT IS INTENDED TO BE USED FORHOBBY, LEARNING AND EDUCATIONAL PURPOSE ONLY. IF YOU WANT TO USE THEM INCOMMERCIAL APPLICATION PLEASE WRITE TO THE AUTHOR.

    WRITTEN BY:AVINASH [email protected]

    *******************************************************************************/

    #include

    #include #include

    #include "lcd.h"

    //Custom Charset support#include "custom_char.h"

    #define LCD_DATA_PORT PORT(LCD_DATA)#define LCD_E_PORT PORT(LCD_E)#define LCD_RS_PORT PORT(LCD_RS)#define LCD_RW_PORT PORT(LCD_RW)

    #define LCD_DATA_DDR DDR(LCD_DATA)#define LCD_E_DDR DDR(LCD_E)#define LCD_RS_DDR DDR(LCD_RS)#define LCD_RW_DDR DDR(LCD_RW)

  • 7/29/2019 lcd on microcontroller program

    2/6

    #define LCD_DATA_PIN PIN(LCD_DATA)

    #define SET_E() (LCD_E_PORT|=(1

  • 7/29/2019 lcd on microcontroller program

    3/6

    //SEND

    CLEAR_E();

    _delay_us(1); //tEL

    LCDBusyLoop();}

    void LCDBusyLoop(){

    //This function waits till lcd is BUSY

    uint8_t busy,status=0x00,temp;

    //Change Port to input type because we are reading dataLCD_DATA_DDR&=(~(0x0fLCD_DATA_POS);status=statusLCD_DATA_POS);temp&=0x0F;

    status=status|temp;

    busy=status & 0b10000000;

    _delay_us(0.5);CLEAR_E();_delay_us(1); //tEL

    }while(busy);

    CLEAR_RW(); //write mode//Change Port to outputLCD_DATA_DDR|=(0x0F

  • 7/29/2019 lcd on microcontroller program

    4/6

    void LCDInit(uint8_t style){

    /*****************************************************************

    This function Initializes the lcd modulemust be called before calling lcd related functions

    Arguments:style = LS_BLINK,LS_ULINE(can be "OR"ed for combination)LS_BLINK :The cursor is blinking typeLS_ULINE :Cursor is "underline" type else "block" type

    *****************************************************************/

    //After power on Wait for LCD to Initialize_delay_ms(30);

    //Set IO PortsLCD_DATA_DDR|=(0x0F

  • 7/29/2019 lcd on microcontroller program

    5/6

    Their are 8 custom char in the LCD they can be defined using"LCD Custom Character Builder" PC Software.

    You can print custom character using the % symbol. For exampleto print custom char number 0 (which is a degree symbol), youneed to write

    LCDWriteString("Temp is 30%0C");^^

    |> %0 will

    So it will be printed like.

    Temp is 30C

    In the same way you can insert any syblom numbered 07

    *****************************************************************/while(*msg!=\0)

    {//Custom Char Supportif(*msg==%){

    msg++;int8_t cc=*msg0;

    if(cc>=0 && cc

  • 7/29/2019 lcd on microcontroller program

    6/6

    i;}if(field_length==1)

    while(str[j]==0) j++;else

    j=5field_length;

    if(val