mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps] Timers access the shared container directly
This commit is contained in:
committed by
EmilieNumworks
parent
652cbae9ac
commit
5548767809
@@ -64,8 +64,8 @@ AppsContainer::AppsContainer() :
|
|||||||
#elif EPSILON_BOOT_PROMPT == EPSILON_UPDATE_PROMPT
|
#elif EPSILON_BOOT_PROMPT == EPSILON_UPDATE_PROMPT
|
||||||
m_promptController(sPromptMessages, sPromptColors, 6),
|
m_promptController(sPromptMessages, sPromptColors, 6),
|
||||||
#endif
|
#endif
|
||||||
m_batteryTimer(BatteryTimer(this)),
|
m_batteryTimer(),
|
||||||
m_suspendTimer(SuspendTimer(this)),
|
m_suspendTimer(),
|
||||||
m_backlightDimmingTimer(),
|
m_backlightDimmingTimer(),
|
||||||
m_homeSnapshot(),
|
m_homeSnapshot(),
|
||||||
m_onBoardingSnapshot(),
|
m_onBoardingSnapshot(),
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
#include "battery_timer.h"
|
#include "battery_timer.h"
|
||||||
#include "apps_container.h"
|
#include "apps_container.h"
|
||||||
|
|
||||||
BatteryTimer::BatteryTimer(AppsContainer * container) :
|
BatteryTimer::BatteryTimer() :
|
||||||
Timer(1),
|
Timer(1)
|
||||||
m_container(container)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BatteryTimer::fire() {
|
bool BatteryTimer::fire() {
|
||||||
bool needRedrawing = m_container->updateBatteryState();
|
AppsContainer * container = AppsContainer::sharedAppsContainer();
|
||||||
|
bool needRedrawing = container->updateBatteryState();
|
||||||
if (Ion::Battery::level() == Ion::Battery::Charge::EMPTY) {
|
if (Ion::Battery::level() == Ion::Battery::Charge::EMPTY) {
|
||||||
m_container->shutdownDueToLowBattery();
|
container->shutdownDueToLowBattery();
|
||||||
}
|
}
|
||||||
return needRedrawing;
|
return needRedrawing;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,11 @@
|
|||||||
|
|
||||||
#include <escher.h>
|
#include <escher.h>
|
||||||
|
|
||||||
class AppsContainer;
|
|
||||||
|
|
||||||
class BatteryTimer : public Timer {
|
class BatteryTimer : public Timer {
|
||||||
public:
|
public:
|
||||||
BatteryTimer(AppsContainer * container);
|
BatteryTimer();
|
||||||
private:
|
private:
|
||||||
bool fire() override;
|
bool fire() override;
|
||||||
AppsContainer * m_container;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
#include "suspend_timer.h"
|
#include "suspend_timer.h"
|
||||||
#include "apps_container.h"
|
#include "apps_container.h"
|
||||||
|
|
||||||
SuspendTimer::SuspendTimer(AppsContainer * container) :
|
SuspendTimer::SuspendTimer() :
|
||||||
Timer(k_idleBeforeSuspendDuration/Timer::TickDuration),
|
Timer(k_idleBeforeSuspendDuration/Timer::TickDuration)
|
||||||
m_container(container)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SuspendTimer::fire() {
|
bool SuspendTimer::fire() {
|
||||||
/* We could just call m_container->suspend(), but we want to notify all
|
/* We could just call container->suspend(), but we want to notify all
|
||||||
* responders in the responder chain that the calculator will be switched off,
|
* responders in the responder chain that the calculator will be switched off,
|
||||||
* so we use an event to switch off the calculator. */
|
* so we use an event to switch off the calculator. */
|
||||||
m_container->dispatchEvent(Ion::Events::OnOff);
|
AppsContainer * container = AppsContainer::sharedAppsContainer();
|
||||||
|
container->dispatchEvent(Ion::Events::OnOff);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,12 @@
|
|||||||
|
|
||||||
#include <escher.h>
|
#include <escher.h>
|
||||||
|
|
||||||
class AppsContainer;
|
|
||||||
|
|
||||||
class SuspendTimer : public Timer {
|
class SuspendTimer : public Timer {
|
||||||
public:
|
public:
|
||||||
SuspendTimer(AppsContainer * container);
|
SuspendTimer();
|
||||||
private:
|
private:
|
||||||
constexpr static int k_idleBeforeSuspendDuration = 5*60*1000; // In miliseconds
|
constexpr static int k_idleBeforeSuspendDuration = 5*60*1000; // In miliseconds
|
||||||
bool fire() override;
|
bool fire() override;
|
||||||
AppsContainer * m_container;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user