diff --git a/apps/hardware_test/Makefile b/apps/hardware_test/Makefile index ba445bc73..8352f26b2 100644 --- a/apps/hardware_test/Makefile +++ b/apps/hardware_test/Makefile @@ -2,7 +2,6 @@ app_src += $(addprefix apps/hardware_test/,\ app.cpp \ arrow_view.cpp \ battery_test_controller.cpp \ - centered_screen_test_controller.cpp \ code_128b_view.cpp \ dead_pixels_test_controller.cpp \ keyboard_test_controller.cpp \ diff --git a/apps/hardware_test/app.cpp b/apps/hardware_test/app.cpp index 86f4dc10c..bfb0a7b68 100644 --- a/apps/hardware_test/app.cpp +++ b/apps/hardware_test/app.cpp @@ -21,7 +21,6 @@ App::App(Container * container, Snapshot * snapshot) : App::WizardViewController::WizardViewController(Responder * parentResponder) : BankViewController(parentResponder), m_batteryTestController(this), - m_centeredScreenTestController(this), m_deadPixelsTestController(this), m_keyboardController(this), m_lcdDataTestController(this), @@ -39,7 +38,6 @@ ViewController * App::WizardViewController::childAtIndex(int i) { ViewController * children[] = { &m_vBlankTestController, &m_lcdDataTestController, - &m_centeredScreenTestController, &m_deadPixelsTestController, &m_ledTestController, &m_keyboardController, diff --git a/apps/hardware_test/app.h b/apps/hardware_test/app.h index 628d75cd1..7e37d0505 100644 --- a/apps/hardware_test/app.h +++ b/apps/hardware_test/app.h @@ -3,7 +3,6 @@ #include #include "battery_test_controller.h" -#include "centered_screen_test_controller.h" #include "dead_pixels_test_controller.h" #include "keyboard_test_controller.h" #include "lcd_data_test_controller.h" @@ -31,7 +30,6 @@ private: bool handleEvent(Ion::Events::Event event) override; private: BatteryTestController m_batteryTestController; - CenteredScreenTestController m_centeredScreenTestController; DeadPixelsTestController m_deadPixelsTestController; KeyboardTestController m_keyboardController; LCDDataTestController m_lcdDataTestController; diff --git a/apps/hardware_test/centered_screen_test_controller.cpp b/apps/hardware_test/centered_screen_test_controller.cpp deleted file mode 100644 index 0472ab056..000000000 --- a/apps/hardware_test/centered_screen_test_controller.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "centered_screen_test_controller.h" - -namespace HardwareTest { - -void CenteredScreenTestController::ContentView::drawRect(KDContext * ctx, KDRect rect) const { - ctx->fillRect(rect, KDColorWhite); - ctx->fillRect(KDRect(k_outlineThickness, k_outlineThickness, bounds().width()-2*k_outlineThickness, bounds().height()-2*k_outlineThickness), KDColorBlack); -} - -} diff --git a/apps/hardware_test/centered_screen_test_controller.h b/apps/hardware_test/centered_screen_test_controller.h deleted file mode 100644 index b78839bbc..000000000 --- a/apps/hardware_test/centered_screen_test_controller.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef HARDWARE_TEST_CENTERED_SCREEN_TEST_CONTROLLER_H -#define HARDWARE_TEST_CENTERED_SCREEN_TEST_CONTROLLER_H - -#include - -namespace HardwareTest { - -class CenteredScreenTestController : public ViewController { -public: - CenteredScreenTestController(Responder * parentResponder) : - ViewController(parentResponder), - m_view() - {} - View * view() override { return &m_view; } - bool handleEvent(Ion::Events::Event event) override { - // This will be handled by the WizardViewController - return false; - } -private: - class ContentView : public View { - public: - ContentView() {} - void drawRect(KDContext * ctx, KDRect rect) const override; - private: - constexpr static KDCoordinate k_outlineThickness = 1; - }; - - ContentView m_view; -}; - -} - -#endif - diff --git a/apps/hardware_test/code_128b_view.cpp b/apps/hardware_test/code_128b_view.cpp index 090708492..75d011ab6 100644 --- a/apps/hardware_test/code_128b_view.cpp +++ b/apps/hardware_test/code_128b_view.cpp @@ -6,6 +6,7 @@ constexpr uint16_t patterns[] = {0x6CC, 0x66C, 0x666, 0x498, 0x48C, 0x44C, 0x4C8 constexpr uint16_t startPattern = 0x690; constexpr uint16_t stopPattern = 0x18EB; +constexpr KDColor Code128BView::k_borderColor; Code128BView::Code128BView() : View(), @@ -93,7 +94,20 @@ void Code128BView::drawRect(KDContext * ctx, KDRect rect) const { drawPatternAt(ctx, stopPattern, &x, 13); drawQuietZoneAt(ctx, &x); - ctx->drawString(m_data, KDPointZero); + ctx->drawString(m_data, KDPoint(k_stringOffset, k_stringOffset)); + + // Draw a red border to test the screen centered position + ctx->fillRect(KDRect(0, 0, bounds().width(), k_outlineThickness), k_borderColor); + ctx->fillRect(KDRect(bounds().width() - k_outlineThickness, 0, k_outlineThickness, bounds().height()), k_borderColor); + ctx->fillRect(KDRect(0, bounds().height() - k_outlineThickness, bounds().width(), k_outlineThickness), k_borderColor); + ctx->fillRect(KDRect(0, 0, k_outlineThickness, bounds().height()), k_borderColor); + + KDColor enhanceColor = KDColorBlack; + ctx->fillRect(KDRect(k_outlineThickness, k_outlineThickness, bounds().width() - 2 * k_outlineThickness, 2 * k_outlineThickness), enhanceColor); + ctx->fillRect(KDRect(bounds().width() - 3*k_outlineThickness, k_outlineThickness, 2 * k_outlineThickness, bounds().height() - 2 * k_outlineThickness), enhanceColor); + ctx->fillRect(KDRect(k_outlineThickness, bounds().height() - 3 * k_outlineThickness, bounds().width()- 2 * k_outlineThickness, 2 * k_outlineThickness), enhanceColor); + ctx->fillRect(KDRect(k_outlineThickness, k_outlineThickness, 2 * k_outlineThickness, bounds().height()- 2 * k_outlineThickness), enhanceColor); + } } diff --git a/apps/hardware_test/code_128b_view.h b/apps/hardware_test/code_128b_view.h index 84f1ecd5f..c437e8e27 100644 --- a/apps/hardware_test/code_128b_view.h +++ b/apps/hardware_test/code_128b_view.h @@ -12,11 +12,14 @@ public: void setData(const char * data); void layoutSubviews() override; private: - static constexpr KDCoordinate charPatternWidth = 11; + static constexpr KDCoordinate k_outlineThickness = 1; + static constexpr KDCoordinate k_charPatternWidth = 11; + static constexpr KDCoordinate k_stringOffset = 3; + static constexpr KDColor k_borderColor = KDColorRed; void updateModuleWidth(); int checksum() const; void drawQuietZoneAt(KDContext * ctx, KDCoordinate * x) const; - void drawPatternAt(KDContext * ctx, uint16_t pattern, KDCoordinate * x, KDCoordinate width = charPatternWidth) const; + void drawPatternAt(KDContext * ctx, uint16_t pattern, KDCoordinate * x, KDCoordinate width = k_charPatternWidth) const; void drawCharAt(KDContext * ctx, char c, KDCoordinate * x) const; int m_moduleWidth; const char * m_data; diff --git a/apps/hardware_test/dead_pixels_test_controller.cpp b/apps/hardware_test/dead_pixels_test_controller.cpp index 7bc0c548d..50cde3ec9 100644 --- a/apps/hardware_test/dead_pixels_test_controller.cpp +++ b/apps/hardware_test/dead_pixels_test_controller.cpp @@ -2,13 +2,13 @@ namespace HardwareTest { -constexpr KDColor DeadPixelsTestController::k_colors[DeadPixelsTestController::k_numberOfColors - 1]; +constexpr KDColor DeadPixelsTestController::k_colors[DeadPixelsTestController::k_numberOfAdditionalColors]; bool DeadPixelsTestController::handleEvent(Ion::Events::Event event) { if (event != Ion::Events::OK) { return true; } - if (m_colorIndex == k_numberOfColors) { + if (m_colorIndex == k_numberOfAdditionalColors) { // Go to the next step - this will be handled by the WizardViewController return false; } else { diff --git a/apps/hardware_test/dead_pixels_test_controller.h b/apps/hardware_test/dead_pixels_test_controller.h index 4d7ae64e3..1a7826db3 100644 --- a/apps/hardware_test/dead_pixels_test_controller.h +++ b/apps/hardware_test/dead_pixels_test_controller.h @@ -11,13 +11,13 @@ public: DeadPixelsTestController(Responder * parentResponder) : ViewController(parentResponder), m_colorIndex(0), - m_view(KDColorRed) + m_view(KDColorBlack) {} View * view() override { return &m_view; } bool handleEvent(Ion::Events::Event event) override; private: - constexpr static int k_numberOfColors = 4; - constexpr static KDColor k_colors[k_numberOfColors - 1] = {KDColorBlue, KDColorGreen, KDColorWhite}; // KDColorRed is the first color, set in the constructor + constexpr static int k_numberOfAdditionalColors = 4; + constexpr static KDColor k_colors[k_numberOfAdditionalColors] = {KDColorRed, KDColorBlue, KDColorGreen, KDColorWhite}; // KDColorBlack is the first color, set in the constructor int m_colorIndex; SolidColorView m_view; };