diff --git a/apps/calculation/edit_expression_controller.cpp b/apps/calculation/edit_expression_controller.cpp index f3ee86ad3..5204515ef 100644 --- a/apps/calculation/edit_expression_controller.cpp +++ b/apps/calculation/edit_expression_controller.cpp @@ -1,6 +1,6 @@ #include "edit_expression_controller.h" -#include "app.h" #include "../apps_container.h" +#include "app.h" #include using namespace Shared; diff --git a/apps/hardware_test/keyboard_controller.cpp b/apps/hardware_test/keyboard_controller.cpp index 95cf5feea..c6e8d49ae 100644 --- a/apps/hardware_test/keyboard_controller.cpp +++ b/apps/hardware_test/keyboard_controller.cpp @@ -18,13 +18,14 @@ View * KeyboardController::view() { } bool KeyboardController::handleEvent(Ion::Events::Event event) { - Ion::LED::setColor(m_color); + m_view.updateLEDState(m_color); m_color = nextColor(m_color); m_view.updateBatteryState(Ion::Battery::voltage(), Ion::Battery::isCharging()); if (event != Ion::Events::Event::PlainKey(m_view.testedKey()) && event != Ion::Events::Event::ShiftKey(m_view.testedKey()) && event != Ion::Events::Event::AlphaKey(m_view.testedKey()) && event != Ion::Events::Event::ShiftAlphaKey(m_view.testedKey())) { m_view.setDefectiveKey(m_view.testedKey()); } if (!m_view.setNextKey()) { + m_view.updateLEDState(KDColorBlack); AppsContainer * container = (AppsContainer *)app()->container(); container->switchTo(container->appAtIndex(0)); } @@ -32,8 +33,9 @@ bool KeyboardController::handleEvent(Ion::Events::Event event) { } void KeyboardController::viewWillAppear() { - m_color = KDColorBlack; m_view.resetTestedKey(); + m_color = KDColorBlack; + m_view.updateLEDState(m_color); m_view.updateBatteryState(Ion::Battery::voltage(), Ion::Battery::isCharging()); } diff --git a/apps/hardware_test/keyboard_view.cpp b/apps/hardware_test/keyboard_view.cpp index e1d597dc7..c89896ec2 100644 --- a/apps/hardware_test/keyboard_view.cpp +++ b/apps/hardware_test/keyboard_view.cpp @@ -9,7 +9,8 @@ namespace HardwareTest { KeyboardView::KeyboardView() : m_testedKey(Ion::Keyboard::Key::A1), m_batteryLevelView(BufferTextView(KDText::FontSize::Small)), - m_batteryChargingView(BufferTextView(KDText::FontSize::Small)) + m_batteryChargingView(BufferTextView(KDText::FontSize::Small)), + m_ledStateView(BufferTextView(KDText::FontSize::Small)) { for (int i = 0; i < Ion::Keyboard::NumberOfKeys; i++) { m_defectiveKey[i] = 0; @@ -46,6 +47,34 @@ void KeyboardView::resetTestedKey() { markRectAsDirty(bounds()); } +void KeyboardView::updateLEDState(KDColor color) { + Ion::LED::setColor(color); + + char ledLevel[k_maxNumberOfCharacters]; + const char * legend = "LED color: "; + int legendLength = strlen(legend); + int numberOfChar = legendLength; + strlcpy(ledLevel, legend, legendLength+1); + legend = "Off"; + if (color == KDColorWhite) { + legend = "White"; + } + if (color == KDColorRed) { + legend = "Red"; + } + if (color == KDColorBlue) { + legend = "Blue"; + } + if (color == KDColorGreen) { + legend = "Green"; + } + legendLength = strlen(legend); + strlcpy(ledLevel+numberOfChar, legend, legendLength+1); + m_ledStateView.setText(ledLevel); + + markRectAsDirty(bounds()); +} + void KeyboardView::updateBatteryState(float batteryLevel, bool batteryCharging) { char bufferLevel[k_maxNumberOfCharacters + Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; const char * legend = "Battery level: "; @@ -127,17 +156,21 @@ void KeyboardView::layoutSubviews() { KDSize textSize = KDText::stringSize(" ", KDText::FontSize::Small); m_batteryLevelView.setFrame(KDRect(130, k_margin, bounds().width()-130, textSize.height())); m_batteryChargingView.setFrame(KDRect(130, k_margin+2*textSize.height(), bounds().width()-130, textSize.height())); + m_ledStateView.setFrame(KDRect(130, k_margin+5*textSize.height(), bounds().width()-130, textSize.height())); } int KeyboardView::numberOfSubviews() const { - return 2; + return 3; } View * KeyboardView::subviewAtIndex(int index) { if (index == 0) { return &m_batteryLevelView; } - return &m_batteryChargingView; + if (index == 1) { + return &m_batteryChargingView; + } + return &m_ledStateView; } } diff --git a/apps/hardware_test/keyboard_view.h b/apps/hardware_test/keyboard_view.h index b3e02b6d5..d2a49ddc1 100644 --- a/apps/hardware_test/keyboard_view.h +++ b/apps/hardware_test/keyboard_view.h @@ -12,6 +12,7 @@ public: void setDefectiveKey(Ion::Keyboard::Key key); bool setNextKey(); void resetTestedKey(); + void updateLEDState(KDColor color); void updateBatteryState(float batteryLevel, bool batteryCharging); void drawRect(KDContext * ctx, KDRect rect) const override; private: @@ -26,11 +27,12 @@ private: constexpr static int k_smallRectWidth = 16; constexpr static int k_bigRectHeight = 14; constexpr static int k_bigRectWidth = 20; - constexpr static int k_maxNumberOfCharacters = 15; + constexpr static int k_maxNumberOfCharacters = 20; Ion::Keyboard::Key m_testedKey; int m_defectiveKey[Ion::Keyboard::NumberOfKeys]; BufferTextView m_batteryLevelView; BufferTextView m_batteryChargingView; + BufferTextView m_ledStateView; }; }