Exemplo n.º 1
0
/*
 * call back function to update tboot UI
 */
static void ui_callback(void *arg)
{
	char buf_usb[32];
	char buf_charger[32];
	char buf_bat[32];
	int status;
	static saved_usb_status = STATUS_UNKOWN;
	static saved_charger_status = STATUS_UNKOWN;

	status = usb_status();
	if (status == STATUS_UNKOWN)
		snprintf(buf_usb, sizeof(buf_usb), "USB: Unknow");
	else
		snprintf(buf_usb, sizeof(buf_usb), "USB: %s",
				status == STATUS_CONNECTED ?
				"connected" : "disconnected");
	if (saved_usb_status != status) {
		RESET_ALARM;
		lcd_state = (lcd_state_t)lcd_state(LCD_USB_EVENT);
		saved_usb_status = status;
	}

	status = charger_status();
	if (status == STATUS_UNKOWN)
		snprintf(buf_charger, sizeof(buf_charger), "Charger: Unknow");
	else
		snprintf(buf_charger, sizeof(buf_charger), "Charger: %s",
				status == STATUS_CONNECTED ?
				"connected" : "disconnected");
	if (saved_charger_status != status) {
		RESET_ALARM;
		lcd_state = (lcd_state_t)lcd_state(LCD_USB_EVENT);
		saved_charger_status = status;
	}

	status = battery_capacity();
	if (status < 0)
		snprintf(buf_bat, sizeof(buf_bat), "Battery: Unknow");
	else
		snprintf(buf_bat, sizeof(buf_bat), "Battery: %d%%", status);

	tboot_ui_uevent("%s, %s, %s", buf_usb, buf_charger, buf_bat);
}
Exemplo n.º 2
0
static void usbled(int sig)
{
	usb_path1 = nvram_safe_get("usb_path1");
	usb_path2 = nvram_safe_get("usb_path2");
	status_usb_old = status_usb;
	status_usb = usb_status();

#ifdef LED_USB3
	if(model==MODEL_RTAC56U || model==MODEL_RTAC68U){
                got_usb2_old = got_usb2;
                got_usb2 = check_usb2();
                got_usb3_old = got_usb3;
                got_usb3 = check_usb3();
	}
#endif

	if(nvram_match("asus_mfg", "1")
#ifdef RTCONFIG_USBEJECT
                || !nvram_get_int("AllLED")
#endif
        )
		no_blink(sig);
	else if (!usb_busy
#ifdef RTCONFIG_USBEJECT
                && nvram_get_int("AllLED")
#endif
	)
	{
                if(model==MODEL_RTAC56U || model==MODEL_RTAC68U){
                        if(got_usb2 != got_usb2_old){
                                if(got_usb2)
                                        led_control(LED_USB, LED_ON);
                                else
                                        led_control(LED_USB, LED_OFF);
                        }
#ifdef LED_USB3
                        if(got_usb3 != got_usb3_old){
                                if(got_usb3)
                                        led_control(LED_USB3, LED_ON);
                                else
                                        led_control(LED_USB3, LED_OFF);
                        }
#endif
                }
		else if (status_usb != status_usb_old)
		{
			if (status_usb)
				led_control(LED_USB, LED_ON);
			else
				led_control(LED_USB, LED_OFF);
		}
	}
	else
#ifdef RTCONFIG_USBEJECT
                if (nvram_get_int("AllLED"))
#endif
	{
		if (strcmp(usb_path1, "storage") && strcmp(usb_path2, "storage"))
		{
			no_blink(sig);
		}
		else
		{
			count = (count+1) % 20;

			/* 0123456710 */
			/* 1010101010 */
			if (((count % 2) == 0) && (count > 8))
				led_control(LED_USB, LED_ON);
			else
				led_control(LED_USB, LED_OFF);
			alarmtimer(0, USBLED_URGENT_PERIOD);
		}
	}
}