/*! \fn activityDetectedRoutine(void) * \brief What to do when user activity has been detected */ void activityDetectedRoutine(void) { #ifdef HARDWARE_V1 return; #endif // Activate timers for automatic switch off activateTimer(TIMER_LIGHT, LIGHT_TIMER_DEL); activateTimer(TIMER_SCREEN, SCREEN_TIMER_DEL); // If the screen was off, turn it on! if (oledIsOn() == FALSE) { oledOn(); screenComingOnDelay(); } // If the lights were off, turn them on! if (areLightsOn == FALSE) { setPwmDc(MAX_PWM_VAL); activateGuardKey(); areLightsOn = TRUE; } }
/*! \fn activityDetectedRoutine(void) * \brief What to do when user activity has been detected */ void activityDetectedRoutine(void) { // Activate timers for automatic switch off & user interaction timeout activateTimer(TIMER_LIGHT, LIGHT_TIMER_DEL); activateTimer(TIMER_SCREEN, SCREEN_TIMER_DEL); activateTimer(SLOW_TIMER_LOCKOUT, getMooltipassParameterInEeprom(LOCK_TIMEOUT_PARAM)); activateTimer(TIMER_USERINT, ((uint16_t)controlEepromParameter(getMooltipassParameterInEeprom(USER_INTER_TIMEOUT_PARAM), MIN_USER_INTER_DEL/1000, MAX_USER_INTER_DEL/1000)) << 10); // If the screen was off, turn it on! if (oledIsOn() == FALSE) { oledOn(); screenComingOnDelay(); } // If we are in screen saver mode, exit it! if (screenSaverOn == TRUE) { screenSaverOn = FALSE; } // There are only lights in the Mooltipass standard version #if defined(HARDWARE_OLIVIER_V1) // If the lights were off, turn them on! if (areLightsOn == FALSE) { setPwmDc(MAX_PWM_VAL); activateGuardKey(); areLightsOn = TRUE; } #endif }
/*! \fn displayDebugStatusCode(char* text) * \brief Display a debug status code on the screen to help diagnose usb comms * \param text The text */ void displayDebugStatusCode(char* text) { if (oledIsOn() == TRUE) { oledWriteActiveBuffer(); oledPutstrXY(0, 0, OLED_LEFT, text); oledWriteInactiveBuffer(); } }
/*! \fn guiMainLoop(void) * \brief Main user interface loop */ void guiMainLoop(void) { RET_TYPE touch_detect_result; uint8_t isScreenOnCopy; #ifdef HARDWARE_V1 return; #endif // Set led mask depending on our current screen switch(getCurrentScreen()) { case SCREEN_DEFAULT_NINSERTED : currentLedMask = LED_MASK_LEFT|LED_MASK_RIGHT|LED_MASK_WHEEL; break; case SCREEN_DEFAULT_INSERTED_LCK : currentLedMask = LED_MASK_LEFT|LED_MASK_RIGHT|LED_MASK_WHEEL; break; case SCREEN_DEFAULT_INSERTED_NLCK : currentLedMask = LED_MASK_LEFT|LED_MASK_RIGHT; break; case SCREEN_DEFAULT_INSERTED_INVALID : currentLedMask = LED_MASK_LEFT|LED_MASK_RIGHT|LED_MASK_WHEEL; break; case SCREEN_SETTINGS : currentLedMask = LED_MASK_LEFT|LED_MASK_RIGHT; break; case SCREEN_MEMORY_MGMT : currentLedMask = LED_MASK_LEFT|LED_MASK_RIGHT|LED_MASK_WHEEL; break; default: break; } // Make a copy of the screen on bool isScreenOnCopy = oledIsOn(); // Launch touch detection routine to check for interactions touch_detect_result = touchDetectionRoutine(currentLedMask); // No activity, switch off LEDs and activate prox detection if (hasTimerExpired(TIMER_LIGHT, TRUE) == TIMER_EXPIRED) { setPwmDc(0x0000); areLightsOn = FALSE; activateProxDetection(); } // No activity, switch off screen if (hasTimerExpired(TIMER_SCREEN, TRUE) == TIMER_EXPIRED) { guiDisplayGoingToSleep(); userViewDelay(); oledFlipBuffers(0,0); #ifndef HARDWARE_V1 oledOff(); #endif } // If the screen just got turned on, don't call the guiScreenLoop() function if ((touch_detect_result & TOUCH_PRESS_MASK) && (isScreenOnCopy != FALSE)) { guiScreenLoop(touch_detect_result); } }
/*! \fn guiMainLoop(void) * \brief Main user interface loop */ void guiMainLoop(void) { RET_TYPE input_interface_result; uint8_t screenSaverOnCopy; uint8_t isScreenOnCopy; #if defined(HARDWARE_OLIVIER_V1) // Set led mask depending on our current screen switch(getCurrentScreen()) { case SCREEN_DEFAULT_NINSERTED : currentLedMask = LED_MASK_LEFT|LED_MASK_RIGHT|LED_MASK_WHEEL; break; case SCREEN_DEFAULT_INSERTED_LCK : currentLedMask = LED_MASK_LEFT|LED_MASK_RIGHT|LED_MASK_WHEEL; break; case SCREEN_DEFAULT_INSERTED_NLCK : currentLedMask = LED_MASK_LEFT|LED_MASK_RIGHT; break; case SCREEN_DEFAULT_INSERTED_INVALID : currentLedMask = LED_MASK_LEFT|LED_MASK_RIGHT|LED_MASK_WHEEL; break; case SCREEN_SETTINGS : currentLedMask = LED_MASK_LEFT|LED_MASK_RIGHT; break; case SCREEN_MEMORY_MGMT : currentLedMask = LED_MASK_LEFT|LED_MASK_RIGHT|LED_MASK_WHEEL; break; default: break; } #endif // Make a copy of the screen on & screensaver on bools screenSaverOnCopy = screenSaverOn; isScreenOnCopy = oledIsOn(); #if defined(HARDWARE_OLIVIER_V1) // Launch touch detection routine to check for interactions input_interface_result = touchDetectionRoutine(currentLedMask); #elif defined(MINI_VERSION) input_interface_result = miniGetWheelAction(FALSE, FALSE); #endif #if defined(HARDWARE_OLIVIER_V1) // No activity, switch off LEDs and activate prox detection if (hasTimerExpired(TIMER_LIGHT, TRUE) == TIMER_EXPIRED) { setPwmDc(0x0000); areLightsOn = FALSE; activateProxDetection(); } #endif // No activity, switch off screen if (hasTimerExpired(TIMER_SCREEN, TRUE) == TIMER_EXPIRED) { guiDisplayGoingToSleep(); userViewDelay(); if (getMooltipassParameterInEeprom(SCREENSAVER_PARAM) != FALSE) { screenSaverOn = TRUE; oledWriteInactiveBuffer(); oledClear(); oledDisplayOtherBuffer(); oledClear(); } else { oledDisplayOtherBuffer(); oledOff(); } } #if defined(HARDWARE_OLIVIER_V1) // If there was some activity and we are showing the screen saver if ((input_interface_result & TOUCH_PRESS_MASK) && (screenSaverOnCopy == TRUE)) { guiGetBackToCurrentScreen(); } // If the screen just got turned on, don't call the guiScreenLoop() function if ((input_interface_result & TOUCH_PRESS_MASK) && (((isScreenOnCopy != FALSE) && (screenSaverOnCopy == FALSE)) || (getCurrentScreen() == SCREEN_DEFAULT_INSERTED_LCK))) { guiScreenLoop(input_interface_result); } #elif defined(MINI_VERSION) // If there was some activity and we are showing the screen saver if ((input_interface_result != WHEEL_ACTION_NONE) && (screenSaverOnCopy == TRUE)) { guiGetBackToCurrentScreen(); } if ((input_interface_result != WHEEL_ACTION_NONE) && (((isScreenOnCopy != FALSE) && (screenSaverOnCopy == FALSE)) || (getCurrentScreen() == SCREEN_DEFAULT_INSERTED_LCK))) { guiScreenLoop(input_interface_result); } #endif }