Files
Upsilon/apps/usb_timer.cpp
Émilie Feral 4c4dd4b33d [apps] Set the backlight brightness at maximum when plugging the USB
Change-Id: If544eaa5b34fecc1117beb82909f1f5c8a82760f
2017-05-23 15:58:54 +02:00

37 lines
989 B
C++

#include "usb_timer.h"
#include "global_preferences.h"
#include "apps_container.h"
USBTimer::USBTimer(AppsContainer * container) :
Timer(1),
m_container(container),
m_previousPluggedState(false)
{
}
bool USBTimer::fire() {
bool needRedrawing = false;
if (Ion::USB::isPlugged()) {
if (!m_previousPluggedState && GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) {
m_container->displayExamModePopUp(false);
needRedrawing = true;
}
#if LED_WHILE_CHARGING
KDColor LEDColor = Ion::Battery::isCharging() ? KDColorYellow : KDColorGreen;
Ion::LED::setColor(LEDColor);
#endif
if (!m_previousPluggedState) {
Ion::Backlight::setBrightness(Ion::Backlight::MaxBrightness);
}
m_previousPluggedState = true;
} else {
if (m_previousPluggedState) {
#if LED_WHILE_CHARGING
Ion::LED::setColor(KDColorBlack);
#endif
m_previousPluggedState = false;
}
}
return needRedrawing;
}