Simplified code

This commit is contained in:
RedGl0w
2019-12-08 18:18:28 +01:00
parent f6aab242a2
commit 1442e6977d
5 changed files with 5 additions and 4 deletions

View File

@@ -4,6 +4,7 @@
#include <ion.h>
#include <poincare/init.h>
#include <poincare/exception_checkpoint.h>
#include <ion/backlight.h>
extern "C" {
#include <assert.h>
@@ -220,7 +221,7 @@ bool AppsContainer::processEvent(Ion::Events::Event event) {
}
if (event == Ion::Events::BrightnessPlus || event == Ion::Events::BrightnessMinus) {
int delta = Ion::Backlight::MaxBrightness/GlobalPreferences::NumberOfBrightnessStates;
int direction = (event == Ion::Events::BrightnessPlus) ? NumberOfStepsForShiftPlusMinus*delta : -delta*NumberOfStepsForShiftPlusMinus;
int direction = (event == Ion::Events::BrightnessPlus) ? Ion::Backlight::NumberOfStepsPerShortcut*delta : -delta*Ion::Backlight::NumberOfStepsPerShortcut;
GlobalPreferences::sharedGlobalPreferences()->setBrightnessLevel(GlobalPreferences::sharedGlobalPreferences()->brightnessLevel()+direction);
}
return false;

View File

@@ -78,7 +78,6 @@ private:
OnBoarding::App::Snapshot m_onBoardingSnapshot;
HardwareTest::App::Snapshot m_hardwareTestSnapshot;
USB::App::Snapshot m_usbConnectedSnapshot;
const int NumberOfStepsForShiftPlusMinus = 3;
};
#endif

View File

@@ -2,6 +2,7 @@
#include "../global_preferences.h"
#include <apps/i18n.h>
#include <assert.h>
#include <ion/backlight.h>
using namespace Poincare;
@@ -38,7 +39,7 @@ bool MainController::handleEvent(Ion::Events::Event event) {
GlobalPreferences * globalPreferences = GlobalPreferences::sharedGlobalPreferences();
if (event == Ion::Events::BrightnessPlus || event == Ion::Events::BrightnessMinus){
int delta = Ion::Backlight::MaxBrightness/GlobalPreferences::NumberOfBrightnessStates;
int direction = (event == Ion::Events::BrightnessPlus) ? NumberOfStepsForShiftPlusMinus*delta : -delta*NumberOfStepsForShiftPlusMinus;
int direction = (event == Ion::Events::BrightnessPlus) ? Ion::Backlight::NumberOfStepsPerShortcut*delta : -delta*Ion::Backlight::NumberOfStepsPerShortcut;
GlobalPreferences::sharedGlobalPreferences()->setBrightnessLevel(GlobalPreferences::sharedGlobalPreferences()->brightnessLevel()+direction);
m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), 1);
return true;

View File

@@ -42,7 +42,6 @@ private:
AccessibilityController m_accessibilityController;
ExamModeController m_examModeController;
AboutController m_aboutController;
const int NumberOfStepsForShiftPlusMinus = 3;
};
}

View File

@@ -12,6 +12,7 @@ bool isInitialized();
void shutdown();
void setBrightness(uint8_t b);
uint8_t brightness();
const int NumberOfStepsPerShortcut = 4;
}
}