コード例 #1
0
ファイル: epuckPlayer.c プロジェクト: knickels/OLDNickelsLab
void epuckPlayer()
{
  //e_start_agendas_processing();
  //e_init_motors();
  //e_init_prox();
  //e_init_uart1();

  /* Must send anything here or it don't work. Is it a bug? */
  e_send_uart1_char("epuckSide_v3.0", 14);

  unsigned a,b;

  /* Flash the LED's in a singular manner for show that this program is in
   * epuck memory */
  for(a=0; a<8; a++)
    for(b=0; b<20000; b++)
      e_set_led(a ,1); /* LED ON */

  for(a=0; a<8; a++)
    for(b=0; b<20000; b++)
      e_set_led(a ,0); /* LED OFF */

  char command;
  while(1)
  {
    command = recv_char();

    switch(command)
    {
    case 0x13:
      recv_vel();
      break;
    case 0x14:
      send_steps();
      break;
    case 0x16:
      read_ir_sensors();
      break;
    case 0x15:
      stop_motors();
      break;
    case 0x17:
      read_camera();
      break;
    case 0x18:
      set_LEDs();
      break;
    case 0x01:
      sendVersion();
      break;
    case 0x02:
      config_camera();
      break;
    }
  }
}
コード例 #2
0
/**
 * Increment effect counter & set new LED number
 */
void next_LED_in_effects(){
	if(!current_effect) return;
	set_LEDs(current_effect[effect_cntr]);
	if(effect_cntr == 0 && effect_increment == -1){ // left border - go to the right
		effect_increment = 1;
	}
	effect_cntr += effect_increment;
	if(current_effect[effect_cntr] == 0){ // right border - go to the left
		effect_increment = -1;
		effect_cntr -= 2; // and go to left from previous element
	}
}
コード例 #3
0
ファイル: LEDs2.c プロジェクト: kbob/hw-samples
void ramp(uint8_t b0, uint8_t b1, void (*set_LEDs)(uint8_t))
{
    int df = RAMP_FRAMES;
    int db = abs(b1 - b0) * 16;
    int32_t err = df / 2;
    int b = b0 * 16;
    int bstep = b1 < b0 ? -1 : +1;
    for (int f = 0; f < RAMP_FRAMES; f++) {
        int c = b / 16;
        c += (b % 16) >= dither_matrix[f % 16];
        set_LEDs(c);
        err -= db;
        if (err < 0) {
            b += bstep;
            err += df;
        }
    }
}