Exemple #1
0
void menu_params_apply_remote_enable(const menuitem_t *item) {
	if(*item->parm.menuitem_enum.value)
		remote_on();
	else
		remote_off();
}
Exemple #2
0
static void remote_thread(void)
{
    int rc_thread_sleep_count = 10;
    int rc_thread_wait_timeout = TIMEOUT_BLOCK;

    while (1)
    {
        semaphore_wait(&rc_thread_wakeup, rc_thread_wait_timeout);

        /* Error handling (most likely due to remote not present) */
        if (rc_status & RC_ERROR_MASK)
        {
            if (--rc_thread_sleep_count == 0)
                rc_status |= RC_POWER_OFF;
        }

        /* Power-off (thread sleeps) */
        if (rc_status & RC_POWER_OFF)
        {
            remote_off();

            rc_thread_sleep_count = 10;
            rc_thread_wait_timeout = TIMEOUT_BLOCK;

            continue;
        }

        /* Detection */
        if (!(rc_status & RC_DETECTED))
        {
            rc_thread_wait_timeout = HZ;

            if (headphones_inserted())
            {
                remote_on();

                if (rc_status & RC_AWAKE)
                {
                    rc_thread_sleep_count = 10;
                    rc_thread_wait_timeout = HZ/20; /* ~50ms for updates */
                }
            }
            else
            {
                if (--rc_thread_sleep_count == 0)
                    rc_status &= ~RC_POWER_OFF;
            }

            continue;
        }

        /* Update the remote (one per wakeup cycle) */
        if (headphones_inserted() && (rc_status & RC_AWAKE))
        {
            if (rc_status & RC_SCREEN_ON)
            {
                /* In order of importance */
                if (rc_status & RC_UPDATE_CONTROLLER)
                {
                    remote_update_controller();
                    rc_status &= ~RC_UPDATE_CONTROLLER;
                }
                else if (rc_status & RC_UPDATE_LCD)
                {
                    remote_update_lcd();
                    rc_status &= ~RC_UPDATE_LCD;
                }
                else
                {
                    remote_nop();
                }
            }
            else
            {
                remote_nop();
            }
        }
    }
}