From 8597f47c369113aa53a8e445f08cc5243f019132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Tue, 28 May 2019 16:49:56 +0200 Subject: [PATCH] [apps/POSTAndHWTest] In LCDDataOK iterate on Text and Tiling tests --- apps/on_boarding/power_on_self_test.cpp | 9 ++++-- apps/shared/post_and_hardware_tests.cpp | 35 ++++++++++++----------- apps/shared/post_and_hardware_tests.h | 3 +- ion/include/ion/display.h | 2 +- ion/src/device/shared/drivers/display.cpp | 4 +-- ion/src/shared/dummy/display.cpp | 2 +- 6 files changed, 31 insertions(+), 24 deletions(-) diff --git a/apps/on_boarding/power_on_self_test.cpp b/apps/on_boarding/power_on_self_test.cpp index 4e23e26ac..921be6b26 100644 --- a/apps/on_boarding/power_on_self_test.cpp +++ b/apps/on_boarding/power_on_self_test.cpp @@ -8,11 +8,14 @@ KDColor PowerOnSelfTest::Perform() { KDColor previousLEDColor = Ion::LED::getColor(); KDColor resultColor = KDColorGreen; - // Screen tests + /* Screen tests + * CAUTION: Timing is important. TextLCDTestOK fails only if done at an + * unknown time, which happens to be for VBlankOK being done just before. + * TextLCDTestOK is done many times in a row in the HardwareTest, so if the + * screen passes the POST and fails the Hardware Test, we will need to find + * the right time to sleep here before launching TextLCDTestOK. */ bool screenTestsOK = Shared::POSTAndHardwareTests::VBlankOK() && Shared::POSTAndHardwareTests::TextLCDTestOK(); - // We push a white screen so that the LCD Data test is invisible for the user. - Ion::Display::waitForVBlank(); Ion::Display::pushRectUniform(KDRect(0, 0, Ion::Display::Width, Ion::Display::Height), KDColorWhite); Ion::Display::waitForVBlank(); diff --git a/apps/shared/post_and_hardware_tests.cpp b/apps/shared/post_and_hardware_tests.cpp index a489383e2..4376a3757 100644 --- a/apps/shared/post_and_hardware_tests.cpp +++ b/apps/shared/post_and_hardware_tests.cpp @@ -28,7 +28,6 @@ bool POSTAndHardwareTests::TextLCDTestOK() { for (int i = 0; i < Ion::Display::Height / glyphHeight; i++) { KDIonContext::sharedContext()->drawString(text, KDPoint(0, i * glyphHeight), font); } - // Check the drawing for (int i = 0; i < Ion::Display::Height / glyphHeight; i++) { if (!KDIonContext::sharedContext()->checkDrawnString(text, KDPoint(0, i * glyphHeight), font)) { @@ -39,23 +38,27 @@ bool POSTAndHardwareTests::TextLCDTestOK() { } bool POSTAndHardwareTests::LCDDataOK() { - if (!TextLCDTestOK()) { - return false; + for (int iteration = 0; iteration < k_numberOfLCDIterations; iteration++) { + if (!TextLCDTestOK() || !TilingLCDTestOK()) { + return false; + } } - for (int iteration = 0; iteration < k_numberOfTilingLCDIterations; iteration++) { - Ion::Display::POSTPushMulticolor(iteration, k_stampSize); - KDColor stamp[k_stampSize*k_stampSize]; - for (int i = 0; i < Ion::Display::Width / k_stampSize; i++) { - for (int j = 0; j < Ion::Display::Height / k_stampSize; j++) { - Ion::Display::pullRect(KDRect(i * k_stampSize, j * k_stampSize, k_stampSize, k_stampSize), stamp); - int shift = (i+j+iteration) % 16; - uint16_t color = (uint16_t)(1 << shift); - for (int k = 0; k < k_stampSize*k_stampSize; k++) { - if (stamp[k] != color) { - return false; - } - color ^= 0xFFFF; + return true; +} + +bool POSTAndHardwareTests::TilingLCDTestOK() { + Ion::Display::POSTPushMulticolor(k_stampSize); + KDColor stamp[k_stampSize*k_stampSize]; + for (int i = 0; i < Ion::Display::Width / k_stampSize; i++) { + for (int j = 0; j < Ion::Display::Height / k_stampSize; j++) { + Ion::Display::pullRect(KDRect(i * k_stampSize, j * k_stampSize, k_stampSize, k_stampSize), stamp); + int shift = (i+j) % 16; + uint16_t color = (uint16_t)(1 << shift); + for (int k = 0; k < k_stampSize*k_stampSize; k++) { + if (stamp[k] != color) { + return false; } + color ^= 0xFFFF; } } } diff --git a/apps/shared/post_and_hardware_tests.h b/apps/shared/post_and_hardware_tests.h index d09fab8d2..af01f0341 100644 --- a/apps/shared/post_and_hardware_tests.h +++ b/apps/shared/post_and_hardware_tests.h @@ -22,7 +22,8 @@ public: static bool LCDDataOK(); private: constexpr static int k_stampSize = 8; - constexpr static int k_numberOfTilingLCDIterations = 20; + constexpr static int k_numberOfLCDIterations = 20; + static bool TilingLCDTestOK(); static_assert(Ion::Display::Width % k_stampSize == 0, "Stamps must tesselate the display"); static_assert(Ion::Display::Height % k_stampSize == 0, "Stamps must tesselate the display"); static_assert(k_stampSize % 2 == 0, "Even number of XOR needed."); diff --git a/ion/include/ion/display.h b/ion/include/ion/display.h index 30fb079d1..94b0a9bd4 100644 --- a/ion/include/ion/display.h +++ b/ion/include/ion/display.h @@ -29,7 +29,7 @@ constexpr int WidthInTenthOfMillimeter = 576; constexpr int HeightInTenthOfMillimeter = 432; // For Power On Self tests -void POSTPushMulticolor(int shift, int tileSize); +void POSTPushMulticolor(int tileSize); } } diff --git a/ion/src/device/shared/drivers/display.cpp b/ion/src/device/shared/drivers/display.cpp index 1fd3977d9..20d5bb74f 100644 --- a/ion/src/device/shared/drivers/display.cpp +++ b/ion/src/device/shared/drivers/display.cpp @@ -86,12 +86,12 @@ bool waitForVBlank() { return false; } -void POSTPushMulticolor(int shift, int tileSize) { +void POSTPushMulticolor(int tileSize) { const int maxI = Ion::Display::Width / tileSize; const int maxJ = Ion::Display::Height / tileSize; for (int i = 0; i < maxI; i++) { for (int j = 0; j < maxJ; j++) { - uint16_t k = (i+j+shift) % 16; + uint16_t k = (i+j) % 16; uint16_t color = 1 << k; setDrawingArea(KDRect(i*tileSize,j*tileSize,tileSize, tileSize), Orientation::Landscape); pushColorAndContraryPixels(color, tileSize*tileSize); diff --git a/ion/src/shared/dummy/display.cpp b/ion/src/shared/dummy/display.cpp index e2fd9f46c..0a345b846 100644 --- a/ion/src/shared/dummy/display.cpp +++ b/ion/src/shared/dummy/display.cpp @@ -1,6 +1,6 @@ #include -void Ion::Display::POSTPushMulticolor(int shift, int tileSize) { +void Ion::Display::POSTPushMulticolor(int tileSize) { } bool Ion::Display::waitForVBlank() {