static int btn_check_wlt(void) { unsigned int i_button_value = !BTN_PRESSED; #if defined (BOARD_GPIO_BTN_RESET) /* check RESET pressed */ if (btn_count_reset > 0) return 0; #endif #if defined (BOARD_GPIO_BTN_WPS) /* check WPS pressed */ if (btn_count_wps > 0) return 0; #endif if (cpu_gpio_get_pin(BOARD_GPIO_BTN_WLTOG, &i_button_value) < 0) return 0; if (i_button_value == BTN_PRESSED) { /* WLTOG pressed */ btn_count_wlt++; #if defined (BOARD_GPIO_LED_POWER) /* flash power LED */ if (btn_count_wlt > BTN_EZ_WAIT_COUNT) { int i_led = get_state_led_pwr(); cpu_gpio_set_pin(BOARD_GPIO_LED_POWER, (btn_count_wlt % 2) ? i_led : !i_led); } #endif } else { /* WLTOG released */ int press_count = btn_count_wlt; btn_count_wlt = 0; if (press_count > BTN_EZ_WAIT_COUNT) { /* pressed >= 3sec */ wd_alarmtimer(0, 0); ez_event_long(1); } else if (press_count > 0 && press_count < BTN_EZ_CANCEL_COUNT) { /* pressed < 500ms */ wd_alarmtimer(0, 0); ez_event_short(1); } } return (i_button_value != BTN_PRESSED) ? 0 : 1; }
static void btn_check_ez(void) { #if defined(BTN_WPS) int i_front_leds, i_led0, i_led1; unsigned int i_button_value = 1; // check RESET pressed if (btn_pressed_reset != 0) return; if (cpu_gpio_get_pin(BTN_WPS, &i_button_value) < 0) return; if (!i_button_value) { // WPS pressed i_front_leds = nvram_get_int("front_leds"); if (i_front_leds == 2 || i_front_leds == 4) { // POWER always OFF i_led0 = LED_ON; i_led1 = LED_OFF; } else { // POWER always ON i_led0 = LED_OFF; i_led1 = LED_ON; } if (btn_pressed_wps == 0) { btn_pressed_wps = 1; btn_count_wps = 0; alarmtimer(0, URGENT_PERIOD); // toggle power LED cpu_gpio_set_pin(LED_POWER, i_led0); } else { if (++btn_count_wps > WPS_WAIT_COUNT) { btn_pressed_wps = 2; } if (btn_pressed_wps == 2) { // flash power LED if (btn_count_wps % 2) cpu_gpio_set_pin(LED_POWER, i_led1); else cpu_gpio_set_pin(LED_POWER, i_led0); } } } else { // WPS released if (btn_pressed_wps == 1) { btn_pressed_wps = 0; btn_count_wps = 0; // pressed < 3sec ez_event_short(); } else if (btn_pressed_wps == 2) { btn_pressed_wps = 0; btn_count_wps = 0; // pressed >= 3sec ez_event_long(); } } #endif }