diff --git a/apps/apps_container.cpp b/apps/apps_container.cpp index 776153935..c352f44c4 100644 --- a/apps/apps_container.cpp +++ b/apps/apps_container.cpp @@ -4,6 +4,7 @@ #include #include #include +#include extern "C" { #include @@ -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; } diff --git a/apps/settings/main_controller.cpp b/apps/settings/main_controller.cpp index 59ac61ca8..12419bc55 100644 --- a/apps/settings/main_controller.cpp +++ b/apps/settings/main_controller.cpp @@ -2,6 +2,7 @@ #include "../global_preferences.h" #include #include +#include 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) { diff --git a/ion/include/ion/backlight.h b/ion/include/ion/backlight.h index cd69ee888..89a19687c 100644 --- a/ion/include/ion/backlight.h +++ b/ion/include/ion/backlight.h @@ -12,6 +12,7 @@ bool isInitialized(); void shutdown(); void setBrightness(uint8_t b); uint8_t brightness(); +const int NumberOfStepsPerShortcut = 4; } } diff --git a/ion/include/ion/events.h b/ion/include/ion/events.h index 1ce72c76d..92905e9ca 100644 --- a/ion/include/ion/events.h +++ b/ion/include/ion/events.h @@ -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); diff --git a/ion/include/ion/keyboard/layout_B2/layout_events.h b/ion/include/ion/keyboard/layout_B2/layout_events.h index a0d877cd5..3a1f75260 100644 --- a/ion/include/ion/keyboard/layout_B2/layout_events.h +++ b/ion/include/ion/keyboard/layout_B2/layout_events.h @@ -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, diff --git a/ion/include/ion/keyboard/layout_B3/layout_events.h b/ion/include/ion/keyboard/layout_B3/layout_events.h index 1783ff7a3..a1f9502fa 100644 --- a/ion/include/ion/keyboard/layout_B3/layout_events.h +++ b/ion/include/ion/keyboard/layout_B3/layout_events.h @@ -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,