コード例 #1
0
ファイル: leds.c プロジェクト: robbievz/symawii
// switch the LEDs according to the timer, the function have to be called if the programm is running in a loop
// 
void leds_blink_continuous(unsigned char state, unsigned int on_time, unsigned int off_time) {
	if(lib_timers_gettimermicroseconds(0) % ((on_time + off_time) * 1000) > (off_time * 1000) )
			leds_set(state);
	else
			leds_set(~state);
			 
}
コード例 #2
0
ファイル: rx_flysky.c プロジェクト: TheSmartGerman/bradwii-X4
void bind() {
	/* if no id found, bind */
	while (usersettings.flysky_id==0) {
		usersettings.flysky_id=bind_Flysky();
	} 
	/* if id found toggle read and bind until one frame is readed */
	/* in that way, it possible to bind with an other TX even if one tx id is already registered */
	uint8_t state=READ_STATE;
	while (state!=DONE) {
		unsigned long timeout_timer=lib_timers_starttimer();
		if (state==READ_STATE) {
			init_channels();
			if (_readrx()) state=DONE;
			while (state==READ_STATE && lib_timers_gettimermicroseconds(timeout_timer) < BIND_READ_TOGGLE_TIMEOUT) {
				if( lib_timers_gettimermicroseconds(0) % 500000 > 250000)
					leds_set(LED1 | LED5);
				else
					leds_set(LED2 | LED6);
				if (_readrx()) state=DONE;
			}
			if (state==READ_STATE) {
				state=BIND_STATE;
			}
		}
		if (state==BIND_STATE) {
			uint32_t _id=bind_Flysky();
			if (_id) {
				usersettings.flysky_id=_id;
			}
			state=READ_STATE;
		}
	}
}
コード例 #3
0
ファイル: rx_flysky.c プロジェクト: TheSmartGerman/bradwii-X4
//BIND_TX
uint32_t bind_Flysky() {
	unsigned long timeout_timer=lib_timers_starttimer();
	uint32_t _id=0;
	// set channel 0;
	A7105_Strobe(0xA0);
	A7105_WriteRegister(A7105_0F_PLL_I,00);
	A7105_Strobe(A7105_RX);
	while(!_id && lib_timers_gettimermicroseconds(timeout_timer) < BIND_READ_TOGGLE_TIMEOUT)
	{
	if( lib_timers_gettimermicroseconds(0) % 524288 > 262144)
            leds_set(LED2 | LED4);
        else
            leds_set(LED1 | LED3);
				
	char mode = A7105_ReadRegister(A7105_00_MODE);

	if(mode & A7105_MODE_TRER_MASK || mode & (1<<6) ||  mode & ( 1<<5) )	
		{
		A7105_Strobe(A7105_RST_RDPTR); 
		A7105_Strobe(A7105_RX);
		continue;
		}
	A7105_ReadPayload((uint8_t*)&packet, sizeof(packet)); 
  A7105_Strobe(A7105_RST_RDPTR);
	if ( packet[0] == 170 )  // 170
			{
				//set found tx		
			  _id=( ( packet[1] << 0 |  packet[2] <<8 |  packet[3] << 16 | packet[4]<<24 ) );
			}
	 A7105_Strobe(A7105_RX);		
	}
	return _id;
}
コード例 #4
0
void leds_run(int brightness, int delay)
{
    int brightness_max = 255;
    int brightness_2 = abs(brightness / 2);
    int adj_delay = abs(brightness_max / brightness * delay);

    int j;
    struct cRGB color, color2;
    for (int i = 0; i < brightness; i++) {
        color.r = i;
        color.g = brightness - i;
        color.b = i < brightness_2 ? brightness_2 + i : i - brightness_2;
        leds_set(0, color);

        color2.r = color.b;
        color2.g = color.g;
        color2.b = color.r;
        leds_set(1, color2);

        j = adj_delay;
        while (j--) {
            _delay_ms(1);
        }
    }
}
コード例 #5
0
ファイル: sys_hw.c プロジェクト: JorgeGzm/JAGA
PUBLIC void setupDevices(void)
{   
    //inicializa informaçoes do equipamento.
    info_init();

    //inicializa e configura mecanismo de controle das teclas
    buttons_init();
    button_attach(1, 9);
    button_attach(2, 28);

    //configura e inicializa pinos que serao usados pela biblioteca LCD.
    lcd_attach(14, 15, 22, 23, 24, 25);
    lcd_gotoxy(1, 1);
    uint8_t buff[] = {"Modulo JAGA!    "};
    lcd_print(&buff);
   
    //configura mecanismo de controle dos leds
    pinMode(0, INPUT);
    leds_init();
    leds_attach(0, 4);
    leds_attach(1, 5);
    
    leds_set(LD1G, LED_BLINK_FAST);
    leds_set(LD2G, LED_BLINK_SLOW);
   
}
コード例 #6
0
ファイル: leds.c プロジェクト: robbievz/symawii
void leds_blink_cycles(unsigned char state, unsigned int on_time, unsigned int off_time, unsigned char cycles)
{
	for(uint8_t i=0;i<cycles;i++) {
			leds_set(state);
			lib_timers_delaymilliseconds(on_time);
			leds_set(~state);
			lib_timers_delaymilliseconds(off_time);
	}							
}
コード例 #7
0
ファイル: dongle-node.c プロジェクト: An-S/contiki
/* Call back for led toggle timer to toggle leds */
static void
ct_callback(void *ptr)
{
  static uint8 toggle_status = 0;
  if(toggle_status) {
    leds_set(LEDS_RED);
  } else {
    leds_set(LEDS_GREEN);
  } ctimer_restart(&ct);
  toggle_status ^= 0x01;
}
コード例 #8
0
void cmd_tick(void)
{
    if( cmd_desiredDoorStateTimeout-- == 0 ){
        cmd_desiredDoorStateTimeout = 0;
        cmd_desiredDoorState = DOOR_LOCK_LOCKED;
    }

    door_setDesiredState(cmd_desiredDoorState);

    if( (door_getState() & (DOOR_LOCK_LOCKED | DOOR_DOOR_CLOSED)) ==
            (DOOR_LOCK_LOCKED | DOOR_DOOR_CLOSED) ){
        leds_set(LED_OPEN, LED_SHORT_FLASH);
    }else{
        leds_set(LED_OPEN, LED_ON);
    }
}
コード例 #9
0
void B_exec(struct st_event* evt) {
	static int16_t count = 0;
	leds_set(2);

	timer_execute_once( count&1 ? eventY_cb : eventX_cb, TIMER_SECOND);
	
	count ++;
}
コード例 #10
0
void leds_set_circle(unsigned char l1, unsigned char l2, unsigned char l3, unsigned char l4, unsigned char l5, unsigned char l6, unsigned char l7, unsigned char l8) {
	leds_set(LED_CIRCLE_0, l1);
	leds_set(LED_CIRCLE_1, l2);
	leds_set(LED_CIRCLE_2, l3);
	leds_set(LED_CIRCLE_3, l4);
	leds_set(LED_CIRCLE_4, l5);
	leds_set(LED_CIRCLE_5, l6);
	leds_set(LED_CIRCLE_6, l7);
	leds_set(LED_CIRCLE_7, l8);
}
コード例 #11
0
void leds_off()
{
    struct cRGB color = {0, 0, 0};
    for (int i = 0; i < leds_count; i++) {
        leds_set(i, color);
    }

    ws2812_setleds(leds, leds_count);
}
コード例 #12
0
ファイル: main.c プロジェクト: tuanh118/aseba-target-thymio2
void AsebaVMResetCB(AsebaVMState *vm) {
	leds_set_circle(0,0,0,0,0,0,0,0);
	leds_set_body_rgb(0,0,0);
	leds_set(LED_SOUND,0);
	leds_set(LED_RC,0);
	behavior_start(B_LEDS_ACC);
	behavior_start(B_LEDS_NTC);
	behavior_start(B_LEDS_MIC);
	behavior_start(B_LEDS_PROX);
	behavior_start(B_SOUND_BUTTON);
	behavior_start(B_LEDS_MIC);
	behavior_start(B_LEDS_RC5);
	prox_disable_network();
	memset(vm->variables, 0, vm->variablesSize*sizeof(sint16));
	vmVariables.id = vmState.nodeId;
	vmVariables.productid = PRODUCT_ID;
	vmVariables.fwversion[0] = FW_VERSION;
	vmVariables.fwversion[1] = FW_VARIANT;	
}
コード例 #13
0
ファイル: cutnpaste.c プロジェクト: backeliten/RPI-EMS
void heartbeat(void *cookie)
{
	int state = 0;

	while (!end) {
		rtdm_task_wait_period();

		leds_set(state++);
	}
}
コード例 #14
0
ファイル: dongle-node.c プロジェクト: An-S/contiki
static void
put_post_led_toggle_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
  static int led_state = 0;
  const uint8_t *request_content;
  int request_content_len;
  unsigned int accept = -1;

  /* Given the way the LEDs are connected to the DIO ports, the LEDs are controlled via direct DIO access. */
  content_len = 0;
  switch(led_state) {
  case (0):
    ctimer_stop(&ct);
    leds_set(LEDS_GREEN);            /* Only LEDS_GREEN on */
    CONTENT_PRINTF("Message from resource: Green LED on");
    led_state = 1;
    break;
  case (1):
    leds_set(LEDS_RED);              /* Only LEDS_RED on */
    CONTENT_PRINTF("Message from resource: Red LED on");
    led_state = 2;
    break;
  case (2):
    leds_set(0);                      /* All LEDS off */
    CONTENT_PRINTF("Message from resource: All LEDs off");
    led_state = 3;
    break;
  case 3:
    /* Both leds toggle */
    CONTENT_PRINTF("Message from resource: LEDs toggle");
    ctimer_restart(&ct);
    led_state = 0;
  default:
    break;
  }
  /* Return message */
  REST.get_header_accept(request, &accept);
  if(accept == -1 || accept == REST.type.TEXT_PLAIN) {
    REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
    REST.set_response_payload(response, (uint8_t *)content, content_len);
  }
}
コード例 #15
0
void leds_blink()
{
    struct cRGB color = {20, 20, 20};
    for (int i = 0; i < leds_count; i++) {
        leds_set(i, color);
    }

    _delay_ms(500);

    leds_off();
}
コード例 #16
0
void set_1_blue(int32_t idx)
{
  int32_t result = 0;
  // LOCKED 30 JUN 2015  
  // Set one of the six blue LEDs
  // -- connections designed for Charlieplexing
  //    * make one high, one low, the other high-z (input)
  // -- for multiple LEDs use Charlieplex driver methods
  
  if (cpcog) {
    // Charlieplex driver loaded?
    if ((idx >= BLUE_0) && (idx <= BLUE_5)) {
      // valid element?
      // set via mask
      led_on((1 << idx));
    } else {
      // clear all 
      leds_set(0b000000);
    }
    return;
  }
  // if no driver loaded, use direct control
  if (idx == BLUE_0) {
    // CP2 = L, CP1 = H, CP0 = Z     
    OUTA = ((OUTA & 0xfffffe3f) | 0x80);
    DIRA = ((DIRA & 0xfffffe3f) | 0x180);
  } else if (idx == BLUE_1) {
    // CP2 = H, CP1 = Z, CP0 = L    
    OUTA = ((OUTA & 0xfffffe3f) | 0x100);
    DIRA = ((DIRA & 0xfffffe3f) | 0x140);
  } else if (idx == BLUE_2) {
    // CP2 = L, CP1 = Z, CP0 = H 
    OUTA = ((OUTA & 0xfffffe3f) | 0x40);
    DIRA = ((DIRA & 0xfffffe3f) | 0x140);
  } else if (idx == BLUE_3) {
    // CP2 = H, CP1 = L, CP0 = Z  
    OUTA = ((OUTA & 0xfffffe3f) | 0x100);
    DIRA = ((DIRA & 0xfffffe3f) | 0x180);
  } else if (idx == BLUE_4) {
    // CP2 = Z, CP1 = H, CP0 = L 
    OUTA = ((OUTA & 0xfffffe3f) | 0x80);
    DIRA = ((DIRA & 0xfffffe3f) | 0xc0);
  } else if (idx == BLUE_5) {
    // CP2 = Z, CP1 = L, CP0 = H
    OUTA = ((OUTA & 0xfffffe3f) | 0x40);
    DIRA = ((DIRA & 0xfffffe3f) | 0xc0);
  } else if (1) {
    // disable all
    OUTA &= ~(7<<BLU_CP0);
    DIRA &= ~(7<<BLU_CP0);
  }
}
コード例 #17
0
ファイル: main.c プロジェクト: mbonani/aseba-target-thymio2
void AsebaVMResetCB(AsebaVMState *vm) {
	leds_set_circle(0,0,0,0,0,0,0,0);
	leds_set_body_rgb(0,0,0);
	leds_set(LED_SOUND,0);
	leds_set(LED_RC,0);
	behavior_start(B_LEDS_ACC);
	behavior_start(B_LEDS_NTC);
	behavior_start(B_LEDS_MIC);
	behavior_start(B_LEDS_PROX);
	behavior_start(B_SOUND_BUTTON);
	behavior_start(B_LEDS_MIC);
	behavior_start(B_LEDS_RC5);
	prox_disable_network();
	events_flags[0] = 0;
	events_flags[1] = 0;
	memset(vm->variables, 0, vm->variablesSize*sizeof(int16_t));
	vmVariables.id = vmState.nodeId;
	vmVariables.productid = PRODUCT_ID;
	vmVariables.fwversion[0] = FW_VERSION;
	vmVariables.fwversion[1] = FW_VARIANT;
	vmVariables.sd_present = !sd_user_open("_TESTSD");
	sd_user_open(NULL);	
}
コード例 #18
0
ファイル: main.c プロジェクト: edwkar/TDT4258
static ssize_t leds_dev_write(struct file *filp,
                              const char *buffer,
                              size_t length,
                              loff_t * offset)
{
    unsigned char v[1];

    if (length == 0)
        return 0;

    copy_from_user(v, buffer, 1);
    leds_set((unsigned int) v[0]);

    return 1;
}
コード例 #19
0
ファイル: cmd-leds.c プロジェクト: w5292c/mcode
void cmd_engine_set_led(const char *args)
{
  uint16_t index = -1;
  uint16_t value = -1;
  args = string_skip_whitespace(args);
  args = string_next_number(args, &index);
  args = string_skip_whitespace(args);
  string_next_number(args, &value);

  if (index > 2u || value > 1u) {
    merror(MStringWrongArgument);
    return;
  }

  leds_set(index, value);
}
コード例 #20
0
int main(void)
{
    // Boot
    struct cRGB color = {0, 0, 10};
    leds_set(1, color);
    _delay_ms(1000);
    leds_off();

    // Set up game
    game_setup();

    while(1) {
        // Game loop
        game_loop();
    }

    return 0;
}
コード例 #21
0
int main(void)
{
    wdt_disable();
    /* Clear WDRF in MCUSR */
    MCUSR &= ~(1<<WDRF);
    /* Write logical one to WDCE and WDE */
    /* Keep old prescaler setting to prevent unintentional time-out */
    WDTCSR |= (1<<WDCE) | (1<<WDE);
    /* Turn off WDT */
    WDTCSR = 0x00;
    //DDRA |= 0x07;
    //PORTA &= ~7;
    //DDRC |= 0x07;
    //DDRC |= 0xC0;

    eeprom_read_block(&state, &state_ee, sizeof(state));
    aes_handler_init();
    bus_handler_init();
    serial_init();
    bus_init();
    cmd_init();
    buttons_init();
    leds_init();
    timer0_init();
    sei();
    
    leds_set(0,LED_SHORT_FLASH);

    while( 1 ){
        if( timer0_timebase ){
            timer0_timebase--;
            bus_tick();
            serial_tick();
            buttons_tick();
            leds_tick();
        }
        bus_process();
        serial_process();

        //aes128_enc(data, &ctx); /* encrypting the data block */
    }

}
コード例 #22
0
void cmd_new(uint8_t cmd, uint8_t *data)
{
    if( cmd == CMD_SET_LED ){
        uint8_t led = data[0];
        uint8_t state = data[1];
        leds_set(led, state);
        bus_sendAck(true);
    //}else if( cmd == CMD_SEND_STATE ){
        //cmd_sendState();
#if 0
    }else if( cmd == CMD_CLEAR_BUTTONS ){
        uint8_t buttons = data[0];
        buttons_clearPendingButtons(buttons);
        bus_sendAck(true);
#endif
    }else if( cmd == CMD_DOOR_STATE ){
        uint8_t door_state = data[0];
        cmd_setDesiredDoorState(door_state);
        //bool success = door_cmd(cmd);
        cmd_sendState();
        //bus_sendAck(success);
    }
}
コード例 #23
0
void first_init() {
	st_init_chain(&first_chain);

	stateA.exec = A_exec;
	stateB.exec = B_exec;
	stateC.exec = C_exec;
	st_add_state(&first_chain, &stateA);
	st_add_state(&first_chain, &stateB);
	st_add_state(&first_chain, &stateC);

	
	t1.event = &eventX;
	t1.from_state = &stateA;
	t1.to_state = &stateB;

	t2.event = &eventX;
	t2.from_state = &stateB;
	t2.to_state = &stateC;
	
	t3.event = &eventX;
	t3.from_state = &stateC;
	t3.to_state = &stateB;

	t4.event = &eventY;
	t4.from_state = &stateB;
	t4.to_state = &stateA;

	st_add_transition(&first_chain, &t1);
	st_add_transition(&first_chain, &t2);
	st_add_transition(&first_chain, &t3);
	st_add_transition(&first_chain, &t4);

	leds_set(0);

	st_set_active_state(&first_chain, &stateA);
	timer_execute_once(eventX_cb, TIMER_SECOND);
}
コード例 #24
0
ファイル: frame.c プロジェクト: lochsh/thegrid
void frame_process() {
    if(!frame_check_sync())
        return;

    Packet pkt = framebuf.packets[node_id];
    if(!packet_check_checksum(&pkt)) {
        /*leds_set(255, 0, 0);*/
        return;
    }

    switch(pkt.cmd_id) {
        case CMD_SYNC:
            return;
        case CMD_SET_ID:
            set_node_id(&pkt);
            break;
        case CMD_BOOTLOAD:
            bootload(&pkt);
            break;
        default:
            leds_set(pkt.r, pkt.g, pkt.b);
            sound_set(pkt.sound_id, pkt.sound_freq, pkt.sound_mag);
    }
}
コード例 #25
0
void leds_set_br(unsigned char r, unsigned char g, unsigned char b) {
	leds_set(LED_R_BOT_R, r);
	leds_set(LED_G_BOT_R, g);
	leds_set(LED_B_BOT_R, b);
}
コード例 #26
0
ファイル: main.c プロジェクト: tuanh118/aseba-target-thymio2
int main(void)
{   
	int test_mode;
	int vm_present;
	int i;
	unsigned int seed;

	// Needs to be called ASAP as rf need a looooooong time to wake up.
	// This function is just sending a pulse over the SCL line.
	rf_wakeup();
	
	clock_set_speed(16000000UL,16);	
	
	setup_pps();
	setup_io();
	
	leds_init();

	CHARGE_500MA = 0; // Switch back to 100mA charge.
	
	// Switch on one led to say we are powered on
	leds_set(LED_BATTERY_0, 32);

	// Enable the poweroff softirq.
	_INT3IF = 0;
	_INT3IP = 1;
	_INT3IE = 1;

	// Sound must be enabled before analog, as 
	// The analog interrupt callback into sound processing ... 
	// But must be initialised _after_ leds as it use one led IO for enabling amp.
	sound_init();
	tone_init(); // Init tone generator
	
	pwm_motor_init();
	pid_motor_init();

	// We need the settings for the horizontal prox.
	load_settings_from_flash();


	for (i = 0; i < 2; i++) {
		// Settings is definitely wrong....
		if(settings.mot256[i] <= 0)
			settings.mot256[i] = 256;

		// 1024 (AD resolution is 10 bits) * 256 / 9 fits in signed 16 bits.
		if (settings.mot256[i] < 9)
			settings.mot256[i] = 9;
	}
	
	// This is the horizontal prox. Vertical one are handled by the ADC
	// but ADC sync the motor mesurment with the prox, so we don't pullute it with noise ...
	
	timer_init(TIMER_IR_COMM, 0,-1); // The period will be changed later.
	prox_init(PRIO_SENSORS);  // Same priority as analog (maybe should be at 7 ...)
	
	// Warning: We cannot use the SD before the analog init as some pin are on the analog port.
	analog_init(TIMER_ANALOG, PRIO_SENSORS);

        wait_valid_vbat();
        
	log_init(); // We will need to read vbat to be sure we can flash.

	ntc_init(ntc_callback, PRIO_1KHZ);

//	i2c_init(I2C_3);

	i2c_init_master(I2C_3, 400000, PRIO_I2C);
	I2C3CON = 0x9000;

	
	mma7660_init(I2C_3, MMA7660_DEFAULT_ADDRESS, acc_cb, 0);
	mma7660_set_mode(MMA7660_120HZ, 1);
	
	rc5_init(TIMER_RC5, rc5_callback, PRIO_RC5);
	
	sd_init();

	timer_init(TIMER_1KHZ, 1000, 6);
	timer_enable_interrupt(TIMER_1KHZ, timer_1khz, PRIO_1KHZ);
	
	rf_init(I2C_3);
	
	timer_enable(TIMER_1KHZ);
	
	sd_log_file();
	
	vm_present = init_aseba_and_fifo();
	
	if(vm_present) 
		log_analyse_bytecode();

	vmVariables.fwversion[0] = FW_VERSION;
	vmVariables.fwversion[1] = FW_VARIANT;
	
	// SD file is more important than internal flash
	if(!sd_load_aseba_code()) {
		log_set_flag(LOG_FLAG_VMCODESD);
		vm_present = 1;
		log_analyse_bytecode();
	}

	// Behavior is on INT4 (softirq trigged by 1khz timer).
	behavior_init(PRIO_BEHAVIOR);
	
	
	test_mode = sd_test_file_present();
	
	if(!test_mode)
		mode_init(vm_present);

	
	
	// Enable the LVD interrupt
	_LVDIE = 1;
	
	play_sound(SOUND_POWERON);
	
	if(test_mode) {	
		test_mode_start();
		while(1) 
			idle_without_aseba();
	}
	
	while(behavior_enabled(B_MODE)) 
		idle_without_aseba();
	
	// If usb did not put us out of behavior mode, then start the rf link
	if(!usb_uart_serial_port_open() && (rf_get_status() & RF_PRESENT)) {
		rf_set_link(RF_UP);
	}

	// get the random seed
	seed = 0;
	for(i = 0; i < 5; i++) {
		seed += vmVariables.buttons_mean[i];
		seed += vmVariables.buttons_noise[i];
	}
	seed += vmVariables.vbat[0];
	seed += vmVariables.vbat[1];
	
	for(i = 0; i < 3; i++) 
		seed += vmVariables.acc[i];
	
	AsebaSetRandomSeed(seed);
	
	for(i = 0; i < 3; i++)
		AsebaGetRandom();
	
	// Give full control to aseba. No way out (except reset).
	run_aseba_main_loop();
}
コード例 #27
0
void leds_set_bl(unsigned char r, unsigned char g, unsigned char b) {
	leds_set(LED_R_BOT_L, r);
	leds_set(LED_G_BOT_L, g);
	leds_set(LED_B_BOT_L, b);
}
コード例 #28
0
ファイル: main.c プロジェクト: nordlicht81/formica_rev1_muc
int main( void )
{
        uint32_t chargeopportunity = 0;
	init();

	random_walk_disable();

	time_wait(TICKS_PER_SEC * 1);
	/* start charging if touching charger within 1 second */
	chargeopportunity = the_time + 20;
	leds_set(ORANGE);
	while (the_time < chargeopportunity)
	{
		if ( battery_power_good() )
			now_parking = !charge_complete;
	}
	leds_set(NONE);
	
	while(1)
	{
		leds_update_mood();
	    
		if (battery_critical())
			low_power();
	    
		/* We may have finished charging */
		if( charge_complete )
		{
			food_level = 0;
			charge_complete = FALSE;
			now_parking = 0;
		
			/* reverse out of the charger */
			random_walk_disable();
			motor_r = motor_l = 6;
			motor_mode = MOTOR_BK;
		
			time_wait(5);
			continue;
		}
		
		/* Go to the charger if... */
		if( battery_low()
		    /* Or we've reached a defficiency of food */
		    || ( food_level > FOOD_THRESHOLD ) 
		    || ( now_parking )  ) 
		{
			if (battery_low() )
				mood = MOOD_DRIVING_TO_CHARGER_FLATBATT;
			else if ( food_level > FOOD_THRESHOLD ) 
				mood = MOOD_DRIVING_TO_CHARGER_NOFOOD;
		   
			now_parking = !charge_complete;
			parking_update();
			continue;
		}

		/* Parking involves a static situation, which is incompatible 
		   with the watchdog - hence leave it here. */
		watchdog_update();

		if( hasfood() )
		{
			mood = MOOD_GOT_FOOD;

			/* Are we at the light source? */
			if(light_intensity == 0)
			{
				/* Deposit food here */
				mood = MOOD_AT_LAMP;
				leds_update_mood();
				random_walk_disable();
				motor_r = motor_l = 6;
				motor_mode = MOTOR_BK;

				time_wait(10);
			}

			/* Do we have a reasonable bearing? */
			else if(bearing_strength > 10)
			{
				random_walk_disable();
				braitenberg_update();
			}
			else
				/* Random Walk */
				random_walk_enable();

		}
		else
		{
			/* Not got food, just do random walk */
			mood = MOOD_NONE;
			random_walk_enable();
		}
	}
}
コード例 #29
0
ファイル: heartbeat.c プロジェクト: pficheux/raspberry_pi
static void leds_cleanup(void)
{
	leds_set(0);
}
コード例 #30
0
void leds_set_top(unsigned char r, unsigned char g, unsigned char b) {
	leds_set(LED_R_TOP, r);
	leds_set(LED_G_TOP, g);
	leds_set(LED_B_TOP, b);	
}