summaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-05-05 18:35:39 +0200
committerNao Pross <naopross@thearcway.org>2018-05-05 18:35:39 +0200
commit7c6e90299de97b51f6ba17d1a50cedb824d0c82f (patch)
tree2a032bbec8a11e1b5f7a189ff2750936982576fc /main.cpp
parentFix split() (diff)
downloadSAMLiquidSmoke-7c6e90299de97b51f6ba17d1a50cedb824d0c82f.tar.gz
SAMLiquidSmoke-7c6e90299de97b51f6ba17d1a50cedb824d0c82f.zip
Add gpio::is_set() to read from _latch register, update command parsing
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp42
1 files changed, 31 insertions, 11 deletions
diff --git a/main.cpp b/main.cpp
index 29263cd..46e5342 100644
--- a/main.cpp
+++ b/main.cpp
@@ -5,7 +5,7 @@
* Created on May 1, 2018, 6:18 PM
*/
-#define DEBUG
+//#define DEBUG
// basic devices
#include "hal/confbits.hpp"
@@ -86,19 +86,22 @@ int main(int argc, char** argv)
std::string input = "";
// write prompt
- uart::write<1>("> ");
+ uart::write<1>("\n\r> ");
do {
input += uart::read_wait<1>();
- } while (input.back() != '\r');
-
+ } while (input.back() != '\r' && input.back() != '\n');
+
#ifdef DEBUG
- uart::write<1>("\n\rinput: ");
+ uart::write<1>("input: ");
uart::print<1>(input);
#endif
// remove weird symbols
strip(input);
+
+ // set to lowercase
+ std::transform(input.begin(), input.end(), input.begin(), ::tolower);
// split
const std::vector<std::string> command = split(input, ' ');
@@ -112,19 +115,36 @@ int main(int argc, char** argv)
if (command.size() == 1) {
if (command[0] == "help") {
- uart::print<1>("TODO: help text");
+ uart::print<1>("List of available commands:");
+ uart::print<1>("help");
+ uart::print<1>("set led <color> <on/off>");
+ uart::print<1>("show led all <on/off>");
+ uart::print<1>("set baudrate <baud>");
+
+ uart::print<1>("\n\rList of available colors:");
+ uart::print<1>("red, green, yellow");
+
+ uart::print<1>("\n\rList of available baudrates:");
+ uart::print<1>("9600, 4800");
}
} else if (command.size() == 3) {
if (command[0] == "show") {
- uart::print<1>(led1.to_string());
- uart::print<1>(led2.to_string());
- uart::print<1>(led3.to_string());
- continue;
+ if (command[1] == "led") {
+ if (command[2] == "all") {
+ uart::print<1>(led1.to_string());
+ uart::print<1>(led2.to_string());
+ uart::print<1>(led3.to_string());
+ }
+ }
}
if (command[0] == "set") {
if (command[1] == "baudrate") {
- // TODO
+ if (command[2] == "9600") {
+ U1BRG = 0x19;
+ } else if (command[2] == "4800") {
+ U1BRG = 0x33;
+ }
}
}
} else if (command.size() == 4) {