Seeed Grove ++  v0.0.1-2386
Linux C++ Library For Seeed Grove Devices
SG::Button Class Reference

Push button. More...

#include <sg_101020003_Button.hpp>

Inheritance diagram for SG::Button:
Collaboration diagram for SG::Button:

Public Member Functions

virtual ~Button (void)
 Destructor. More...
 
 Button (const std::string &n="")
 Constructor. More...
 
virtual bool is_down (void)
 Determine if the button is currently pushed down. More...
 
virtual bool is_up (void)
 Determine if the button is currently up. More...
 
virtual bool wait_for_button_down (const size_t timeout_in_milliseconds=0)
 Wait for the button to be pressed down. More...
 
virtual bool wait_for_button_up (const size_t timeout_in_milliseconds=0)
 Wait for the button to be released. More...
 
virtual bool wait_for_transition (const size_t timeout_in_milliseconds=0)
 Wait for the button to transition to up or down, depending on the current state. More...
 
virtual bool wait_for_button (const size_t timeout_in_milliseconds=0)
 Wait for any sort of user interaction with the button, either to the up or down state. More...
 
virtual GroveGPIOsend_2_bytes (uint16_t bits)
 Send 16 bits (2 bytes). More...
 
virtual GroveGPIOsend_byte (uint8_t byte)
 Send a single byte. More...
 
virtual bool is_grove_uart (void) const
 Determine if this is a Grove UART device. More...
 
virtual bool is_grove_i2c (void) const
 Determine if this is a Grove I2C device. More...
 
virtual bool is_grove_gpio (void) const
 Determine if this is a Grove GPIO device. More...
 
virtual uint32_t get_sku (void) const
 Return a guess as to the Seeed SKU number based on the grove type. More...
 
virtual std::string get_type_name (void) const
 Return a short text string representing the grove type. More...
 
virtual EGroveType get_type (void) const
 Return the grove type. More...
 
virtual std::string get_name (void) const
 Return the user-supplied name. More...
 
virtual std::string get_description (void) const
 Return a multi-word 1-line description of this object. More...
 
bool operator== (const GroveBase &rhs) const
 Test object equality. More...
 
bool operator!= (const GroveBase &rhs) const
 Test object equality. More...
 

Public Attributes

EGroveType grove_type
 Grove type. More...
 
std::string grove_name
 User-supplied name. More...
 

Detailed Description

Push button.

Description Image
Button connected to the Grove UART interface.
sg_101020003_Button.jpg
Note
There is no difference between the SKU #101020003 button and the SKU #111020000 panel mount button.

Example code:

bool is_up = button.is_up();
std::cout << "button is " << (is_up ? "up" : "down") << std::endl;
See also
http://www.seeedstudio.com/wiki/Grove_-_Button
http://www.seeedstudio.com/depot/Grove-Button-p-766.html
http://www.seeedstudio.com/depot/Grove-ButtonP-p-1243.html

Constructor & Destructor Documentation

◆ ~Button()

SG::Button::~Button ( void  )
virtual

Destructor.

References SG::SGpp::get(), SG::SGpp::gpio, and SG::GpioManagement::gpio_unexport().

Here is the call graph for this function:

◆ Button()

SG::Button::Button ( const std::string &  n = "")

Constructor.

References SG::SGpp::get(), SG::SGpp::gpio, SG::GpioManagement::gpio_export(), and SG::GpioManagement::kInput.

Here is the call graph for this function:

Member Function Documentation

◆ get_description()

◆ get_name()

virtual std::string SG::GroveBase::get_name ( void  ) const
inlinevirtualinherited

Return the user-supplied name.

References SG::GroveBase::get_description(), SG::GroveBase::grove_name, SG::GroveBase::is_grove_gpio(), SG::GroveBase::is_grove_i2c(), and SG::GroveBase::is_grove_uart().

Referenced by SG::GroveBase::get_description(), SG::GroveBase::operator=(), and SG::GroveBase::operator==().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_sku()

virtual uint32_t SG::GroveBase::get_sku ( void  ) const
inlinevirtualinherited

Return a guess as to the Seeed SKU number based on the grove type.

References SG::get_sku_from_grove_type(), and SG::GroveBase::grove_type.

Referenced by SG::GroveBase::get_description().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_type()

virtual EGroveType SG::GroveBase::get_type ( void  ) const
inlinevirtualinherited

Return the grove type.

References SG::GroveBase::grove_type.

Referenced by SG::GroveI2CDigital::get_address_from_type(), SG::GroveBase::operator=(), and SG::GroveBase::operator==().

Here is the caller graph for this function:

◆ get_type_name()

virtual std::string SG::GroveBase::get_type_name ( void  ) const
inlinevirtualinherited

Return a short text string representing the grove type.

References SG::GroveBase::grove_type, and SG::to_string().

Referenced by SG::GroveBase::get_description().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_down()

bool SG::Button::is_down ( void  )
virtual

Determine if the button is currently pushed down.

