Files
Upsilon/apps/on_boarding/logo_controller.cpp
Léa Saviot 5e7731c34d [apps/on_boarding] Reset LED only if POST was performed
Fixes LED color bug in the following scenario:
Plug the device, reset, back, unplug the device, select language
-> The led is lit up
2019-04-30 15:40:47 +02:00

56 lines
1.8 KiB
C++

#include "logo_controller.h"
#include "power_on_self_test.h"
#include <ion/led.h>
namespace OnBoarding {
LogoController::LogoController() :
ViewController(nullptr),
Timer(15),
m_logoView(),
m_previousLEDColor(KDColorBlack),
m_didPerformTests(false)
{
}
bool LogoController::fire() {
app()->dismissModalViewController();
return true;
}
void LogoController::viewWillAppear() {
/* The backlight is already initialized if the on boarding has been
* interrupted by the "Calculator connected" pop up, in which case we do not
* want to perform the tests: we would need to shutdown the backlight so the
* tests are not visible, which would still be visible for the user. The
* interruption does not happen on the production line, and the tests are not
* mandatory for the end-user.*/
bool backlightInitialized = Ion::Backlight::isInitialized();
if (Ion::USB::isPlugged() || backlightInitialized) {
m_didPerformTests = false;
m_previousLEDColor = Ion::LED::getColor();
} else {
m_didPerformTests = true;
m_previousLEDColor = PowerOnSelfTest::Perform();
/* If EPSILON_ONBOARDING_APP == 1, the backlight is not initialized in
* Ion::Device::Board::initPeripherals, so that the LCD test is not visible to
* the user. We thus need to initialize the backlight after the test. Before,
* we push a white rect on the display to hide redrawing glitches. */
Ion::Display::pushRectUniform(KDRect(KDPointZero, Ion::Display::Width, Ion::Display::Height), KDColorWhite);
Ion::Timing::msleep(50);
}
if (!backlightInitialized) {
Ion::Backlight::init();
}
ViewController::viewWillAppear();
}
void LogoController::viewDidDisappear() {
if (m_didPerformTests) {
Ion::LED::setColor(m_previousLEDColor);
}
ViewController::viewDidDisappear();
}
}