Code Monkey home page Code Monkey logo

serialterminal's Introduction

SerialTerminal

โ€“ a simple Arduino library to incorporate a serial terminal to your project

Usage

Store a global pointer to an instance of maschinendeck::SerialTerminal, initialize it with your desired baudrate and commands in the setup() function and call its maschinendeck::SerialTerminal::loop() function in the general loop() function, like in the example below.

#include <SerialTerminal.hpp>

maschinendeck::SerialTerminal* term;

void addInt(String opts) {
	maschinendeck::Pair<String, String> operands = maschinendeck::SerialTerminal::ParseCommand(opts);
	Serial.print(operands.first());
	Serial.print(" + ");
	Serial.print(operands.second());
	Serial.print(" = ");
	Serial.print(operands.first().toInt() + operands.second().toInt());
	Serial.print('\n');
}

void setup() {
	term = new maschinendeck::SerialTerminal(38400);
	term->add("add", &addInt, "adds two integers");
}

void loop() {
	term->loop();
}

Flags

You can change the behavior of the library, by setting some flags:

  • ST_FLAG_NOHELP - removes the help screen normally printed on startup
  • ST_FLAG_NOBUILTIN - removes all default commands, if you do not need them
  • ST_FLAG_NOPROMPT - do not print a prompt

You simply define them before the include of SerialTerminal.h:

#define ST_FLAG_NOHELP
#define ST_FLAG_NOBUILTIN

#include <SerialTerminal.hpp>

maschinendeck::SerialTerminal* term;

...

serialterminal's People

Contributors

miko007 avatar madsdyd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.