diff --git a/README.md b/README.md index 024e0aa..328adec 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#Arduino Serial Manager Library v1.0.0-alpha.1 +#Arduino Serial Manager Library v1.0.0-alpha.2 A simple interface for serial communication. * [Documentation](http://robotsbigdata.com/docs-arduino-serial-manager.html) diff --git a/examples/basic_serial_protocol/basic_serial_protocol.ino b/examples/basic_serial_protocol/basic_serial_protocol.ino index 6e47d2f..1e4ef57 100644 --- a/examples/basic_serial_protocol/basic_serial_protocol.ino +++ b/examples/basic_serial_protocol/basic_serial_protocol.ino @@ -1,6 +1,6 @@ -// Arduino RBD Serial Manager Library v1.0.0-alpha.1 Example - Receive, parse, then echo characters back to serial output. +// Arduino RBD Serial Manager Library v1.0.0-alpha.2 Example - Quickly define and consume an event-based serial protocol. // https://github.com/alextaujenis/RBD_SerialManager -// Copyright 2015 Alex Taujenis +// Copyright 2016 Alex Taujenis // MIT License #include // https://github.com/alextaujenis/RBD_SerialManager @@ -12,8 +12,16 @@ void setup() { } void loop() { + // example commands: on; pwm,123; if(serial_manager.onReceive()) { - // example serial command: hello world; - Serial.println(serial_manager.getValue()); + if(serial_manager.isCmd("on")) { + serial_manager.println("IT'S ON!"); + } + + if(serial_manager.isCmd("pwm")) { + int value = serial_manager.getParam().toInt(); + serial_manager.print("SET PWM "); + serial_manager.println(value); + } } } \ No newline at end of file diff --git a/examples/led_serial_protocol/led_serial_protocol.ino b/examples/led_serial_protocol/led_serial_protocol.ino index f3f56b2..58b6bb3 100644 --- a/examples/led_serial_protocol/led_serial_protocol.ino +++ b/examples/led_serial_protocol/led_serial_protocol.ino @@ -1,14 +1,14 @@ -// Arduino RBD Serial Manager Library v1.0.0-alpha.1 Example - Control the built-in Arduino led with serial commands: on; off; pwm,255; +// Arduino RBD Serial Manager Library v1.0.0-alpha.2 Example - Control the built-in Arduino led with serial commands: on; off; pwm,255; // https://github.com/alextaujenis/RBD_SerialManager -// Copyright 2015 Alex Taujenis +// Copyright 2016 Alex Taujenis // MIT License -#include // https://github.com/alextaujenis/RBD_SerialManager #include // https://github.com/alextaujenis/RBD_Timer #include // https://github.com/alextaujenis/RBD_Light +#include // https://github.com/alextaujenis/RBD_SerialManager -RBD::SerialManager usb; RBD::Light light(13); +RBD::SerialManager usb; void setup() { usb.start(); diff --git a/examples/servo_serial_protocol/servo_serial_protocol.ino b/examples/servo_serial_protocol/servo_serial_protocol.ino index 4abf344..be0043c 100644 --- a/examples/servo_serial_protocol/servo_serial_protocol.ino +++ b/examples/servo_serial_protocol/servo_serial_protocol.ino @@ -1,13 +1,13 @@ -// Arduino RBD Serial Manager Library v1.0.0-alpha.1 Example - Control the rotation of a servo with serial commands: up; down; move,90; +// Arduino RBD Serial Manager Library v1.0.0-alpha.2 Example - Control the rotation of a servo with serial commands: up; down; move,90; // https://github.com/alextaujenis/RBD_SerialManager -// Copyright 2015 Alex Taujenis +// Copyright 2016 Alex Taujenis // MIT License -#include // https://github.com/alextaujenis/RBD_SerialManager #include // https://github.com/alextaujenis/RBD_Servo +#include // https://github.com/alextaujenis/RBD_SerialManager -RBD::SerialManager usb; RBD::Servo servo(2, 700, 2300); // digital pin 2, 700ms - 2300ms pulse range +RBD::SerialManager usb; void setup() { usb.start(); diff --git a/library.properties b/library.properties index df28de6..fd3cdf3 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RBD_SerialManager -version=1.0.0-alpha.1 +version=1.0.0-alpha.2 author=Alex Taujenis maintainer=Alex Taujenis sentence=A simple interface for serial communication. diff --git a/src/RBD_SerialManager.cpp b/src/RBD_SerialManager.cpp index 970d650..509e50c 100644 --- a/src/RBD_SerialManager.cpp +++ b/src/RBD_SerialManager.cpp @@ -1,6 +1,6 @@ -// Arduino RBD Serial Manager Library v1.0.0-alpha.1 - A simple interface for serial communication. +// Arduino RBD Serial Manager Library v1.0.0-alpha.2 - A simple interface for serial communication. // https://github.com/alextaujenis/RBD_SerialManager -// Copyright 2015 Alex Taujenis +// Copyright 2016 Alex Taujenis // MIT License #include diff --git a/src/RBD_SerialManager.h b/src/RBD_SerialManager.h index 3edd25d..82412b7 100644 --- a/src/RBD_SerialManager.h +++ b/src/RBD_SerialManager.h @@ -1,6 +1,6 @@ -// Arduino RBD Serial Manager Library v1.0.0-alpha.1 - A simple interface for serial communication. +// Arduino RBD Serial Manager Library v1.0.0-alpha.2 - A simple interface for serial communication. // https://github.com/alextaujenis/RBD_SerialManager -// Copyright 2015 Alex Taujenis +// Copyright 2016 Alex Taujenis // MIT License #ifndef RBD_SERIAL_MANAGER @@ -20,6 +20,8 @@ namespace RBD { String getParam(); bool isCmd(String value); bool isParam(String value); + template void print(T value){Serial.print(value);} + template void println(T value){Serial.println(value);} private: int _position; char _char;