Model Railroad System  2.2.1
Public Member Functions | Static Private Attributes | List of all members
linuxgpio::LinuxGpio Class Reference

Base generic GPIO interface class. More...

Public Member Functions

 LinuxGpio (name,...)
 Constructor, used to set up the GPIO pin. More...
 
 read ()
 Read the value of the pin. More...
 
 write (value)
 Write value to the pin. More...
 
 is_output ()
 Returns a boolean value indicating whether the pin is an output pin or not. More...
 
 ~LinuxGpio ()
 Destructor. More...
 
 Set ()
 Set the pin to logic true. More...
 
 Clr ()
 Set the pin to logic false. More...
 
 Get ()
 Get the pin's logic state. More...
 

Static Private Attributes

static EXPORT
 The name of the export control file. More...
 
static UNEXPORT
 The name of the unexport control file. More...
 
static DIRECTIONFMT
 The format string to generate the name of the direction control file. More...
 
static VALUEFMT
 The format string to generate the name of the value file. More...
 

Detailed Description

Base generic GPIO interface class.

(Use one of the specialized classes.)

This class implements the basic interface for a GPIO pin. The pin is set up, its direction configured and its value is optionally initialized.

Constructor & Destructor Documentation

◆ LinuxGpio()

linuxgpio::LinuxGpio::LinuxGpio ( name  ,
  ... 
)

Constructor, used to set up the GPIO pin.

The pin number is written to the export control file and then the pin's diection control file is computed and the pin's direction is written.

Parameters
nameThe name of the pin.
...Options:
  • -pinnumber The pin number, readonly, defaults to 0 and can be any positive integer.
  • -direction The pin direction, readonly, defaults to in can be one of in, out, high, or low.
Author
Robert Heller <heller@deepsoft.com>

◆ ~LinuxGpio()

linuxgpio::LinuxGpio::~LinuxGpio ( )

Destructor.

Unexport the pin.

Member Function Documentation

◆ Clr()

linuxgpio::LinuxGpio::Clr ( )

Set the pin to logic false.

◆ Get()

linuxgpio::LinuxGpio::Get ( )

Get the pin's logic state.

◆ is_output()

linuxgpio::LinuxGpio::is_output ( )

Returns a boolean value indicating whether the pin is an output pin or not.

Returns
A boolean flag, true if this is an output, false if it is an input.

◆ read()

linuxgpio::LinuxGpio::read ( )

Read the value of the pin.

Returns
The value of the pin, 1 or 0.

◆ Set()

linuxgpio::LinuxGpio::Set ( )

Set the pin to logic true.

◆ write()

linuxgpio::LinuxGpio::write ( value  )

Write value to the pin.

Parameters
valueThe value to write, either 1 or any non-zero value for high or 0 for low.

Member Data Documentation

◆ DIRECTIONFMT

linuxgpio::LinuxGpio::DIRECTIONFMT
staticprivate

The format string to generate the name of the direction control file.

◆ EXPORT

linuxgpio::LinuxGpio::EXPORT
staticprivate

The name of the export control file.

◆ UNEXPORT

linuxgpio::LinuxGpio::UNEXPORT
staticprivate

The name of the unexport control file.

◆ VALUEFMT

linuxgpio::LinuxGpio::VALUEFMT
staticprivate

The format string to generate the name of the value file.