Exploring BeagleBone  V1.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Data Structures | Typedefs | Functions
exploringBB Namespace Reference

Data Structures

class  ADXL345
 Specific class for the ADXL345 Accelerometer. More...
 
class  BMA180
 A class to control a BMA180 accelerometer (untested) More...
 
class  BusDevice
 This class is the parent of I2C and SPI devices, so that devices that use both SPI and I2C interfaces can use those interfaces interchangeably. Because it contains abstract methods, the child classes MUST implement the methods that are listed in this class. More...
 
class  DCMotor
 A generic DC motor class that controls a motor driver board using a PWM signal,and a GPIO state to control the motor direction. More...
 
class  GPIO
 GPIO class for input and output functionality on a single GPIO pin. More...
 
class  I2CDevice
 Generic I2C Device class that can be used to connect to any type of I2C device and read or write to its registers. More...
 
class  ITG3200
 A class to interface with the ITG3200 gyroscope (untested) More...
 
class  LCDCharacterDisplay
 A class that provides an interface to an LCD character module. It provices support for multiple rows and columns and provides methods for formatting and printing text. You should use a 4 wire interface and a 74XX595 to communicate with the display module. More...
 
class  PWM
 A class to control a basic PWM output – you must know the exact sysfs filename for the PWM output. More...
 
class  Servo
 An extremely basic Servo class stub – does nothing more than the PWM class but is here for future use. More...
 
class  SevenSegmentDisplay
 A class that allows you to drive an array of 7 segment displays using an array of 74XX595 ICs. More...
 
class  SocketClient
 A class that encapsulates a socket client to be used for network communication. More...
 
class  SocketServer
 A class that encapsulates a server socket for network communication. More...
 
class  SPIDevice
 Generic SPI Device class that can be used to connect to any type of SPI device and read or write to its registers. More...
 
class  StepperMotor
 A class to control a stepper motor using a motor driver board, such as the Easy Driver board, or compatible. The class uses five GPIOs to control each motor. More...
 

Typedefs

typedef int(* CallbackType )(int)
 

Functions

void * threadedToggle (void *value)
 
void * threadedPoll (void *value)
 
int write (string path, string filename, string value)
 
string read (string path, string filename)
 
int write (string path, string filename, int value)
 
void * threadedStep (void *value)
 

Typedef Documentation

typedef int(* exploringBB::CallbackType)(int)

Function Documentation

string exploringBB::read ( string  path,
string  filename 
)

Helper read function that reads a single string value to a file from the path provided

Parameters
pathThe sysfs path of the file to be read
filenameFilename The file to be written to in that path
Returns
57  {
58  ifstream fs;
59  fs.open((path + filename).c_str());
60  if (!fs.is_open()){
61  perror("GPIO: read failed to open file ");
62  }
63  string input;
64  getline(fs,input);
65  fs.close();
66  return input;
67 }
void * exploringBB::threadedPoll ( void *  value)
272  {
273  GPIO *gpio = static_cast<GPIO*>(value);
274  while(gpio->threadRunning){
275  gpio->callbackFunction(gpio->waitForEdge());
276  usleep(gpio->debounceTime * 1000);
277  }
278  return 0;
279 }
void * exploringBB::threadedStep ( void *  value)
179  {
180  StepperMotor *stepper = static_cast<StepperMotor*>(value);
181  while(stepper->threadRunning){
182  stepper->step();
183  usleep(stepper->threadedStepPeriod * 1000); // convert from ms to us
184  if(stepper->threadedStepNumber>0) stepper->threadedStepNumber--;
185  if(stepper->threadedStepNumber==0) stepper->threadRunning = false;
186  }
187  return 0;
188 }
void * exploringBB::threadedToggle ( void *  value)
218  {
219  GPIO *gpio = static_cast<GPIO*>(value);
220  bool isHigh = (bool) gpio->getValue(); //find current value
221  while(gpio->threadRunning){
222  if (isHigh) gpio->setValue(GPIO::HIGH);
223  else gpio->setValue(GPIO::LOW);
224  usleep(gpio->togglePeriod * 500);
225  isHigh=!isHigh;
226  if(gpio->toggleNumber>0) gpio->toggleNumber--;
227  if(gpio->toggleNumber==0) gpio->threadRunning=false;
228  }
229  return 0;
230 }
int exploringBB::write ( string  path,
string  filename,
string  value 
)

Helper write function that writes a single string value to a file in the path provided

Parameters
pathThe sysfs path of the file to be modified
filenameThe file to be written to in that path
valueThe value to be written to the file
Returns
40  {
41  ofstream fs;
42  fs.open((path + filename).c_str());
43  if (!fs.is_open()){
44  perror("GPIO: write failed to open file ");
45  return -1;
46  }
47  fs << value;
48  fs.close();
49  return 0;
50 }
int exploringBB::write ( string  path,
string  filename,
int  value 
)

Private write method that writes a single int value to a file in the path provided

Parameters
pathThe sysfs path of the file to be modified
filenameThe file to be written to in that path
valueThe int value to be written to the file
Returns
76  {
77  stringstream s;
78  s << value;
79  return write(path,filename,s.str());
80 }
int write(string path, string filename, int value)
Definition: util.cpp:76