Пример #1
0
/**
 * Sensor calls RFID_done as a response to read_rfid to take action
 *
 * @param id_and_station The station robot has stopped on and which side it is on
 */
void RFID_done(uint8_t id, uint16_t id_and_station)
{
    uint8_t station_id = (uint8_t)(id_and_station);
    uint8_t station_data = (uint8_t)(id_and_station >> 8);
    if (station_id != 0) // rfid found!
    {
        stop_wheels();
        display_station_and_rfid(station_data, station_id);
        rfid_to_pc(station_id);
        update_station_list(station_id);
        command_to_arm(station_data, station_id);
    }
    else if (station_id == 0 && scan_count < 18) // No id found, drive forward
    {
        drive_left_wheels(1, 130);
        drive_right_wheels(1, 130);
        ++scan_count;
        _delay_ms(5);
        read_rfid();
    }
    else if (station_id == 0 && scan_count < 35) // Still no id found, start backing
    {
        drive_left_wheels(0, 130);
        drive_right_wheels(0, 130);
        ++scan_count;
        _delay_ms(5);
        read_rfid();
    }
    else
    {
        stop_wheels();
        decision_to_pc(6);
        display(0, "No tag ");
        display(1, "found!");
        //scan_count = 0;
        if (lap_finished == 0)
            clear_station_list();
        drive_to_next();
    }
}
Пример #2
0
void wait_for_null_rfid_scan(){
	RFID_Tag tag = RFID_Tag();
	while(!tag.is_null())
		tag = read_rfid();
}
Пример #3
0
RFID_Tag scan_rfid(){
	RFID_Tag tag;
	while(tag.is_null())
		tag = read_rfid();
	return tag;
}
Пример #4
0
bool nothing_to_scan(){
	RFID_Tag tag = read_rfid();
	return tag.is_null();
}