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