Пример #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++;
}
Пример #2
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);
}
Пример #3
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();
}
Пример #4
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();	


}
}
Пример #5
0
void Lamp::drawMenu(unsigned long index)
{

  //Serial.println("Draw");

  unsigned char almhr;
  almhr= getAlarmHour();
  unsigned char almmn;
  almmn = getAlarmMin();
  bool almAM;
  almAM = getAlarmAM();
  bool almOn;
  almOn = getAlarmOn();
  byte dspMode = getDisplayMode();
  byte lmpbr = getLampBrightness();
  byte lcdbr = getLCDBrightness();
 // byte lcdsl = getLCDSleepTime();
//  byte audfs = getAudioFadeSpeed();
  byte cych  = getCycleHoldTime();
  byte cycf  = getCycleFadeTime();
  byte cycs  = getCycleSteps();
  byte rndh  = getRandomHoldTime();
  byte rndf  = getRandomFadeTime();
  byte solh  = getColorHue();
  byte sols  = getColorSat();

  char strSec[5] = "sec.";
  char strON[3] = "ON";
  char strOFF[4] = "OFF";
  char strAM[5] = "  AM";
  char strPM[5] = "  PM";
  char strPad0[2] = "0";
  char strBr[11] = "Brightness";
  char strHT[11] = "Hold Time";
  char strFT[11] = "Fade Time";
  char strST[7] = "Steps";
  char strTimeH[15] = "Hour Min AM/PM";
  char strDateH[14] = "d.  D. M.  Y.";
  char strBL[10] = "Backlight";

  char* weekdayStr[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat","ERR"};  
  char* monthStr[] = {"","Jan", "Feb", "Mar","Apr","May","Jun", "Jul","Aug", "Sep","Oct","Nov","Dec","ERR"};

  goTo(0);
  hideCursor();
  clearLCD();
  //  selectLineOne();

  switch (index)
  {
  case 0x000000:
    //Main menu
    //  Serial1.println("03:28 PM    Alm.");
    //  Serial1.println("Mon Nov 10 2012 ");
    if (tHour12 < 10) Serial1.print(strPad0);
    Serial1.print(tHour12);
    Serial1.print(":");
    if (tMinute < 10) Serial1.print(strPad0);
    Serial1.print(tMinute);


    if(tHour<12) Serial1.print(strAM);
    if(tHour>=12)Serial1.print(strPM);
    if(almOn) Serial1.print("   Alm.");
    if(!almOn) Serial1.print("");
    selectLineTwo();
    Serial1.print(weekdayStr[tDay]);
    Serial1.print(" ");
    Serial1.print(monthStr[tMonth]);
    Serial1.print(" ");
    Serial1.print(tDate);
    Serial1.print("  ");
    Serial1.print(tYear +2000);

    break;
  case 0x000001:
    //Clock Settings
    Serial1.print("Clock Settings");
    //  Serial1.println("");
    break;
  case 0x000002:
    //Lamp Settings
    Serial1.print("Lamp Settings");
    //  selectLineTwo();
    //  Serial1.println("");
    break;
  case 0x000011:
    //set Date/time top menu
    Serial1.print("Set Date/Time");
    selectLineTwo();
    if (tHour12 < 10) Serial1.print(strPad0);
    Serial1.print(tHour12);
    Serial1.print(":");
    if(tMinute < 10) Serial1.print(strPad0);
    Serial1.print(tMinute);
    if(tHour<12) Serial1.print("AM ");
    if(tHour>=12) Serial1.print("PM ");
    Serial1.print(tDate);
    Serial1.print("/");
    Serial1.print(tMonth);
    Serial1.print("/");
    Serial1.print(tYear);

    break;
  case 0x000012:
    //Set Display mode top menu
    Serial1.print("Dispay Mode");
    selectLineTwo();
    if (dspMode==0) Serial1.print("Audio Viz.");
    if (dspMode==1) Serial1.print("Cycle");
    if (dspMode==2) Serial1.print("Random");
    if (dspMode==3) Serial1.print("Solid");

    break;
  case 0x000021:
    //set Alarm top menu
    Serial1.print("Set Alarm");
    selectLineTwo();
    //Serial1.print("07:00AM      OFF");
    if (almhr < 10) Serial1.print(strPad0);
    Serial1.print(almhr);
    Serial1.print(":");
    if(almmn < 10) Serial1.print(strPad0);
    Serial1.print(almmn);
    if(almAM) Serial1.print(strAM);
    if(!almAM)Serial1.print(strPM);
    if(almOn) { 
      Serial1.print("     "); 
      Serial1.print(strON);
    }
    if(!almOn) {
      Serial1.print("    "); 
      Serial1.print(strOFF);
    }

    break;
  case 0x000022:
    //Set Brightness top menu
    Serial1.print(strBr);
    selectLineTwo();
    Serial1.print(lmpbr,DEC);
    break; 
  case 0x000032:
    //set LCD Backlight top menu
    Serial1.print(strBL);
    selectLineTwo();
    Serial1.print(lcdbr,DEC);
    break;

  case 0x000111:
    //set clock time / current time
    Serial1.print(strTimeH);
    selectLineTwo();
    if (tHour12 < 10) Serial1.print(strPad0);
    Serial1.print(tHour12);
    Serial1.print("   ");
    if(tMinute < 10) Serial1.print(strPad0);
    Serial1.print(tMinute);
    if(tHour<12) Serial1.print(strAM);
    if(tHour>=12) Serial1.print(strPM);

    break;

  case 0x000121:
    //set alarm time / current time
    Serial1.print(strTimeH);
    selectLineTwo();
    if (almhr < 10) Serial1.print(strPad0);
    Serial1.print(almhr);
    Serial1.print("   ");
    if(almmn < 10) Serial1.print(strPad0);
    Serial1.print(almmn);
    if(almAM) Serial1.print(strAM);
    if(!almAM) Serial1.print(strPM);

    break;
  case 0x000122:
    //Set lamp Brigthness
    //should display cursor
    Serial1.print(strBr);
    selectLineTwo();
    Serial1.print(lmpbr,DEC);

    showCursor();
    goTo(18);

    break;
  case 0x000132:
    //set lcd backlight brightness
    //should display cursor
    Serial1.print(strBL);
    selectLineTwo();
    Serial1.print(lcdbr,DEC);
    //
    showCursor();
    goTo(17);

    break;

  case 0x000211:
    //set clock date menu
    Serial1.print(strDateH);
    selectLineTwo();
    Serial1.print(weekdayStr[tDay]);
    Serial1.print(" ");
    Serial1.print(tDate); 
    Serial1.print(" ");

    Serial1.print(monthStr[tMonth]);
    Serial1.print(" ");
    Serial1.print(tYear);
    break;
  case 0x000212:
    //Cycle display mode
    Serial1.print("Cycle");

    break;
  case 0x000221:
    //set alarm on/off menu
    Serial1.print("Alarm");
    selectLineTwo();
    if (almOn) Serial1.print(strON);
    if (!almOn) Serial1.print(strOFF);
    break;
  case 0x000312:
    //random color display mode
    Serial1.print("Random");
    //  Serial1.print("");
    break;
  case 0x000412:
    //solid color display mode
    Serial1.print("Solid");
    // Serial1.print("");
    break;
  case 0x001111:
    //set clock time / set hour
    //show cursor at hour
    Serial1.print(strTimeH);
    selectLineTwo();
    if (tHour12 < 10) Serial1.print(strPad0);
    Serial1.print(tHour12);
    Serial1.print("   ");
    if(tMinute < 10) Serial1.print(strPad0);
    Serial1.print(tMinute);
    if(tHour<12) Serial1.print(strAM);
    if(tHour>=12) Serial1.print(strPM);

    showCursor();
    goTo(17);

    break;

  case 0x001121:
    //set alarm time / hour
    //show cursor at hour
    Serial1.print(strTimeH);
    selectLineTwo();
    if (almhr < 10) Serial1.print(strPad0);
    Serial1.print(almhr);
    Serial1.print("   ");
    if(almmn < 10) Serial1.print(strPad0);
    Serial1.print(almmn);
    if(almAM) Serial1.print(strAM);
    if(!almAM) Serial1.print(strPM);

    showCursor();
    goTo(17);

    break;
  case 0x001211:
    //set clock date / day of week
    //show cursor at d o w

    Serial1.print(strDateH);
    selectLineTwo();
    //Serial1.print("Mon 3_ Dec 12");
    Serial1.print(weekdayStr[tDay]);
    Serial1.print(" ");
    Serial1.print(tDate);
    Serial1.print(" ");
    Serial1.print(monthStr[tMonth]);
    Serial1.print(" ");
    Serial1.print(tYear);

    showCursor();
    goTo(18);

    break;
  case 0x001212:
    //set Cycle hold time
    //show cursor
    Serial1.print(strHT);
    selectLineTwo();
    Serial1.print(cych,DEC);
    Serial1.print(strSec);

    showCursor();
    goTo(17);

    break;
  case 0x001221:
    //set alarm on / off
    //show cursor
    Serial1.print("Alarm");
    selectLineTwo();
    if (almOn) Serial1.print(strON);
    if (!almOn) Serial1.print(strOFF);

    showCursor();
    goTo(18);

    break;
  case 0x001312:
    //set random mode holde time
    //show cursor
    Serial1.print(strHT);
    selectLineTwo();
    Serial1.print(rndh,DEC);
    Serial1.print(strSec);

    showCursor();
    goTo(17);

    break;
  case 0x001412:
    //set solid mode Hue
    //show cursor
    Serial1.print("Hue");
    selectLineTwo();
    Serial1.print(solh,DEC);

    showCursor();
    goTo(19);

    break;
  case 0x002111:
    //set clock time / min
    //show curso at min
    Serial1.print(strTimeH);
    selectLineTwo();
    if (tHour12 < 10) Serial1.print(strPad0);
    Serial1.print(tHour12);
    Serial1.print("   ");
    if(tMinute < 10) Serial1.print(strPad0);
    Serial1.print(tMinute);
    if(tHour<12) Serial1.print(strAM);
    if(tHour>=12) Serial1.print(strPM);

    showCursor();
    goTo(22);

    break;
  case 0x002121:
    //set alarm time / min
    //show cursor at min
    Serial1.print(strTimeH);
    selectLineTwo();
    if (almhr < 10) Serial1.print(strPad0);
    Serial1.print(almhr);
    Serial1.print("   ");
    if(almmn < 10) Serial1.print(strPad0);
    Serial1.print(almmn);
    if(almAM) Serial1.print(strAM);
    if(!almAM)Serial1.print(strPM);

    showCursor();
    goTo(22);

    break;
  case 0x002211:
    //set clock date / day
    //show cursor at day
    Serial1.print(strDateH);
    //Serial1.print("Mon 3_ Dec 12");
    selectLineTwo();
    Serial1.print(weekdayStr[tDay]);
    Serial1.print(" ");
    Serial1.print(tDate);
    Serial1.print(" ");
    Serial1.print(monthStr[tMonth]);
    Serial1.print(" ");
    Serial1.print(tYear);

    showCursor();
    goTo(21);

    break;
  case 0x002212:
    //set cycle mode fade time
    //show cursor
    Serial1.print(strFT);
    selectLineTwo();
    Serial1.print(cycf,DEC);
    Serial1.print(strSec);
    showCursor();
    goTo(17);
    break;
  case 0x003212:
    //set cycle mode steps
    //show cursor
    Serial1.print(strST);
    selectLineTwo();
    Serial1.print(cycs,DEC);
    showCursor();
    goTo(18);
    break; 
  case 0x002312:
    //set randome mode fade time
    //show cursor
    Serial1.print(strFT);
    selectLineTwo();
    Serial1.print(rndf,DEC);
    Serial1.print(strSec);
    showCursor();
    goTo(17);
    break;
  case 0x002412:
    //set solid mode color sat
    //show cursor
    Serial1.print("Saturation");
    selectLineTwo();
    Serial1.print(sols,DEC);
    showCursor();
    goTo(18);
    break;
  case 0x003111:
    //set clock time am/pm
    //show cursor
    Serial1.print(strTimeH);
    selectLineTwo();
    if (tHour12 < 10) Serial1.print(strPad0);
    Serial1.print(tHour12);
    Serial1.print("   ");
    if(tMinute < 10) Serial1.print(strPad0);
    Serial1.print(tMinute);
    if(tHour<12) Serial1.print(strAM);
    if(tHour>=12) Serial1.print(strPM);

    showCursor();
    goTo(26);

    break;
  case 0x003121:
    //set alarm am/pm
    //show cursor at AM
    Serial1.print(strTimeH);
    selectLineTwo();
    if (almhr < 10) Serial1.print(strPad0);
    Serial1.print(almhr);
    Serial1.print("   ");
    if(almmn < 10) Serial1.print(strPad0);
    Serial1.print(almmn);
    if(almAM) Serial1.print(strAM);
    if(!almAM)Serial1.print(strPM);

    showCursor();
    goTo(26);

    break;
  case 0x003211:
    //set clock date / month
    //show cursor at month
    Serial1.print(strDateH);
    selectLineTwo();
    Serial1.print(weekdayStr[tDay]);
    Serial1.print(" ");
    Serial1.print(tDate);
    Serial1.print(" ");
    Serial1.print(monthStr[tMonth]);
    Serial1.print(" ");
    Serial1.print(tYear);
    showCursor();
    goTo(25);
    break;
  case 0x004211:
    //set clock date / year
    //show cursor at year
    Serial1.print(strDateH);
    selectLineTwo();
    Serial1.print(weekdayStr[tDay]);
    Serial1.print(" ");
    Serial1.print(tDate);
    Serial1.print(" ");
    Serial1.print(monthStr[tMonth]);
    Serial1.print(" ");
    Serial1.print(tYear);

    showCursor();
    goTo(28);

    break;
  default:
    break;
  }

  //  backLightBr(getLCDBrightness());

}