SyRenSimplified.cpp
Go to the documentation of this file.
00001 /*
00002 Arduino Library for SyRen Simplified Serial
00003 Copyright (c) 2012-2013 Dimension Engineering LLC
00004 http://www.dimensionengineering.com/arduino
00005 
00006 Permission to use, copy, modify, and/or distribute this software for any
00007 purpose with or without fee is hereby granted, provided that the above
00008 copyright notice and this permission notice appear in all copies.
00009 
00010 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
00011 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00012 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
00013 SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
00014 RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
00015 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
00016 USE OR PERFORMANCE OF THIS SOFTWARE.
00017 */
00018 
00019 #include "SyRenSimplified.h"
00020 
00021 SyRenSimplified::SyRenSimplified()
00022   : _port(SyRenTXPinSerial)
00023 {
00024   
00025 }
00026 
00027 SyRenSimplified::SyRenSimplified(Print& port)
00028   : _port(port)
00029 {
00030   
00031 }
00032 
00033 void SyRenSimplified::motor(int power)
00034 {
00035   byte command;
00036   power = constrain(power, -126, 126);
00037   command = (power < 0 ? 127 : 128) + power;
00038   _port.write(command);
00039 }
00040 
00041 void SyRenSimplified::motor(byte motor_, int power)
00042 {
00043   if (motor_ == 1) { motor(power); }
00044 }
00045 
00046 void SyRenSimplified::stop()
00047 {
00048   motor(0);
00049 }


ric_mc
Author(s): RoboTiCan
autogenerated on Fri May 20 2016 03:48:56