int main (void) { led_t leds[LEDS_NUM]; uint8_t i; /* Initialise IR driver. */ ir_sirc_rx_init (); /* Initialise LEDs. */ for (i = 0; i < LEDS_NUM; i++) leds[i] = led_init (&leds_cfg[i]); led_set (leds[0], 1); led_set (leds[1], 0); while (1) { int16_t data; /* Poll the IR driver. */ data = ir_sirc_rx_read (); if (data > 0) led_set (leds[1], 1); } }
void switch_to_netzbetrieb(void) { canix_frame message; // Status merken: on_battery = 0; // Relais schalten darlingtonoutput_setpin(7,0); // Auch hier wieder: ein Prellen verhindern usv_timer = 10; // LEDs anpassen: led_set(3,10); led_set(6,0); // Busteilnehmer informieren: message.src = canix_selfaddr(); message.dst = HCAN_MULTICAST_INFO; message.proto = HCAN_PROTO_SFP; message.data[0] = HCAN_SRV_USVS; message.data[1] = HCAN_USVS_STATE_INFO; message.data[2] = on_battery; message.size = 3; canix_frame_send(&message); }
/* * Header: Decode the specified instruction * * Params: tsk - the task to obtain an instruction from * opcode - the addr at which to save opcode *mask* * params - the addr at which to save the parameters * Return: 0 - success of execution * ETRINS - malformed instruction * * Description: * * Decodes the fields of the instructions and saves them in the provided * locations. If any field is malformed, that error will be returned, and * the state of opcode and params is undefined. */ static char task_instr_decode(struct task *tsk, unsigned char *opcode, unsigned char *params) { char result = 0; unsigned char instr = tsk->recipe[tsk->pc]; switch(instr_get_opcode(instr, opcode)) { case EINVOP: led_set(tsk, LED_RECIPE_CMD_ERROR); tsk->state = ST_ERROR; result = ETRINS; goto yield; } switch(instr_get_params(instr, params)) { case EINVOP: case EINVTG: case EINVDL: case EINVLP: led_set(tsk, LED_RECIPE_CMD_ERROR); tsk->state = ST_ERROR; result = ETRINS; goto yield; case ENOPRM: /* ENOPRM just means the opcode has no param! */ break; } yield: return result; }
int main (void) { system_init (); led_init (); /* TODO: Initialise timer/counter1. */ TCCR1A = 0x00; TCCR1B = 0x05; TCCR1C = 0x00; TCNT1 = 0; while (1) { /* Turn LED on. */ led_set (LED1, 1); /* TODO: wait for 500 milliseconds. */ timer_wait(40); /* Turn LED off. */ led_set (LED1, 0); //timer_wait(3900); timer_wait(40); /* TODO: wait for 500 milliseconds. */ } }
void set_error_tsd(errormsg_t *err, uint8_t errornum, uint8_t track, uint8_t sector, int8_t drive) { char *msg = (char *)err->error_buffer; err->errorno = errornum; err->readp = 0; rom_sprintf(msg, IN_ROM_STR("%2.2d,"), errornum); // error number rom_strcat(msg, errmsg(errornum)); // error message from flash memory if (drive < 0) { rom_sprintf(msg + strlen(msg), IN_ROM_STR(",%2.2d,%2.2d\r"), track%100, sector%100); // track & sector } else { rom_sprintf(msg + strlen(msg), IN_ROM_STR(",%2.2d,%2.2d,%1.1d\r"), track, sector, drive); // track & sector & drive } if (errornum != CBM_ERROR_OK && errornum != CBM_ERROR_DOSVERSION && errornum != CBM_ERROR_SCRATCHED) { led_set(ERROR); term_printf("Setting status to: %s\n", err->error_buffer); } else { led_set(OFF); // same as idle, but clears error } #ifdef DEBUG_ERROR debug_printf("Set status to: %s\n", err->error_buffer); #endif }
int main (void) { led_t led1; button_t button1; /* Initialise LED. */ led1 = led_init (&led1_cfg); /* Turn on LED. */ led_set (led1, 1); /* Initialise button. */ button1 = button_init (&button1_cfg); button_poll_count_set (BUTTON_POLL_COUNT (BUTTON_POLL_RATE)); pacer_init (BUTTON_POLL_RATE); while (1) { pacer_wait (); button_poll (button1); if (button_pushed_p (button1)) { /* Turn off LED. */ led_set (led1, 0); sleep_setup (); } } return 0; }
/*! The main function. */ void job_on_the_field(struct programs_t *progs, struct debug_t *debug, struct tm *tm_clock) { if (flag_get(progs, FL_LED)) led_set(GREEN, ON); if (flag_get(progs, FL_LOG)) { debug_print_P(PSTR("Executing programs at "), debug); date(debug); } prog_run(progs, tm_clock, debug); if (prog_alarm(progs)) { if (flag_get(progs, FL_LED)) led_set(RED, BLINK); if (flag_get(progs, FL_LOG)) debug_print_P(PSTR("ALARM! queue run skipped!\n"), debug); } else { if (flag_get(progs, FL_LOG)) { debug_print_P(PSTR("Run queue at "), debug); date(debug); } queue_run(progs, tm_clock, debug); } /* print the temperature updated * from the prog_run call */ if (flag_get(progs, FL_LOG)) temperature_print(progs, debug); led_set(GREEN, OFF); }
void switch_to_battery(void) { canix_frame message; // Status merken: on_battery = 1; // Relais schalten darlingtonoutput_setpin(7,1); // Timer auf 2 Sekunden setzen, d.h. fruehstens in // 2 Sekunden kann die USV wieder reagieren. Das ist noetig // damit kein "Prellen" oder "Flackern" passiert usv_timer = 200; // LEDs anpassen: led_set(3,0); led_set(6,10); // Busteilnehmer informieren: message.src = canix_selfaddr(); message.dst = HCAN_MULTICAST_INFO; message.proto = HCAN_PROTO_SFP; message.data[0] = HCAN_SRV_USVS; message.data[1] = HCAN_USVS_STATE_INFO; message.data[2] = on_battery; message.size = 3; canix_frame_send(&message); }
void main(void){ for (;;){ led_set(LED, 1); sleep(period / 2); led_set(LED, 0); sleep(period / 2); } }
void led_init(void) { led_setmodestatic(0); led_setmodestatic(1); led_set(0,1); led_set(1,0); led_enact(); }
/** **************************************************************************************** * @brief LED initilization **************************************************************************************** */ void led_init() { // gpio P0.5/P0.4/P0.3/P0.2/P0.1 are output to control led 1~5 gpio_set_direction_field(LED1_PIN|LED2_PIN, (uint32_t)GPIO_OUTPUT); // all led are off led_set(1, LED_OFF); led_set(2, LED_OFF); }
void ButtonMachine::setLED() { if (m_index>7) return; led_set(0); wait(BT_FLASH_TIMEOUT); // flash for just a little bit led_set(g_colors[m_index]); }
static uint32_t led_set_sequence_step(led_data_t *leds, uint32_t step_num) { led_seq_step_t *step = &leds->sequence[step_num]; leds->sequence_step = step_num; led_set(&leds->led_state[0], step->state & 0x01); led_set(&leds->led_state[1], step->state & 0x02); leds->t_sequence_next = HAL_GetTick() + 10*step->time_in_10ms; return 10 * step->time_in_10ms; }
/** * Enable/Disable the LED. * LET ON|OFF */ void cmd_led(char *args) { if (strcmp("on", args) == 0) { led_set(1); } else if (strcmp("off", args) == 0) { led_set(0); } else { syntax_error(); } }
void diag_initialise(void) { led_set(OVMS_LED_GRN,NET_LED_ERRDIAGMODE); led_set(OVMS_LED_RED,NET_LED_ERRDIAGMODE); led_start(); net_timeout_ticks = 0; net_timeout_goto = 0; net_puts_rom("\x1B[2J\x1B[01;01H\r# OVMS DIAGNOSTICS MODE\r\n\n"); orig_canwrite = sys_features[FEATURE_CANWRITE]; canwrite_state = -1; }
void colorize() { if (!leds_are_custom()) { for (int i=0; i<6; i++) { led_set(mapping[i], LED_R|LED_G|LED_B); } for (int i=6; i<12; i++) { led_set(mapping[i], 0); } } }
static void flash_RL (led_color color) { led_set(LED_RIGHT, color); spin(64 * 1024); led_set(LED_BOTH, LED_BLACK); led_set(LED_LEFT, color); spin(64 * 1024); led_set(LED_BOTH, LED_BLACK); spin(512 * 1024); }
static int main_led(int argc, char **argv) { led_name = argv[1]; if (!strcmp(argv[2], "set")) { led_set("trigger", "mtk-wifi"); } else { led_set("trigger", "none"); led_set("brightness", "0"); } return 0; }
static void hello(void) { uint8_t i; drive_0(1); for (i = 0; i < 8; i++) { led_set(0xff); _delay_ms(33); led_set(0x00); _delay_ms(33); } drive_0(0); }
/** **************************************************************************************** * @brief Led 1 flash process **************************************************************************************** */ static void usr_led1_process(void) { if(led_get(1) == LED_ON) { led_set(1, LED_OFF); ke_timer_set(APP_SYS_LED_1_TIMER, TASK_APP, usr_env.led1_off_dur); } else { led_set(1, LED_ON); ke_timer_set(APP_SYS_LED_1_TIMER, TASK_APP, usr_env.led1_on_dur); } }
void ButtonMachine::flashLED(uint8_t flashes) { int i; for (i=0; i<flashes; i++) { led_set(0); wait(BT_FLASH_TIMEOUT); // flash for just a little bit led_set(g_colors[m_index]); wait(BT_FLASH_TIMEOUT); // flash for just a little bit } }
Error led_init() { DDRC = 0x60; for (uint i = 0; i < 20; ++i) { led_set(i & 1, true); led_set((i + 1) & 1, false); os_sleep(10); } return success; }
void led_warning(unsigned char n) { led_init(); for(unsigned char i=0; i<n; i++) { _delay_ms(LED_TIME); led_set(0,0); led_enact(); _delay_ms(LED_TIME); led_set(0,1); led_enact(); } }
/** \brief Displays an error message on assertion This function will display an error message on an assertion to the debug output. \param[in] msg Error message to display \param[in] line Line number in file with error \param[in] file Filename with error */ void assert_printf(char *msg, int line, char *file) { if (msg) { LWIP_DEBUGF(LWIP_DBG_ON, ("%s:%d in file %s\n", msg, line, file)); while (1) { /* Fast LED flash */ led_set(0); msDelay(100); led_set(1); msDelay(100); } } }
void diag_initialise(void) { led_set(OVMS_LED_GRN,OVMS_LED_ON); led_set(OVMS_LED_RED,OVMS_LED_OFF); led_start(); net_timeout_ticks = 0; net_timeout_goto = 0; net_puts_rom("\x1B[2J\x1B[01;01H\r# OVMS DIAGNOSTICS MODE\n\n"); #ifdef OVMS_CAR_TESLAROADSTER orig_canwrite = sys_features[FEATURE_CANWRITE]; canwrite_state = -1; #endif //OVMS_CAR_TESLAROADSTER }
static void navswitch_task (__unused__ void *data) { navswitch_update (); if (navswitch_push_event_p (NAVSWITCH_NORTH)) things_monster_move (0, -1); if (navswitch_push_event_p (NAVSWITCH_SOUTH)) things_monster_move (0, 1); if (navswitch_push_event_p (NAVSWITCH_EAST)) things_monster_move (1, 0); if (navswitch_push_event_p (NAVSWITCH_WEST)) things_monster_move (-1, 0); /* Pause/resume things running around. */ if (navswitch_push_event_p (NAVSWITCH_PUSH)) { switch (game_state) { case GAME_WAIT: game_state = GAME_RUNNING; srand (timer_get ()); tinygl_clear (); things_create (); duration = 0; led_set (LED1, 1); break; case GAME_RUNNING: game_state = GAME_PAUSED; led_set (LED1, 0); break; case GAME_PAUSED: game_state = GAME_RUNNING; led_set (LED1, 1); break; } } if (game_state == GAME_RUNNING && things_killed_p ()) { char buffer[6]; game_state = GAME_WAIT; led_set (LED1, 0); sprintf (buffer, "%d", duration); tinygl_text (buffer); } }
void lcd_backlight(u08 val) { #ifdef LED_CODE // control backlight via LED interface led_set(5, val); //!!! treating LED1 as a power light. //!!! if backlight is off, make it bright //!!! if backlight is on, make it dim if(val == LED_OFF) led_set(1, LED_ON); else led_set(1, LED_DIM); #else // direct backlight control if(val == 0) { sbi(DDRC, 2); cbi(PORTC, 2); } else { sbi(DDRC, 2); sbi(PORTC, 2); } #endif }
static inline void led_set_trigger(int blink) { if (blink == led_state) return; if (blink) { led_set("trigger", "timer"); } else { led_set("trigger", "netdev"); led_set("device_name", "ra0"); led_set("mode", "tx"); } blink = led_state; }
void led_ok(unsigned char n) { led_init(); for(unsigned char i=0; i<n; i++) { _delay_ms(LED_TIME); led_set(1,1); led_enact(); _delay_ms(LED_TIME); led_set(1,0); led_enact(); } _delay_ms(LED_TIME); }
void led_init() { // turn on LEDs (max) led_setPWM(LED_RED, LED_MAX_PWM); led_setPWM(LED_GREEN, LED_MAX_PWM); led_setPWM(LED_BLUE, LED_MAX_PWM); // wait for things to settle... delayus(20000); // get current of each led. This is needed because each LED has a different forward voltage. But current determines // brightness regardless of voltage drop. So we normalize with respect to current for best color accuracy. g_ledOnCurrent[LED_RED] = (float)adc_get(LED_RED_ADCCHAN)/ADC_MAX*ADC_VOLTAGE/LED_RED_RESISTOR; g_ledOnCurrent[LED_GREEN] = (float)adc_get(LED_GREEN_ADCCHAN)/ADC_MAX*ADC_VOLTAGE/LED_GREEN_RESISTOR; g_ledOnCurrent[LED_BLUE] = (float)adc_get(LED_BLUE_ADCCHAN)/ADC_MAX*ADC_VOLTAGE/LED_BLUE_RESISTOR; g_ledVal[LED_RED] = 0xff; g_ledVal[LED_GREEN] = 0xff; g_ledVal[LED_BLUE] = 0xff; // turn off LEDs led_set(0); // set other vals... g_ledScale = LED_DEFAULT_SCALE; led_setMaxCurrent(LED_DEFAULT_MAX_CURRENT); g_chirpUsb->registerModule(g_module); }