From be63ab6b2570178f0b47b09ab2bbbce424d5d7e3 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Fri, 10 Mar 2017 17:57:03 +0100 Subject: [PATCH] [apps/hwtest] DISPLAY=0x112233 sends a color to the screen Change-Id: I4ec2a8ab8d8e292fed5bdf38b4c121f2c6ce812e --- apps/hwtest/lowlevel/lowlevel.cpp | 46 ++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/apps/hwtest/lowlevel/lowlevel.cpp b/apps/hwtest/lowlevel/lowlevel.cpp index 7ff648629..ca34027dc 100644 --- a/apps/hwtest/lowlevel/lowlevel.cpp +++ b/apps/hwtest/lowlevel/lowlevel.cpp @@ -76,6 +76,7 @@ void CommandList::dispatch(const char * command) const { } static const char * sOK = "OK"; +static const char * sKO = "KO"; static const char * sSyntaxError = "SYNTAX_ERROR"; static const char * sON = "ON"; static const char * sOFF = "OFF"; @@ -139,6 +140,8 @@ void command_led(const char * input) { } void command_display(const char * input) { + // Input must be of the form "0xAABBCC" or "ON" or "OFF" + if (strcmp(input, sON) == 0) { Ion::Display::Device::init(); Ion::Console::writeLine(sOK); @@ -149,7 +152,48 @@ void command_display(const char * input) { Ion::Console::writeLine(sOK); return; } - Ion::Console::writeLine(sSyntaxError); + if (input == nullptr || input[0] != '0' || input[1] != 'x' || !isHex(input[2]) ||!isHex(input[3]) || !isHex(input[4]) || !isHex(input[5]) || !isHex(input[6]) || !isHex(input[7]) || input[8] != NULL) { + Ion::Console::writeLine(sSyntaxError); + return; + } + + /* We fill the screen with a color and return OK if we read that color back everywhere. */ + + 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