bench.cpp
1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "bench.h"
#include <ion.h>
#include "command_list.h"
namespace Ion {
namespace Device {
namespace Bench {
constexpr CommandHandler handles[] = {
CommandHandler("ADC", Command::ADC),
CommandHandler("BACKLIGHT", Command::Backlight),
CommandHandler("CHARGE", Command::Charge),
CommandHandler("DISPLAY", Command::Display),
CommandHandler("EXIT", Command::Exit),
CommandHandler("KEYBOARD", Command::Keyboard),
CommandHandler("LED", Command::LED),
CommandHandler("MCU_SERIAL", Command::MCUSerial),
CommandHandler("PING", Command::Ping),
CommandHandler("SUSPEND", Command::Suspend),
CommandHandler(nullptr, nullptr)
};
constexpr const CommandList sCommandList = CommandList(handles);
constexpr int kMaxCommandLength = 255;
void run() {
char command[kMaxCommandLength];
while (true) {
Ion::Console::readLine(command, kMaxCommandLength);
const CommandHandler * ch = sCommandList.dispatch(command);
if (ch != nullptr && ch->function() == Command::Exit) {
break;
}
}
}
}
}
}