diff --git a/apps/hardware_test/Makefile b/apps/hardware_test/Makefile index 8352f26b2..1465a8307 100644 --- a/apps/hardware_test/Makefile +++ b/apps/hardware_test/Makefile @@ -3,6 +3,7 @@ app_src += $(addprefix apps/hardware_test/,\ arrow_view.cpp \ battery_test_controller.cpp \ code_128b_view.cpp \ + colors_lcd_test_controller.cpp \ dead_pixels_test_controller.cpp \ keyboard_test_controller.cpp \ keyboard_view.cpp \ diff --git a/apps/hardware_test/app.cpp b/apps/hardware_test/app.cpp index bfb0a7b68..a9f110771 100644 --- a/apps/hardware_test/app.cpp +++ b/apps/hardware_test/app.cpp @@ -21,6 +21,7 @@ App::App(Container * container, Snapshot * snapshot) : App::WizardViewController::WizardViewController(Responder * parentResponder) : BankViewController(parentResponder), m_batteryTestController(this), + m_colorsLCDTestController(this), m_deadPixelsTestController(this), m_keyboardController(this), m_lcdDataTestController(this), @@ -31,12 +32,13 @@ App::WizardViewController::WizardViewController(Responder * parentResponder) : } int App::WizardViewController::numberOfChildren() { - return 7; + return 8; } ViewController * App::WizardViewController::childAtIndex(int i) { ViewController * children[] = { &m_vBlankTestController, + &m_colorsLCDTestController, &m_lcdDataTestController, &m_deadPixelsTestController, &m_ledTestController, diff --git a/apps/hardware_test/app.h b/apps/hardware_test/app.h index 7e37d0505..d4ca1b607 100644 --- a/apps/hardware_test/app.h +++ b/apps/hardware_test/app.h @@ -3,6 +3,7 @@ #include #include "battery_test_controller.h" +#include "colors_lcd_test_controller.h" #include "dead_pixels_test_controller.h" #include "keyboard_test_controller.h" #include "lcd_data_test_controller.h" @@ -30,6 +31,7 @@ private: bool handleEvent(Ion::Events::Event event) override; private: BatteryTestController m_batteryTestController; + ColorsLCDTestController m_colorsLCDTestController; DeadPixelsTestController m_deadPixelsTestController; KeyboardTestController m_keyboardController; LCDDataTestController m_lcdDataTestController; diff --git a/apps/hardware_test/colors_lcd_test_controller.cpp b/apps/hardware_test/colors_lcd_test_controller.cpp new file mode 100644 index 000000000..bf708894d --- /dev/null +++ b/apps/hardware_test/colors_lcd_test_controller.cpp @@ -0,0 +1,40 @@ +#include "colors_lcd_test_controller.h" +#include "../apps_container.h" +#include + +using namespace Poincare; + +namespace HardwareTest { + +bool ColorsLCDTestController::handleEvent(Ion::Events::Event event) { + if (event == Ion::Events::OK) { + if (strcmp(m_view.colorsLCDStateTextView()->text(), k_colorsLCDOKText) == 0) { + // Handled in WizardViewController + return false; + } + } + return true; +} + +void ColorsLCDTestController::viewWillAppear() { + bool testOK = Shared::POSTAndHardwareTests::ColorsLCDOK(); + m_view.setColor(testOK ? KDColorGreen : KDColorRed); + m_view.colorsLCDStateTextView()->setText(testOK ? k_colorsLCDOKText : k_colorsLCDFailTest); +} + +ColorsLCDTestController::ContentView::ContentView() : + SolidColorView(KDColorWhite), + m_colorsLCDStateView(KDFont::LargeFont) +{ +} + +void ColorsLCDTestController::ContentView::setColor(KDColor color) { + SolidColorView::setColor(color); + m_colorsLCDStateView.setBackgroundColor(color); +} + +void ColorsLCDTestController::ContentView::layoutSubviews() { + m_colorsLCDStateView.setFrame(KDRect(0, 0, Ion::Display::Width, Ion::Display::Height)); +} + +} diff --git a/apps/hardware_test/colors_lcd_test_controller.h b/apps/hardware_test/colors_lcd_test_controller.h new file mode 100644 index 000000000..02aae289c --- /dev/null +++ b/apps/hardware_test/colors_lcd_test_controller.h @@ -0,0 +1,41 @@ +#ifndef HARDWARE_TEST_COLORS_LCD_TEST_CONTROLLER_H +#define HARDWARE_TEST_COLORS_LCD_TEST_CONTROLLER_H + +#include +#include + +namespace HardwareTest { + +class ColorsLCDTestController : public ViewController { +public: + ColorsLCDTestController(Responder * parentResponder) : + ViewController(parentResponder), + m_view() + {} + View * view() override { return &m_view; } + bool handleEvent(Ion::Events::Event event) override; + void viewWillAppear() override; +private: + class ContentView : public SolidColorView { + public: + ContentView(); + BufferTextView * colorsLCDStateTextView() { return &m_colorsLCDStateView; } + void setColor(KDColor color) override; + private: + void layoutSubviews() override; + int numberOfSubviews() const override { return 1; } + View * subviewAtIndex(int index) override { + assert(index == 0); + return &m_colorsLCDStateView; + } + BufferTextView m_colorsLCDStateView; + }; + constexpr static const char * k_colorsLCDOKText = "COLORS LCD: OK"; + constexpr static const char * k_colorsLCDFailTest = "COLORS LCD: FAIL"; + ContentView m_view; +}; + +} + +#endif + diff --git a/apps/shared/post_and_hardware_tests.cpp b/apps/shared/post_and_hardware_tests.cpp index b0ac06ca0..992485b6e 100644 --- a/apps/shared/post_and_hardware_tests.cpp +++ b/apps/shared/post_and_hardware_tests.cpp @@ -48,6 +48,16 @@ bool POSTAndHardwareTests::LCDDataOK() { return true; } +bool POSTAndHardwareTests::ColorsLCDOK() { + constexpr KDColor k_colors[] = {KDColorBlack, KDColorRed, KDColorBlue, KDColorGreen, KDColorWhite}; + for (KDColor c : k_colors) { + if (Ion::Display::displayUniformTilingSize10(c) > k_acceptableNumberOfFailures) { + return false; + } + } + return true; +} + bool POSTAndHardwareTests::TilingLCDTestOK() { Ion::Display::POSTPushMulticolor(k_stampSize); KDColor stamp[k_stampSize*k_stampSize]; diff --git a/apps/shared/post_and_hardware_tests.h b/apps/shared/post_and_hardware_tests.h index 87fe04af0..4e2dcb9f7 100644 --- a/apps/shared/post_and_hardware_tests.h +++ b/apps/shared/post_and_hardware_tests.h @@ -20,6 +20,7 @@ public: * Data is sent OK). To test each of the 16 data wires for short-circuits, 16 * colors are used: 2**k with 0 <= k < 16. */ static bool LCDDataOK(); + static bool ColorsLCDOK(); private: constexpr static int k_stampSize = 8; constexpr static int k_numberOfLCDIterations = 20; diff --git a/ion/include/ion/display.h b/ion/include/ion/display.h index 94b0a9bd4..5869e1c54 100644 --- a/ion/include/ion/display.h +++ b/ion/include/ion/display.h @@ -30,6 +30,7 @@ constexpr int HeightInTenthOfMillimeter = 432; // For Power On Self tests void POSTPushMulticolor(int tileSize); +int displayUniformTilingSize10(KDColor color); } } diff --git a/ion/src/device/bench/command/display.cpp b/ion/src/device/bench/command/display.cpp index 43e723222..3be1d8297 100644 --- a/ion/src/device/bench/command/display.cpp +++ b/ion/src/device/bench/command/display.cpp @@ -30,38 +30,7 @@ void Display(const char * input) { KDColor c = KDColor::RGB24(hexNumber(input)); - constexpr int stampHeight = 10; - constexpr int stampWidth = 10; - static_assert(Ion::Display::Width % stampWidth == 0, "Stamps must tesselate the display"); - static_assert(Ion::Display::Height % stampHeight == 0, "Stamps must tesselate the display"); - static_assert(stampHeight % 2 == 0 || stampWidth % 2 == 0, "Even number of XOR needed."); - - KDColor stamp[stampWidth*stampHeight]; - for (int i=0;i