コード例 #1
0
ファイル: test.c プロジェクト: cguerrero1205/tilebot
int main()
{
  lcd_load_custom_character(happy, 0);
  lcd_load_custom_character(sad, 1);
  lcd_load_custom_character(indifferent, 2);
  lcd_load_custom_character(surprised, 3);
  lcd_load_custom_character(mocking, 4);
  clear();                  // this must be called before we can use the custom characters
  print("mood: ?");

  // initialize the random number generator based on how long we hold the button the first time
  wait_for_button_press(ANY_BUTTON);
  long seed = 0;
  while(button_is_pressed(ANY_BUTTON))
    seed++;
  srandom(seed);

  while(1)
  {
  
    lcd_goto_xy(6, 0);             // move cursor to the correct position
  
    char mood;
    do
    {
      mood = random()%5;
    } while (mood == prevMood);   // ensure we get a new mood that differs from the previous
    prevMood = mood;
  
    print_character(mood);   // print a random mood character
    wait_for_button(ANY_BUTTON);   // wait for any button to be pressed
  }
}
コード例 #2
0
ファイル: lab2.c プロジェクト: posborne/msse-embedded-systems
/*
 * Main Loop
 */
int main()
{
    LOG("--------------------------------\r\n");

    /* Unmask interrupt for output compare match A on TC0 */
    timers_setup_timer(TIMER_COUNTER0, TIMER_MODE_CTC, 1000UL);
    TIMSK0 |= (1 << OCIE0A);

    lcd_load_custom_character(degree_symbol, CUSTOM_SYMBOL_DEGREE);

    cli_init();
    motor_init(&g_timers_state);
    log_init();
	scheduler_init(&g_timers_state, g_tasks, COUNT_OF(g_tasks));
	interpolator_init(&g_timers_state);
    sei();

    log_start();

	/* Main Loop: Run Tasks scheduled by scheduler */
	while (1) {
	    int i;
	    for (i = 0; i < 50; i++) {
	        serial_check(); /* needs to be called frequently */
	    }
	    scheduler_service();
	}
}
コード例 #3
0
ファイル: test.c プロジェクト: Chen-Zhe/MDP-Grp2
// This function loads custom characters into the LCD.  Up to 8
// characters can be loaded; we use them for 6 levels of a bar graph
// plus a back arrow and a musical note character.
void load_custom_characters()
{
    lcd_load_custom_character(levels+0,0); // no offset, e.g. one bar
    lcd_load_custom_character(levels+1,1); // two bars
    lcd_load_custom_character(levels+2,2); // etc...
    lcd_load_custom_character(levels+4,3); // skip level 3
    lcd_load_custom_character(levels+5,4);
    lcd_load_custom_character(levels+6,5);
    lcd_load_custom_character(back_arrow,6);
    lcd_load_custom_character(note,7);
    clear(); // the LCD must be cleared for the characters to take effect
}
コード例 #4
0
ファイル: main.c プロジェクト: imsplitbit/3pi_programs
int main(void)
{
    lcd_load_custom_character(smile, 0);
    clear();
    while (1) {
        for (this_row = 0; this_row <= 1; this_row++) {
            <#statements#>
                }
        for (i = 0; i <= 7; i += 2) {
            char output = 0;
            lcd_goto_xy(i, 0);
            print_character(output);
            delay_ms(500);
        }
    }
    return 0;   /* never reached */
}
コード例 #5
0
ファイル: test.c プロジェクト: AndySze/libpololu-avr
int main()
{
    // If button A is pressed, test the PD0/PD1 outputs
	if(button_is_pressed(BUTTON_A))
		test_outputs();

	// If button C is not pressed down, go to the demo.
	if(!button_is_pressed(BUTTON_C) && !test_pushbutton_tries())
		demo();

	// Load bar graph characters.
	// Together with space and the solid block at 255, this makes almost
	// all possible bar heights, with two to spare.
	unsigned char i;
	for(i=0;i<6;i++)
	{
		lcd_load_custom_character(bars+i,i);
	}
	clear();

	pololu_3pi_init(TEST_LINE_SENSOR_TIMEOUT);

	if(test_pushbutton_tries())
		goto pushbuttons;

	play_from_program_space(welcome_test);
	print_two_lines_delay_1s_test(welcome_test_line1,welcome_test_line2);
	print_two_lines_delay_1s_test(test_name_line1,test_name_line2);

	clear();

 	test_battery();
	test_qtr();
	test_motors();
	test_pot();
pushbuttons:
	test_pushbuttons();

	clear();
	print("Success");
	play("O5 c16");
	
	while(1);
}