diff options
Diffstat (limited to '')
-rw-r--r-- | main.cpp | 42 |
1 files changed, 31 insertions, 11 deletions
@@ -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) { |