Final Project/FinalProject.X/FinalProjectMain.c
// <editor-fold defaultstate="collapsed" desc="pollRPG()">
/******************************************************************************
 * pollRPG function
 *
 * Polls the status of the RPG and compares it to the previous value.  Count
 * increases or decreases according to the direction the RPG is turned.
 ******************************************************************************/

pollRPG function

Polls the status of the RPG and compares it to the previous value.  Count
increases or decreases according to the direction the RPG is turned.
pollRPG function Polls the status of the RPG and compares it to the previous value . Count increases or decreases according to the direction the RPG is turned .
void pollRPG() {
    rpgDir = 0;
    rpgTemp = (PORTD ^ oldPortD) & 0x03;
    if(rpgTemp == 0)
        return;
    switch(oldPortD)
    {
        case 0:
            oldPortD = 2;
            break;
        case 2:
            oldPortD = 3;
            break;
        case 3:
            oldPortD = 1;
            break;
        case 1:
            oldPortD = 0;
            break;
    }
    rpgTemp = oldPortD ^ rpgTemp;
    if(rpgTemp == 0)
    {
        rpgDir = -1;
        readyToSend = 1;
    }
    else
    {
        rpgDir = 1;
        readyToSend = 1;
    }
    oldPortD = PORTD & 0b00000011;
}
void pollRPG ( ) { rpgDir = 0 ; rpgTemp = ( PORTD ^ oldPortD ) & 0x03 ; if ( rpgTemp == 0 ) return ; switch ( oldPortD ) { case 0 : oldPortD = 2 ; break ; case 2 : oldPortD = 3 ; break ; case 3 : oldPortD = 1 ; break ; case 1 : oldPortD = 0 ; break ; } rpgTemp = oldPortD ^ rpgTemp ; if ( rpgTemp == 0 ) { rpgDir = -1 ; readyToSend = 1 ; } else { rpgDir = 1 ; readyToSend = 1 ; } oldPortD = PORTD & 0b00000011 ; }
<editor-fold defaultstate="collapsed" desc="pollRPG()">
 pollRPG function
<editor - fold defaultstate = " collapsed " desc = " pollRPG () " > pollRPG function