Ejemplo n.º 1
0
/*--------------------------------------------------------------------------------------------------------------------
        Function:         Check_State_Change

        Description:      Check the MPB state, and see if user wants to change state

        Revisions:

--------------------------------------------------------------------------------------------------------------------*/
void Check_State_Change()
{
	if (MPB==0) /* Negative logic */
	{
		delay(25); //Calling a delay for 25ms
		if (MPB==0)
		{
			while (MPB==0);
			cmdLCD(CLR_DISP);
			gameState = (gameState+1)%2;	/* This will take the current state, add 1, and return the remainder. i.e. toggle between 1 and 0.*/
			//this won't work without the delay pls.
		}
	}
}
Ejemplo n.º 2
0
int main( void ) {
    initPMP();
    initLCD(7);
    initSerial2();

//    initSPI();
    cmdLCD(0b00000010); //return home??
    //writeLCD("hello");

    writeLCD("Begin");

//    int tempStepperCounts[5];
//    int heading_fp; // remember this is in fixed point from spi; 2,14
//    double heading;
//    int i=0;
    while(1) {
        if(newMSG) {
            cmdLCD(0b00000010); //return home??
            writeLCD("                ");
            cmdLCD(0b00000010); //return home??
            writeLCD(msg);
            txSerial("ASS!");
            newMSG = 0;
        }
//        writeLCD("FWD...");
//        writeSlave(MOTOR_DRIVER,SPI_MOTOR,(MOTOR_FWD SPI_MOTOR_RIGHT_DIR) |
//                                      (MOTOR_FULL_SPEED SPI_MOTOR_RIGHT_SPEED));
//        writeSlave(STEPPER_DRIVER,SPI_STEPPER_DIR,'F');
//        writeSlave(STEPPER_DRIVER,SPI_STEPPER_SPEED,30000);
//        writeSlave(STEPPER_DRIVER,SPI_STEPPER_STEPS,1500);
//        for(i=1;i<5000;i+=500)
//            writeSlave(STEPPER_DRIVER,SPI_STEPPER_SPEED,30000-i);

//        msDelay(1500);
//        writeSlave(MOTOR_DRIVER,SPI_MOTOR,(MOTOR_REV SPI_MOTOR_RIGHT_DIR) |
//                                            (MOTOR_STOP SPI_MOTOR_RIGHT_SPEED));
//        msDelay(1500);
//        writeLCD("REV...");
//        writeSlave(MOTOR_DRIVER,SPI_MOTOR,(MOTOR_REV SPI_MOTOR_RIGHT_DIR) |
//                                      (MOTOR_FULL_SPEED SPI_MOTOR_RIGHT_SPEED));
//        writeSlave(STEPPER_DRIVER,SPI_STEPPER_DIR,'R');
//        writeSlave(STEPPER_DRIVER,SPI_STEPPER_SPEED,25000);
//        writeSlave(STEPPER_DRIVER,SPI_STEPPER_STEPS,1000);
//        msDelay(500);
//        tempStepperCounts[0] = readSlave(STEPPER_DRIVER,SPI_STEPPER_INPROG);
//        tempStepperCounts[1] = readSlave(STEPPER_DRIVER,SPI_STEPPER_INPROG);
//        tempStepperCounts[2] = readSlave(STEPPER_DRIVER,SPI_STEPPER_INPROG);
//        msDelay(100);
//        tempStepperCounts[3] = readSlave(STEPPER_DRIVER,SPI_STEPPER_INPROG);
//        msDelay(100);
//        tempStepperCounts[4] = readSlave(STEPPER_DRIVER,SPI_STEPPER_INPROG);
//        msDelay(1500);
//        writeSlave(MOTOR_DRIVER,SPI_MOTOR,(MOTOR_REV SPI_MOTOR_RIGHT_DIR) |
//                                            (MOTOR_STOP SPI_MOTOR_RIGHT_SPEED));
//        msDelay(1500);
////        heading_fp = readSlave(COMPASS,COMPASS_HEADING);
////        heading = ((double) heading_fp) / FIXEDPOINT_13BIT;
//        cmdLCD(0b00000010); //return home??
//        writeLCD("               ");
//        cmdLCD(0b00000010); //return home??
    };
    return (EXIT_SUCCESS);
}