mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-21 14:50:44 +01:00
Add natural dimer (#106)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "backlight_dimming_timer.h"
|
||||
#include "global_preferences.h"
|
||||
|
||||
BacklightDimmingTimer::BacklightDimmingTimer() :
|
||||
Timer(k_idleBeforeDimmingDuration/Timer::TickDuration)
|
||||
@@ -6,6 +7,33 @@ BacklightDimmingTimer::BacklightDimmingTimer() :
|
||||
}
|
||||
|
||||
bool BacklightDimmingTimer::fire() {
|
||||
Ion::Backlight::setBrightness(k_dimBacklightBrightness);
|
||||
if (m_dimerExecutions == 0) {
|
||||
m_brightnessLevel = GlobalPreferences::sharedGlobalPreferences()->brightnessLevel();
|
||||
m_dimerSteps = m_brightnessLevel / decreaseby;
|
||||
m_timeToSleep = decreasetime / m_dimerSteps;
|
||||
m_period = m_timeToSleep / Timer::TickDuration;
|
||||
if (m_period == 0) {
|
||||
m_period = 1;
|
||||
}
|
||||
resetTimer();
|
||||
}
|
||||
if (m_dimerExecutions < m_dimerSteps) {
|
||||
m_nextbrightness = (m_brightnessLevel-k_dimBacklightBrightness)/m_dimerSteps * (m_dimerSteps-m_dimerExecutions);
|
||||
Ion::Backlight::setBrightness(m_nextbrightness);
|
||||
resetTimer();
|
||||
} else if (m_dimerExecutions == m_dimerSteps) {
|
||||
Ion::Backlight::setBrightness(k_dimBacklightBrightness);
|
||||
}
|
||||
m_dimerExecutions++;
|
||||
return false;
|
||||
}
|
||||
|
||||
void BacklightDimmingTimer::reset() {
|
||||
m_dimerExecutions = 0;
|
||||
m_period = k_idleBeforeDimmingDuration / Timer::TickDuration;
|
||||
resetTimer();
|
||||
}
|
||||
|
||||
void BacklightDimmingTimer::resetTimer() {
|
||||
BacklightDimmingTimer::m_numberOfTicksBeforeFire = BacklightDimmingTimer::m_period;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user