Example #1
0
/* Read ambient light value from phones ALS and decide will the backlight be lit or not
 * Restart timer if timer was already running
 */
void Tohkbd::checkDoWeNeedBacklight()
{
    if (forceBacklightOn)
    {
        printf("backlight forced on\n");

        tca8424->setLeds(LED_BACKLIGHT_ON);
    }
    else if (backlightEnabled)
    {
        if (!backlightTimer->isActive())
        {
            if (readOneLineFromFile("/sys/devices/virtual/input/input11/als_lux").toInt() < backlightLuxThreshold)
            {
                printf("backlight on\n");

                tca8424->setLeds(LED_BACKLIGHT_ON);
                backlightTimer->start();
            } else {
                tca8424->setLeds(LED_BACKLIGHT_OFF);
            }
        }
        else
        {
            backlightTimer->start();
        }
    }
    else
    {
        backlightTimer->stop();
        tca8424->setLeds(LED_BACKLIGHT_OFF);
    }
}
Example #2
0
/* Will check is keyboard still there
 */
void Tohkbd::presenceTimerTimeout()
{
    if (checkKeypadPresence())
    {
        presenceTimer->start();

        if (readOneLineFromFile("/sys/class/gpio/gpio" GPIO_INT "/value") == "0")
        {
            printf("checkKeypadPresence: interrupt is active, trying to handle it now.\n");
            handleGpioInterrupt();
        }
    }
}
Example #3
0
/* Key repeat timer timeout. Re-handle key pressed, if key still pressed.
 */
void Tohkbd::repeatTimerTimeout()
{
    if (!keyRepeat)
    {
        /* Check is the interrupt stuck down on first repeat timer timeout*/
        if (readOneLineFromFile("/sys/class/gpio/gpio" GPIO_INT "/value") == "0")
        {
            printf("repeatTimerTimeout: interrupt is active, trying to handle it now.\n");
            handleGpioInterrupt();
            return;
        }
    }

    keyRepeat = true;
    handleKeyPressed(lastKeyCode);

    /* Keep backlight on when repeating if it was turned on when key pressed first time */
    if (backlightTimer->isActive())
        backlightTimer->start();
}