References SG::SGpp::get(), SG::GpioManagement::get_bool(), and SG::SGpp::gpio.

Referenced by is_up(), and wait_for_button_up().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_grove_gpio()

virtual bool SG::GroveGPIO::is_grove_gpio ( void  ) const
inlinevirtualinherited

Determine if this is a Grove GPIO device.

See also
SG::GroveGPIO

Implements SG::GroveBase.

◆ is_grove_i2c()

virtual bool SG::GroveGPIO::is_grove_i2c ( void  ) const
inlinevirtualinherited

Determine if this is a Grove I2C device.

See also
SG::GroveI2C

Implements SG::GroveBase.

◆ is_grove_uart()

virtual bool SG::GroveGPIO::is_grove_uart ( void  ) const
inlinevirtualinherited

Determine if this is a Grove UART device.

See also
SG::GroveUART

Implements SG::GroveBase.

◆ is_up()

virtual bool SG::Button::is_up ( void  )
inlinevirtual

Determine if the button is currently up.

References is_down(), wait_for_button_down(), wait_for_button_up(), and wait_for_transition().

Referenced by button(), wait_for_button_down(), and wait_for_transition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=()

bool SG::GroveBase::operator!= ( const GroveBase rhs) const
inlineinherited

Test object equality.

References SG::GroveBase::operator==().

Here is the call graph for this function:

◆ operator==()

bool SG::GroveBase::operator== ( const GroveBase rhs) const
inherited

Test object equality.

References SG::GroveBase::get_name(), and SG::GroveBase::get_type().

Referenced by SG::GroveBase::operator!=(), SG::Buzzer::operator==(), SG::TemperatureAndHumiditySensor::operator==(), SG::TemperatureSensor::operator==(), and SG::I2CADC::operator==().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_2_bytes()

SG::GroveGPIO & SG::GroveGPIO::send_2_bytes ( uint16_t  bits)
virtualinherited

Send 16 bits (2 bytes).

References SG::GroveGPIO::send_byte().

Here is the call graph for this function:

◆ send_byte()

SG::GroveGPIO & SG::GroveGPIO::send_byte ( uint8_t  byte)
virtualinherited

Send a single byte.

References SG::SGpp::get(), SG::SGpp::gpio, SG::GpioManagement::set_high(), and SG::GpioManagement::set_low().

Referenced by SG::GroveGPIO::send_2_bytes(), and SG::ChainableRGBLED::turn_on().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wait_for_button()

virtual bool SG::Button::wait_for_button ( const size_t  timeout_in_milliseconds = 0)
inlinevirtual

Wait for any sort of user interaction with the button, either to the up or down state.

This is an alias for the method wait_for_transition().

Parameters
[in]timeout_in_millisecondsDetermines the length of time to wait for the button to change state. Will wait indefinitely if the timeout is set to zero.
Returns
Returns TRUE if a transition was detected, or FALSE if a timeout occurred.

Example code:

std::cout << "Press the button to continue." << std::endl;
button.wait_for_button();
See also
wait_for_button_up()
wait_for_button_down()

References wait_for_transition().

Here is the call graph for this function:

◆ wait_for_button_down()

bool SG::Button::wait_for_button_down ( const size_t  timeout_in_milliseconds = 0)
virtual

Wait for the button to be pressed down.

Returns immediately if the button is already down.

Parameters
[in]timeout_in_millisecondsDetermines the length of time to wait for a button push. Will wait indefinitely if the timeout is set to zero.
Returns
Returns TRUE if the button is pushed down, or FALSE if a timeout occurred.
See also
wait_for_button_up()
wait_for_button()

References is_up().

Referenced by button(), is_up(), and wait_for_transition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wait_for_button_up()

bool SG::Button::wait_for_button_up ( const size_t  timeout_in_milliseconds = 0)
virtual

Wait for the button to be released.

Returns immediately if the button is already up.

Parameters
[in]timeout_in_millisecondsDetermines the length of time to wait for the button to be released. Will wait indefinitely if the timeout is set to zero.
Returns
Returns TRUE if the button is up, or FALSE if a timeout occurred.
See also
wait_for_button_down()
wait_for_button()

References is_down().

Referenced by button(), is_up(), and wait_for_transition().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wait_for_transition()

bool SG::Button::wait_for_transition ( const size_t  timeout_in_milliseconds = 0)
virtual

Wait for the button to transition to up or down, depending on the current state.

Parameters
[in]timeout_in_millisecondsDetermines the length of time to wait for the button to change state. Will wait indefinitely if the timeout is set to zero.
Returns
Returns TRUE if a transition was detected, or FALSE if a timeout occurred.

References is_up(), wait_for_button_down(), and wait_for_button_up().

Referenced by is_up(), and wait_for_button().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ grove_name

std::string SG::GroveBase::grove_name
inherited

User-supplied name.

Referenced by SG::GroveBase::get_name(), and SG::GroveBase::operator=().

◆ grove_type


The documentation for this class was generated from the following files: