Beispiel #1
0
void loop() {
  if (Serial.available() > 0) {
    readInHit();
    
    selectLineOne();
    Serial.print("Input: ");
    Serial.print(inBit);
    Serial.print("        ");
    
    selectLineTwo();
    Serial.print("Hit by: ");
    Serial.print( playerNameString() );
    delay(5000);
    clearLCD();    
    flushSerialIn();
  }
  
  if ((digitalRead(triggerPin) == HIGH) && (sendDelay > 200))
    sendMyInfo();
  
  selectLineOne();
  Serial.print("No Hit...       ");
  selectLineTwo();
  Serial.print("Gun:");
  if (sendDelay < 200)
    Serial.print(" Charging.. ");
  else
    Serial.print(" READY!     ");
  delay(10);
  
  if (sendDelay == 32760) // prevent int overflow.
    sendDelay = 32760;
  else 
    sendDelay++;
}
Beispiel #2
0
void sendMyInfo() 
{ // if we pull the trigger... IDENITIFY OURSELF!
  clearLCD();
  delay(50);
  selectLineOne();
  Serial.print("Sending my info!");
  delay(1000);
  clearLCD();
  sendDelay = 0;
}
Beispiel #3
0
void setup () {
 pinMode(triggerPin, INPUT);
 Serial.begin(9600); 
 flushSerialIn();
 delay(500);
 setBrightnessFull();
 
 populatePlayerTable();
 flushSerialIn();
 clearLCD();
 delay(1000);
 selectLineOne();
 Serial.print("Starting Game...");
 delay(1000);
 clearLCD();
 setBrightnessFull();
 flushSerialIn(); 
 selectLineOne();
 delay(1000);
 loop();
}
Beispiel #4
0
void populatePlayerTable() {
// This reads in via the IR-in link the data that is player names.
// Each player is assigned a position in a static array of MAX_PLAYERS
// size.
//
// Sending a "," (comma) indicated NEXT PLAYER
// Sending a "." (period) incates FINSIHED ENTERING.
  clearLCD();
  delay(1000);
  selectLineOne();
  Serial.print("Input Players:");
  delay(1000);
  
  char inChar = 0;
  inChar = 0;
  int namePos = 0; 
  int numPlayers =0;
  
    for (int playPos =0; playPos < MAX_PLAYERS; playPos++ ) 
    {
      char tempName[8] = "       ";
           
        while ( (inChar != ',') && (namePos < 7) )
        {
          if (Serial.available() > 0) {
              inChar = Serial.read();   
              if (inChar == '.')
               printPlayerNames(playPos);       
              selectLineTwo();
              Serial.print("read: ");
              Serial.print(inChar);
              
              tempName[namePos] = inChar;
              namePos++;
              
              Serial.print(" N:");
              Serial.print(namePos);
              Serial.print(" P:");
              Serial.print(playPos, HEX);  
          }          
        }
      if (namePos < 7)
        for (int ctr = namePos; ctr < 7; ctr++)
          tempName[ctr] = ' ';
          
      strcpy(playerNames[playPos], tempName);
      namePos = 0;
      numPlayers = playPos;
    }
    flushSerialIn();
    printPlayerNames(numPlayers);
}
Beispiel #5
0
void printPlayerNames(int playPos) {
  clearLCD();
  delay(500);
  
  selectLineOne();
  Serial.print("Read in:");
  
  for (int ctr = 0; ctr < playPos+1; ctr++) {
    selectLineTwo();
    Serial.print("P");
    Serial.print(ctr, HEX);
    Serial.print(": ");
    Serial.print(playerNames[ctr]);
    delay(1000);
  }
  flushSerialIn();
}
void setup()
{
  Serial.begin(9600);
  backlightOn();
  delay(100);
  clearLCD();
  selectLineOne();
  delay(100);
  //Serial.print("Hello, Dave"); //type in the first line of the splash here (16 char max)
  //selectLineTwo();
  //delay(100);
  //Serial.print("..."); //type the second line of the splash here (16 char max)
  //delay(500);
  Serial.print(0x7C, BYTE); //these lines...
  Serial.print(13, BYTE); //set the splash to memory (this is the <control> j char or line feed
  delay(100);
  clearLCD(); 
  Serial.print("Testing");
  
}
Beispiel #7
0
int main(void)
{
	//========= Peripheral Enable and Setup ===========//
	setup_LCD(); //LCD Screen setup
	setup_tmp36(); //TMP36 ADC thermometer setup


	setup_GPS(); //GPS Pin Setup
	setup_microSD(); //MicroSD Pin Setup
	setupTMP102();  
	setup_PID(&pid);
	setupBMS();
	setup_pwm();

	//Setup the buttons
	
	setup_buttonInterrupts();
	sleepEnablePeripherals();
	setup_timerInterrupt();

	
	//========= Peripheral enable and run ============//
	enable_LCD(); //Start LCD Commmunication
	enable_GPS(); //Start GPS Communication
	clearDisplay(); //Refresh Display



	while(1)
	{	
		//Listen for the GPS Data
		listen_GPS();
		//Open the datalog file for writing
		open_datalog();

		//Obtain vehicle speed
		char *velocity;
		char velocityArray[] = "000";
		
		//velocity = velocityArray;
		velocity = getVelocity();
		//Convert string to int
		int speedInteger = atoi(velocity);
		//Convert knots to mph

		
		speedInteger = 1.15 * speedInteger;
		//Return to string
		sprintf(velocity, "%i", speedInteger);
		// velocity = "50";
		selectLineOne();
		//Show velocity
		putPhrase("V:");
		putPhrase(velocity);

		//Analog Temperature Sensor
		int anag_tempValue = get_analog_temp();
		sprintf(anag_temp, "%i", anag_tempValue);

		//Digital Temperature Sensor
		int digi_tempValue = getTemperature();
		sprintf(digi_temp, "%i", digi_tempValue);

		//Get BMS Level
		char load[] = "89";
		char *load_value;
		load_value = load;
		//-------BMS Communication------
		sendStartSequence();
		getDataString();
		load_value = getLoad();
		//------------------------------

		

			
		//If Cruise Control is on
		if(enableSys)
		{	
			//If initialized
			if(obtain_speed)
			{	//Debouncing
				//SysCtlDelay(533333);
				obtain_speed = 0;
				clearDisplay();

				//Get set velocity
				set_velocity = 10;
			}

			//If driver increases set speed
			if(incr_speed)
			{	
				//SysCtlDelay(533333);

				incr_speed = 0;
				set_velocity += 1;
			}

			//if driver decresaes set speed
			else if(decr_speed)
			{	
				//SysCtlDelay(533333);
				decr_speed = 0;
				set_velocity -= 1;
			}

			//==============PID Portion of the Main Loop ==============//
			float process_value = atof(velocity); //Convert String to Int
			float error = set_velocity - process_value; //Calculate error
			float u_t = UpdatePID(&pid, error, 1.0); //Feed error to the PID
			
			uint32_t duty_cycle = u_t*scaleFactor;
			if(duty_cycle < 950){
				duty_cycle = 50;
			}
			else if(duty_cycle > 0){
				duty_cycle = 950;
			}
			pwm_out(1000, duty_cycle); //Scale and output the PID output

			//====================================================//

			//Show other essentials to the LCD
			putPhrase("mph/"); 

			char set_point[5];
			sprintf(set_point, "%imph", (int) set_velocity);
			putPhrase(set_point);
			putPhrase(" ON"); //Cruise control on

		}

		else
		{
			//Spacer
			putPhrase("mph ");
			putPhrase("Standby  ");

		}

		//Select bottom line
		selectLineTwo();

		//Display analog and digital temperatures
		putPhrase("T:");
		putPhrase(anag_temp);
		putPhrase("/");
		putPhrase(digi_temp);
		putPhrase("C  ");


		//Show Load level
		putPhrase("B:");
		putPhrase(load_value);
		putPhrase("%");

		
		write_datalog(velocity, "ddmm.mmmmmmX", "ddmm.mmmmmX", getTime(), anag_temp, digi_temp, load_value);
		close();

		//Put system in low power mode
		SysCtlSleep();	


}
}