mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps] Add LED switch on/off to usb timer
Change-Id: I6685ab5e21829eb9f2751819b635177a4955d403
This commit is contained in:
@@ -17,7 +17,6 @@ app_objs += $(addprefix apps/,\
|
||||
battery_view.o\
|
||||
constant.o\
|
||||
global_preferences.o\
|
||||
exam_mode_timer.o\
|
||||
exam_pop_up_controller.o\
|
||||
i18n.o\
|
||||
led_timer.o\
|
||||
@@ -26,6 +25,7 @@ app_objs += $(addprefix apps/,\
|
||||
node.o\
|
||||
title_bar_view.o\
|
||||
toolbox_node.o\
|
||||
usb_timer.o\
|
||||
variable_box_controller.o\
|
||||
variable_box_leaf_cell.o\
|
||||
)
|
||||
|
||||
@@ -26,7 +26,7 @@ AppsContainer::AppsContainer() :
|
||||
m_examPopUpController(ExamPopUpController()),
|
||||
m_ledTimer(LedTimer()),
|
||||
m_batteryTimer(BatteryTimer(this)),
|
||||
m_examModeTimer(ExamModeTimer(this))
|
||||
m_USBTimer(USBTimer(this))
|
||||
{
|
||||
refreshPreferences();
|
||||
}
|
||||
@@ -128,7 +128,7 @@ Timer * AppsContainer::timerAtIndex(int i) {
|
||||
case 0:
|
||||
return &m_batteryTimer;
|
||||
case 1:
|
||||
return &m_examModeTimer;
|
||||
return &m_USBTimer;
|
||||
case 2:
|
||||
return &m_ledTimer;
|
||||
default:
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "exam_pop_up_controller.h"
|
||||
#include "led_timer.h"
|
||||
#include "battery_timer.h"
|
||||
#include "exam_mode_timer.h"
|
||||
#include "usb_timer.h"
|
||||
|
||||
#define USE_PIC_VIEW_APP 0
|
||||
#if USE_PIC_VIEW_APP
|
||||
@@ -62,7 +62,7 @@ private:
|
||||
ExamPopUpController m_examPopUpController;
|
||||
LedTimer m_ledTimer;
|
||||
BatteryTimer m_batteryTimer;
|
||||
ExamModeTimer m_examModeTimer;
|
||||
USBTimer m_USBTimer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#include "exam_mode_timer.h"
|
||||
#include "global_preferences.h"
|
||||
#include "apps_container.h"
|
||||
|
||||
ExamModeTimer::ExamModeTimer(AppsContainer * container) :
|
||||
Timer(3),
|
||||
m_container(container),
|
||||
m_previousPluggedState(false)
|
||||
{
|
||||
}
|
||||
|
||||
void ExamModeTimer::fire() {
|
||||
if (!m_previousPluggedState && Ion::USB::isPlugged() && GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) {
|
||||
m_container->displayExamModePopUp(false, true);
|
||||
m_previousPluggedState = true;
|
||||
}
|
||||
if (m_previousPluggedState && !Ion::USB::isPlugged()) {
|
||||
m_previousPluggedState = false;
|
||||
}
|
||||
}
|
||||
24
apps/usb_timer.cpp
Normal file
24
apps/usb_timer.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "usb_timer.h"
|
||||
#include "global_preferences.h"
|
||||
#include "apps_container.h"
|
||||
|
||||
USBTimer::USBTimer(AppsContainer * container) :
|
||||
Timer(2),
|
||||
m_container(container),
|
||||
m_previousPluggedState(false)
|
||||
{
|
||||
}
|
||||
|
||||
void USBTimer::fire() {
|
||||
if (Ion::USB::isPlugged()) {
|
||||
if (!m_previousPluggedState && GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) {
|
||||
m_container->displayExamModePopUp(false, true);
|
||||
}
|
||||
KDColor LEDColor = Ion::Battery::isCharging() ? KDColorBlue : KDColorGreen;
|
||||
Ion::LED::setColor(LEDColor);
|
||||
m_previousPluggedState = true;
|
||||
} else {
|
||||
Ion::LED::setColor(KDColorBlack);
|
||||
m_previousPluggedState = false;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
#ifndef APPS_EXAM_MODE_TIMER_H
|
||||
#define APPS_EXAM_MODE_TIMER_H
|
||||
#ifndef APPS_USB_TIMER_H
|
||||
#define APPS_USB_TIMER_H
|
||||
|
||||
#include <escher.h>
|
||||
|
||||
class AppsContainer;
|
||||
|
||||
class ExamModeTimer : public Timer {
|
||||
class USBTimer : public Timer {
|
||||
public:
|
||||
ExamModeTimer(AppsContainer * container);
|
||||
USBTimer(AppsContainer * container);
|
||||
private:
|
||||
void fire() override;
|
||||
AppsContainer * m_container;
|
||||
Reference in New Issue
Block a user