Beispiel #1
0
/** displayWelcome ******************************************
 * Output welcome message, play tune and delay 2s.
 * @modifies - lcd displays welcome message, tune is played
 */
void displayWelcome() {
	clear();
	print_from_program_space(welcome_line1);
	lcd_goto_xy(0,1);
	print_from_program_space(welcome_line2);
	play_from_program_space(welcome);
	delay_ms(2000);
}
Beispiel #2
0
void print_two_lines_delay_1s(const char *line1, const char *line2)
{
	clear();
	print_from_program_space(line1);
	lcd_goto_xy(0,1);
	print_from_program_space(line2);
	delay_ms(1000);
}
Beispiel #3
0
void print_two_lines_delay_1s(const char *line1, const char *line2)
{
    // Play welcome music and display a message
    clear();
    print_from_program_space(line1);
    lcd_goto_xy(0,1);
    print_from_program_space(line2);
    delay_ms(1000);
}
Beispiel #4
0
// Displays a welcome message and plays the initial music.
void initialize()
{
	load_custom_characters(); // load the custom characters
	
	play_from_program_space(welcome);
	print_two_lines_delay_1s(welcome_line1,welcome_line2);
	print_two_lines_delay_1s(demo_name_line1,demo_name_line2);
	print_two_lines_delay_1s(instructions_line1,instructions_line2);

	clear();
	print_from_program_space(instructions_line3);
	lcd_goto_xy(0,1);
	print_from_program_space(instructions_line4);

	while(!(wait_for_button_and_beep() & BUTTON_B));

	play_from_program_space(thank_you_music);

	print_two_lines_delay_1s(thank_you_line1,thank_you_line2);
}
Beispiel #5
0
// Initializes the 3pi, displays a welcome message, calibrates, and
// plays the initial music.
void initialize()
{
    // This must be called at the beginning of 3pi code, to set up the
    // sensors.  We use a value of 2000 for the timeout, which
    // corresponds to 2000*0.4 us = 0.8 ms on our 20 MHz processor.
    pololu_3pi_init(2000);
    load_custom_characters(); // load the custom characters

    play_from_program_space(welcome);
    print_two_lines_delay_1s(welcome_line1,welcome_line2);
    print_two_lines_delay_1s(demo_name_line1,demo_name_line2);
    print_two_lines_delay_1s(instructions_line1,instructions_line2);

    clear();
    print_from_program_space(instructions_line3);
    lcd_goto_xy(0,1);
    print_from_program_space(instructions_line4);

    while(!(wait_for_button_and_beep() & BUTTON_B));

    play_from_program_space(thank_you_music);

    print_two_lines_delay_1s(thank_you_line1,thank_you_line2);
}
void initialize()
{
	// Set PC5 as an input with internal pull-up disabled
	DDRC5 &= ~(1<< PORTC5); //port 5 is an input
	PORTC &= ~(1<< PORTC5);
	// Play welcome music and display a message
	print_from_program_space(welcome_line1);
	lcd_goto_xy(0,1);
	print_from_program_space(welcome_line2);
	//play_from_program_space(welcome);
	delay_ms(1000);
	clear();
	print_from_program_space(name_line1);
	lcd_goto_xy(0,1);
	print_from_program_space(name_line2);
	delay_ms(1000);
	// Display battery voltage and wait for button press
	while(!button_is_pressed(BUTTON_B))
	{
		clear();
		print_long(read_battery_millivolts());
		print("mV");
		lcd_goto_xy(0,1);
		print("Press B");
		delay_ms(100);
	}

// Always wait for the button to be released so that 3pi doesn't
// start moving until your hand is away from it.
wait_for_button_release(BUTTON_B);
clear();
print("Go!");
// Play music and wait for it to finish before we start driving.
play_from_program_space(go);
while(is_playing());
}
Beispiel #7
0
void initialize()

