[apps/hardware_test] Centered screen test done at serial number view

This commit is contained in:
Léa Saviot
2019-07-03 10:28:22 +02:00
parent 5ac1c27401
commit d07211cde4
9 changed files with 25 additions and 57 deletions

View File

@@ -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 \

View File

@@ -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,

View File

@@ -3,7 +3,6 @@
#include <escher.h>
#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;

View File

@@ -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);
}
}

View File

@@ -1,34 +0,0 @@
#ifndef HARDWARE_TEST_CENTERED_SCREEN_TEST_CONTROLLER_H
#define HARDWARE_TEST_CENTERED_SCREEN_TEST_CONTROLLER_H
#include <escher.h>
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

View File

@@ -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);
}
}

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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;
};