コード例 #1
0
void putsLCD (char *ptr)
{
     while (*ptr) {
           putcLCD(*ptr);
           delayby50us(1);
           ptr++;
     }
}
コード例 #2
0
ファイル: Project3.c プロジェクト: mbhatt1/Code-Examples
void putsLCD (char *ptr) {     //display a string of characters to LCD
    while (*ptr) {               //checks for end of string (null character)
        putcLCD(*ptr);               //send each individual char to putcLCD
        ptr++;                       //go to next char
    }
}
コード例 #3
0
ファイル: Project3.c プロジェクト: mbhatt1/Code-Examples
void main(void) {


    unsigned int i,b;
    unsigned long int n, q, k[3];
    char j=0;


    char *msg1,*msg2,*msg3,*msg4;   //messages to display

    msg1 = "Enter decimal:";
    msg2 = "Hex conversion:";
    msg3 = "Not valid input";
    msg4 = "Max range 65535";

start:

    n = 0;                          //initialize to 0
    q = 5;                          //initialize to not 0

    openLCD();                      //turn LCD on
    cmd2LCD(0x01);                  //clear LCD
    delayms(10);                    //wait of LCD to clear
    putsLCD(msg1);                  //display first message
    cmd2LCD(0xC0);                  //go to second line


    while (1)
    {

keyin:
        i= getkey1();               //get key from keypad
        delayms(10);                //wait to ensure debounce

        if(i == 0x0A) {             //if i=A (enter key)
            goto dec2hex;             //convert decimal to hex
        }
        else if (i > 0x0A) {        //if i not a valid input

            cmd2LCD(0x01);            //clear LCD
            delayms(10);              //wait for LCD to be cleared
            putsLCD(msg3);            //display third message
            exit();                   //exit program
        }

        if((n*10+i) > 0xFFFF) {    //if n exceeds limit
            cmd2LCD(0x01);            //clear LCD
            delayms(10);              //wait for LCD to be cleared
            putsLCD(msg4);            //display message 4
            exit();
        }

        j= (char)i;                //turn i into char
        j=j+0x30;                  //convert hex to ASCII
        putcLCD(j);                //display ASCII to LCD


        n = n*10 +i;               //keep track of decimal value
        delayms(5);
        goto keyin;                //get another key


dec2hex:

        cmd2LCD(0x01);              //clear LCD
        delayms(10);                //wait for LCD to clear
        putsLCD(msg2);              //display message 2
        cmd2LCD(0xC0);              //go to second line

        b = 0;                      //set b to 0
        while(q != 0) {             //while quotient is not 0
            q = n/16;               //quotient is equal to number/16
            k[b] = n%16;            //store remainder in array
            n /= 16;                //new number value
            b ++;
        }

        while(b !=0) {             //display array values to LCD
            b --;                     //decrease b
            if(k[b] < 10) {           //if number add 0x30 for ASCII
                k[b] = k[b] + 0x30;
            } else {                  //if letter add 0x37 for ASCII
                k[b] = k[b] + 0x37;
            }
            putcLCD((char)k[b]);      //display ASCII to LCD
        }
        exit();


    }
}