{

	//unsigned int counter; // used as a simple timer

	//unsigned int sensors[5]; // an array to hold sensor values




	// This must be called at the beginning of 3pi code, to set up the

	// sensors.  We use a value of 2000 for the timeout, which

	// corresponds to 2000*0.4 us = 0.8 ms on our 20 MHz processor.

	pololu_3pi_init(2000);

	//load_custom_characters(); // load the custom characters

	

	// Play welcome music and display a message

	print_from_program_space(welcome_line1);

	lcd_goto_xy(0,1);

	print_from_program_space(welcome_line2);

	//play_from_program_space(welcome);

	delay_ms(1000);




	clear();

	print_from_program_space(demo_name_line1);

	lcd_goto_xy(0,1);

	print_from_program_space(demo_name_line2);

	delay_ms(1000);




	// Display battery voltage and wait for button press

	while(!button_is_pressed(BUTTON_B))

	{

		int bat = read_battery_millivolts();




		clear();

		print_long(bat);

		print("mV");

		lcd_goto_xy(0,1);

		print("Press B");




		delay_ms(100);

	}




	// Always wait for the button to be released so that 3pi doesn't

	// start moving until your hand is away from it.

	wait_for_button_release(BUTTON_B);

	delay_ms(1000);

	clear();

}
Beispiel #8
0
void menu_select()
{
    static int menu_index = 0;

    print_two_lines_delay_1s(main_menu_intro_line1,main_menu_intro_line2);

    while(1)
    {
        clear();
        lcd_goto_xy(0,1);
        print_from_program_space(menu_line2);
        lcd_goto_xy(0,0);
        print_from_program_space(main_menu_options[menu_index]);
        lcd_show_cursor(CURSOR_BLINKING);
        // the cursor will be blinking at the end of the option name

        // wait for all buttons to be released, then a press
        while(button_is_pressed(ANY_BUTTON));
        char button = wait_for_button_press(ANY_BUTTON);

        if(button & BUTTON_A)
        {
            play_from_program_space(beep_button_a);
            menu_index --;
        }
        else if(button & BUTTON_B)
        {
            lcd_hide_cursor();
            clear();

            play_from_program_space(beep_button_b);
            wait_for_button_release(button);

            while(!button_is_pressed(BUTTON_B))
            {
                lcd_goto_xy(0,1);
                print_from_program_space(back_line2);
                lcd_goto_xy(0,0);
                main_menu_functions[menu_index]();
            }

            set_motors(0,0);
            stop_playing();
            m1_speed = 0;
            m2_speed = 0;
            red_led(0);
            green_led(0);
            play_from_program_space(beep_button_b);

            return;
        }
        else if(button & BUTTON_C)
        {
            play_from_program_space(beep_button_c);
            menu_index ++;
        }

        if(menu_index < 0)
            menu_index = main_menu_length-1;
        if(menu_index >= main_menu_length)
            menu_index = 0;
    }
}
Beispiel #9
0
// Initializes the 3pi, displays a welcome message, calibrates, and
// plays the initial music.
void initialize()
{
	unsigned int counter; // used as a simple timer
	unsigned int sensors[5]; // an array to hold sensor values

	// This must be called at the beginning of 3pi code, to set up the
	// sensors.  We use a value of 2000 for the timeout, which
	// corresponds to 2000*0.4 us = 0.8 ms on our 20 MHz processor.
	pololu_3pi_init(2000);
	load_custom_characters(); // load the custom characters
	
	// Play welcome music and display a message
	print_from_program_space(welcome_line1);
	lcd_goto_xy(0,1);
	print_from_program_space(welcome_line2);
	play_from_program_space(welcome);
	delay_ms(1000);

	clear();
	print_from_program_space(demo_name_line1);
	lcd_goto_xy(0,1);
	print_from_program_space(demo_name_line2);
	delay_ms(1000);

	// Display battery voltage and wait for button press
	while(!button_is_pressed(BUTTON_B))
	{
		int bat = read_battery_millivolts();

		clear();
		print_long(bat);
		print("mV");
		lcd_goto_xy(0,1);
		print("Press B");

		delay_ms(100);
	}

	// Always wait for the button to be released so that 3pi doesn't
	// start moving until your hand is away from it.
	wait_for_button_release(BUTTON_B);
	delay_ms(1000);

	// Auto-calibration: turn right and left while calibrating the
	// sensors.
	for(counter=0;counter<80;counter++)
	{
		if(counter < 20 || counter >= 60)
			set_motors(40,-40);
		else
			set_motors(-40,40);

		// This function records a set of sensor readings and keeps
		// track of the minimum and maximum values encountered.  The
		// IR_EMITTERS_ON argument means that the IR LEDs will be
		// turned on during the reading, which is usually what you
		// want.
		calibrate_line_sensors(IR_EMITTERS_ON);

		// Since our counter runs to 80, the total delay will be
		// 80*20 = 1600 ms.
		delay_ms(20);
	}
	set_motors(0,0);

	// Display calibrated values as a bar graph.
	while(!button_is_pressed(BUTTON_B))
	{
		// Read the sensor values and get the position measurement.
		unsigned int position = read_line(sensors,IR_EMITTERS_ON);

		// Display the position measurement, which will go from 0
		// (when the leftmost sensor is over the line) to 4000 (when
		// the rightmost sensor is over the line) on the 3pi, along
		// with a bar graph of the sensor readings.  This allows you
		// to make sure the robot is ready to go.
		clear();
		print_long(position);
		lcd_goto_xy(0,1);
		display_readings(sensors);

		delay_ms(100);
	}
	wait_for_button_release(BUTTON_B);

	clear();

	print("Go!");		

	// Play music and wait for it to finish before we start driving.
	play_from_program_space(go);
	while(is_playing());
}