Merge branch 'KeyBrightness' of https://github.com/RedGl0w/Epsilon-Omega into RedGl0w-KeyBrightness

This commit is contained in:
Quentin Guidée
2019-12-08 22:01:20 +01:00
6 changed files with 26 additions and 6 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>
@@ -218,6 +219,11 @@ bool AppsContainer::processEvent(Ion::Events::Event event) {
suspend(true);
return true;
}
if (event == Ion::Events::BrightnessPlus || event == Ion::Events::BrightnessMinus) {
int delta = Ion::Backlight::MaxBrightness/GlobalPreferences::NumberOfBrightnessStates;
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

@@ -2,6 +2,7 @@
#include "../global_preferences.h"
#include <apps/i18n.h>
#include <assert.h>
#include <ion/backlight.h>
using namespace Poincare;
@@ -36,6 +37,13 @@ void MainController::didBecomeFirstResponder() {
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) ? Ion::Backlight::NumberOfStepsPerShortcut*delta : -delta*Ion::Backlight::NumberOfStepsPerShortcut;
GlobalPreferences::sharedGlobalPreferences()->setBrightnessLevel(GlobalPreferences::sharedGlobalPreferences()->brightnessLevel()+direction);
m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), 1);
return true;
}
if (model()->children(selectedRow())->numberOfChildren() == 0) {
if (model()->children(selectedRow())->label() == promptMessage()) {
if (event == Ion::Events::OK || event == Ion::Events::EXE) {

View File

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

View File

@@ -139,6 +139,11 @@ constexpr Event Equal = Event::ShiftKey(Keyboard::Key::Pi);
constexpr Event Lower = Event::ShiftKey(Keyboard::Key::Sqrt);
constexpr Event Greater = Event::ShiftKey(Keyboard::Key::Square);
constexpr Event BrightnessPlus = Event::ShiftKey(Keyboard::Key::Plus);
constexpr Event BrightnessMinus = Event::ShiftKey(Keyboard::Key::Minus);
constexpr Event DoubleParenthesis = Event::ShiftKey(Keyboard::Key::LeftParenthesis);
constexpr Event ShiftSeven = Event::ShiftKey(Keyboard::Key::Seven);
constexpr Event ShiftEight = Event::ShiftKey(Keyboard::Key::Eight);
constexpr Event ShiftNine = Event::ShiftKey(Keyboard::Key::Nine);

View File

@@ -25,9 +25,9 @@ static constexpr EventData s_dataForEvent[4*Event::PageSize] = {
U(), U(), TL(), TL(), TL(), TL(),
T("["), T("]"), T("{"), T("}"), T("_"), T(""),
T("asin(\x11)"), T("acos(\x11)"), T("atan(\x11)"), T("="), T("<"), T(">"),
TL(), TL(), TL(), T("(\x11)"), U(), U(),
TL(), TL(), TL(), U(), U(), U(),
TL(), TL(), TL(), U(), U(), U(),
TL(), TL(), TL(), U(), U(), U(),
TL(), TL(), TL(), TL(), TL(), U(),
U(), U(), U(), U(), U(), U(),
// Alpha
U(), U(), U(), U(), U(), U(),
@@ -70,9 +70,9 @@ static constexpr const char * s_nameForEvent[255] = {
nullptr, "AlphaLock", "Cut", "Copy", "Paste", "Clear",
"LeftBracket", "RightBracket", "LeftBrace", "RightBrace", "Underscore", "Sto",
"Arcsine", "Arccosine", "Arctangent", "Equal", "Lower", "Greater",
nullptr, nullptr, nullptr, nullptr, "DoubleParenthesis", nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, "BrightnessPlus", "BrightnessMinus", nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
//Alpha,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,

View File

@@ -27,7 +27,7 @@ static constexpr EventData s_dataForEvent[4*Event::PageSize] = {
T("asin(\x11)"), T("acos(\x11)"), T("atan(\x11)"), T("="), T("<"), T(">"),
TL(), TL(), TL(), U(), U(), U(),
TL(), TL(), TL(), U(), U(), U(),
TL(), TL(), TL(), U(), U(), U(),
TL(), TL(), TL(), TL(), TL(), U(),
U(), U(), U(), U(), U(), U(),
// Alpha
U(), U(), U(), U(), U(), U(),
@@ -72,7 +72,7 @@ static constexpr const char * s_nameForEvent[255] = {
"Arcsine", "Arccosine", "Arctangent", "Equal", "Lower", "Greater",
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, "BrightnessPlus", "BrightnessMinus", nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
//Alpha,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,