BeeSTEM.H Interface to Rand Voorhies' BeeSTEM device. More...
#include <Devices/BeeSTEM.H>
Public Member Functions | |
void | run () |
This is our main running thread - don't call directly. | |
bool | writeByte (const byte val, const bool uselock=true) |
send a byte to the BeeSTEM | |
Constructors, destructors and debugging | |
BeeSTEM (OptionManager &mgr, const std::string &descrName="BeeSTEM", const std::string &tagName="BeeSTEM", const char *dev="/dev/ttyS0") | |
Default constructor. See ModelComponent.H. | |
~BeeSTEM () | |
Destructor. | |
void | setListener (rutz::shared_ptr< BeeSTEMListener > &listener) |
Install a callback (listener) for BeeSTEM events. | |
bool | echoRequest () |
Send an echo request. | |
bool | debugMode (const bool on) |
Turn debug mode on/off. | |
bool | resetChip () |
Reset the BeeSTEM. | |
bool | toggleCalibrateHMR3300 () |
Toggle the calibration mode of the HMR3300. | |
bool | levelHMR3300 () |
Level the HMR3300. | |
LCD functions | |
bool | lcdPrintf (const char *fmt,...) __attribute__((format(__printf__ |
Print some text. | |
bool bool | lcdClear () |
Clear LCD screen. | |
PWM control functions | |
bool | setMotor (const int motor, signed char speed) |
Sets the speed of a motor. -100 is full reverse, and +100 is full forwards. | |
float | getMotorCurrent (const int motor) const |
Gets the current current consumption of a motor. | |
Data aquisition and reporting functions | |
bool | setReporting (const BeeSTEMReportingMask t, const bool on) |
Tell the BeeSTEM to start (or stop) sending a data type over the serial connection. | |
Data Acquisition Functions | |
byte | getCompassHeading () |
Get Compass Heading. | |
byte | getCompassPitch () |
Get Compass Pitch. | |
byte | getCompassRoll () |
Get Compass Pitch. | |
byte | getAccelX () |
Get High Speed Accelerometer X. | |
byte | getAccelY () |
Get High Speed Accelerometer Y. | |
byte | getIntPress () |
Get Internal Pressure. | |
byte | getExtPress () |
Get External Pressure. | |
byte | getTemp1 () |
Get Temperature Zone 1. | |
byte | getTemp2 () |
Get Temperature Zone 2. | |
byte | getTemp3 () |
Get Temperature Zone 3. | |
byte | getSpareADC () |
Get current raw Analog value from the spare ADC pin. | |
byte | getMotorCurr (byte whichone) |
Get the current from a motor. | |
bool | getDigitalIn (const int whichone) |
Get the value of a single digital input pin. | |
byte | getDigitalIn () |
Get the value of all 8 digital input pins as a whole byte. | |
Digital output function | |
bool | setDigitalOut (const int outnum, const bool on) |
Turn a given digital output on/off. | |
Protected Member Functions | |
void | start1 () |
open the port and get started | |
void | stop2 () |
close the port and get stopped |
BeeSTEM.H Interface to Rand Voorhies' BeeSTEM device.
Hardware interface Class. Contains interfaces to display to an LCD, a 2D Accelerometer/Compass, and extra high speed accelerometer, 3 temperature sensors, internal & external pressure sensors, 8 digital I/O pins an ADC pin, 5 PWM outputs, and motor current readings.
Definition at line 183 of file BeeSTEM.H.
BeeSTEM::BeeSTEM | ( | OptionManager & | mgr, | |
const std::string & | descrName = "BeeSTEM" , |
|||
const std::string & | tagName = "BeeSTEM" , |
|||
const char * | dev = "/dev/ttyS0" | |||
) |
Default constructor. See ModelComponent.H.
Definition at line 64 of file BeeSTEM.C.
References ModelComponent::addSubComponent(), and rutz::shared_ptr< T >::reset().
bool BeeSTEM::debugMode | ( | const bool | on | ) |
Turn debug mode on/off.
When in debug mode, the BeeSTEM sends an EchoReply for each command it receives.
Definition at line 125 of file BeeSTEM.C.
References writeByte().
bool BeeSTEM::echoRequest | ( | ) |
Send an echo request.
The BeeSTEM should reply with an Echo_Reply event if it is alive
Definition at line 118 of file BeeSTEM.C.
References writeByte().
byte BeeSTEM::getAccelX | ( | ) |
byte BeeSTEM::getAccelY | ( | ) |
byte BeeSTEM::getCompassRoll | ( | ) |
byte BeeSTEM::getDigitalIn | ( | ) |
bool BeeSTEM::getDigitalIn | ( | const int | whichone | ) |
float BeeSTEM::getMotorCurrent | ( | const int | motor | ) | const |
Gets the current current consumption of a motor.
Note that motor current monitoring must be explicitely turned on
byte BeeSTEM::getSpareADC | ( | ) |
bool BeeSTEM::lcdClear | ( | ) |
bool BeeSTEM::lcdPrintf | ( | const char * | fmt, | |
... | ||||
) |
bool BeeSTEM::levelHMR3300 | ( | ) |
bool BeeSTEM::resetChip | ( | ) |
void BeeSTEM::run | ( | ) |
This is our main running thread - don't call directly.
Should have been protected, but is not because of pthread hack.
Definition at line 363 of file BeeSTEM.C.
References rutz::shared_ptr< T >::get(), and MYLOGVERB.
bool BeeSTEM::setDigitalOut | ( | const int | outnum, | |
const bool | on | |||
) |
Turn a given digital output on/off.
Valid range for outnum is [0..7]
Definition at line 337 of file BeeSTEM.C.
References ASSERT, and writeByte().
void BeeSTEM::setListener | ( | rutz::shared_ptr< BeeSTEMListener > & | listener | ) |
bool BeeSTEM::setMotor | ( | const int | motor, | |
signed char | speed | |||
) |
Sets the speed of a motor. -100 is full reverse, and +100 is full forwards.
Note that the [-100..+100] is only a percentage of the maximum possible PWM allowed by the BeeSTEM. See MotorControl.H of the BeeSTEM code for more.
Definition at line 167 of file BeeSTEM.C.
References abs(), and writeByte().
bool BeeSTEM::setReporting | ( | const BeeSTEMReportingMask | t, | |
const bool | on | |||
) |
Tell the BeeSTEM to start (or stop) sending a data type over the serial connection.
This function takes in a BeeSTEMReportingMask and a bool, and tells the BeeSTEM to start or stop monitoring and reporting a resource designated by the mask. Note that turning on too many reporting features may significantly slow down the device, so please only turn on what's needed.
Definition at line 222 of file BeeSTEM.C.
References writeByte().
void BeeSTEM::start1 | ( | ) | [protected, virtual] |
open the port and get started
Reimplemented from ModelComponent.
void BeeSTEM::stop2 | ( | ) | [protected, virtual] |
close the port and get stopped
Reimplemented from ModelComponent.
bool BeeSTEM::toggleCalibrateHMR3300 | ( | ) |
Toggle the calibration mode of the HMR3300.
Definition at line 204 of file BeeSTEM.C.
References writeByte().
bool BeeSTEM::writeByte | ( | const byte | val, | |
const bool | uselock = true | |||
) |
send a byte to the BeeSTEM
You should never have to use this, use the other functions instead. This function is made public just for testing the chip's robustness against a flood of random junk hitting it... See test-BeeSTEM.C
Definition at line 345 of file BeeSTEM.C.
References MYLOGVERB.
Referenced by debugMode(), echoRequest(), lcdClear(), levelHMR3300(), resetChip(), setDigitalOut(), setMotor(), setReporting(), and toggleCalibrateHMR3300().