void init_eeprom(struct Menu *menu){
  eeprom_profile_size = eeprom_calc_size(menu);
  if(EEPROM.read(0) == 255||
     EEPROM.read(0) == 0){
    //clean eeprom 
    eeprom_clear();
    EEPROM.write(0, eeprom_current_profile_num );
    for(unsigned int i = 0; i < eeprom_num_profiles; i++){
      eeprom_save_profile(menu,i); //save the defaults
    }    
  }
  eeprom_current_profile_num = EEPROM.read(0);
  eeprom_load_profile(menu,eeprom_current_profile_num);
}
Beispiel #2
0
void import_waypoints(){
	eeprom_clear();
	
	wpw_count = 1;	//resets the counter to import correctly
	WAYPOINTS_STRING	//edit this in header file to change waypoints
	
	for(int i=0; i < WAYPOINT_COUNT; i++){
		waypoint.x = float(excel_waypoints[i][0]);
		waypoint.y = float(excel_waypoints[i][1]);
		EEPROM_writeAnything(wpw_count*WP_SIZE, waypoint);
		wpw_count++;
	}
	
	wpw_count = 1;	//resets the couter for autonomous mode
	display_waypoints();
	SERIAL_OUT.println("ALL POINTS IMPORTED");
	SERIAL_OUT.println();

	return ;
}
Beispiel #3
0
void reset_waypoints(){
/* NOTE THAT WHEN USING THIS FUNCTION, THERE MUST BE AT LEAST 1 WAYPOINT THAT IS NOT 0,0 OR ELSE THE CAR WILL NOT SET WAYPOINTS CORRECTLY AFTER THAT*/

	eeprom_clear();
	
	wpw_count = 1;	//resets the counter to import correctly
	int excel_waypoints[19][2] = {{0,1000}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}};

	for(int i=0; i < WAYPOINT_COUNT; i++){
		waypoint.x = float(excel_waypoints[i][0]);
		waypoint.y = float(excel_waypoints[i][1]);
		EEPROM_writeAnything(wpw_count*WP_SIZE, waypoint);
		wpw_count++;
	}
	
	wpw_count = 1;	//resets the couter for autonomous mode
	display_waypoints();
	SERIAL_OUT.println("ALL POINTS IMPORTED");
	SERIAL_OUT.println();
	
	return;
}
Beispiel #4
0
//MAIN function
void main (void)
{
	/*Variable Declaration*/
	char pass[PASS_LENGTH], x; 	//pass is the pass entered. 'x' stores temp data
	int loop; 					//variable for loops
	char attempts, entered;		//amount of passcode attempts. amount of data entered (when entering passcode)
	
	/*Setup*/
	{
	DisplayInit();
	settim0 ();
	init_scan();
	init_door();
		/*This section may cause issues on DEV board as it's not configured to hold P1.4 low during normal operation*/
		P1M1|=0x10;
		P1M2&=0xEF; //sets P1.4 to '10'(input mode)
		if((P1&0x10)==0x10) //if P1.4 is held high (Hardware override to wipe eeprom)
		{
			eeprom_clear(0);
			Write("done");
			while(1); //infinite loop, Hardware must be reset again.
		}
		//*************************************************************************************************************/
		
	for(loop=0;loop<PASS_LENGTH;++loop)
	{
		pass[loop]=PASS_NULL; //sets the passcode to PASS_NULL
	}
	entered=0;
	attempts=0;
	Write("init");
	//Should I shut the door here? Spec doesn't Spec and I would assume so.
	}
	
	
	//infinite loop begins
	while(1)
	{
		/*--idling state.--*/
		
		x=passcode_entering(pass,30);	//store data to pass, 30seconds till idle
		
		if(x==KEY_ENTER)	//enter has been pressed.
		{
			while(scan()==1)
			key_flag=0;
			//code check portion
			if (code_check(pass)==1)
			{
				
				//passcode is correct
				//enter open routine
				door_routine();
				//should include passcode change section.
				
				
				//clear passcode, ready for idling
				for(loop=0;loop<PASS_LENGTH;++loop)
				{
					pass[loop]=PASS_NULL; 			//clears stored passcode
				}
				entered=0;
				attempts=0;
				Write("shut");
			}
			else 
			{
				//passcode incorrect
				++attempts;
				if(attempts>=3) //third fail will lock door down
				{
					Write("Bar ");
					
					for(clock=0;clock<(120*clock_freq);) 
						{/*enter three minute loop*/}
					
					attempts=0;	//reset attempts to 0
				}
				for(loop=0;loop<PASS_LENGTH;++loop)
				{
					pass[loop]=PASS_NULL; //clears stored passcode
				}
				Write("shut");
			}
		}//end of 'if(x==KEY_ENTER)'
		
		//clears stored passcode
		for(loop=0;loop<PASS_LENGTH;++loop)
		{
			pass[loop]=PASS_NULL; 
		}
		Write("shut");
		
		if(x==0) //display
			{
				attempts=0; //clears attempts if passcode entering times out
			}
		
	}
	//end of while(1) loop

	/*Error catching Area*/
	Write("Err1");
	while(1);
	/*********************/
}