mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-26 17:20:53 +01:00
[apps/hardware_test] Add LED test
Change-Id: I998074b74357f76a624962bfa274ebf7a10ac0fc
This commit is contained in:
@@ -7,7 +7,8 @@ namespace HardwareTest {
|
||||
|
||||
KeyboardController::KeyboardController(Responder * parentResponder) :
|
||||
ViewController(parentResponder),
|
||||
m_view(KeyboardView())
|
||||
m_view(KeyboardView()),
|
||||
m_color(KDColorBlack)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -16,6 +17,8 @@ View * KeyboardController::view() {
|
||||
}
|
||||
|
||||
bool KeyboardController::handleEvent(Ion::Events::Event event) {
|
||||
Ion::LED::setColor(m_color);
|
||||
m_color = nextColor(m_color);
|
||||
m_view.updateBatteryState(Ion::Battery::voltage(), Ion::Battery::isCharging());
|
||||
if (event != Ion::Events::Event::PlainKey(m_view.testedKey()) && event != Ion::Events::Event::ShiftKey(m_view.testedKey()) && event != Ion::Events::Event::AlphaKey(m_view.testedKey()) && event != Ion::Events::Event::ShiftAlphaKey(m_view.testedKey())) {
|
||||
m_view.setDefectiveKey(m_view.testedKey());
|
||||
@@ -25,9 +28,29 @@ bool KeyboardController::handleEvent(Ion::Events::Event event) {
|
||||
}
|
||||
|
||||
void KeyboardController::viewWillAppear() {
|
||||
m_color = KDColorBlack;
|
||||
m_view.resetTestedKey();
|
||||
m_view.updateBatteryState(Ion::Battery::voltage(), Ion::Battery::isCharging());
|
||||
}
|
||||
|
||||
KDColor KeyboardController::nextColor(KDColor color) {
|
||||
if (color == KDColorBlack) {
|
||||
return KDColorWhite;
|
||||
}
|
||||
if (color == KDColorWhite) {
|
||||
return KDColorRed;
|
||||
}
|
||||
if (color == KDColorRed) {
|
||||
return KDColorBlue;
|
||||
}
|
||||
if (color == KDColorBlue) {
|
||||
return KDColorGreen;
|
||||
}
|
||||
if (color == KDColorGreen) {
|
||||
return KDColorBlack;
|
||||
}
|
||||
return KDColorBlack;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@ namespace HardwareTest {
|
||||
class KeyboardController : public ViewController {
|
||||
public:
|
||||
KeyboardController(Responder * parentResponder);
|
||||
|
||||
View * view() override;
|
||||
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
void viewWillAppear() override;
|
||||
private:
|
||||
static KDColor nextColor(KDColor color);
|
||||
KeyboardView m_view;
|
||||
KDColor m_color;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
objs += $(addprefix ion/src/simulator/, \
|
||||
battery.o\
|
||||
init.o\
|
||||
led.o\
|
||||
)
|
||||
|
||||
objs += $(addprefix ion/src/simulator/boot/, main.o)
|
||||
|
||||
6
ion/src/simulator/led.cpp
Normal file
6
ion/src/simulator/led.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <ion/led.h>
|
||||
|
||||
void Ion::LED::setColor(KDColor c) {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user