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

LED which can be turned on or off. More...

#include <sg_104020001_VariableColorLED.hpp>

Inheritance diagram for SG::VariableColorLED:
Collaboration diagram for SG::VariableColorLED:

Public Member Functions

virtual ~VariableColorLED (void)
 Destructor. More...
 
 VariableColorLED (const std::string &n="", const bool turn_off_at_destruction=false)
 Constructor. More...
 
VariableColorLEDturn_on (void)
 Turn the LED on. More...
 
VariableColorLEDturn_off (void)
 Turn the LED off. 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...
 
VariableColorLEDturn_on (const std::chrono::high_resolution_clock::duration &duration)
 Turn the LED on for a limited amount of time, then turn it off again. More...
 
VariableColorLEDturn_on (const size_t duration_in_milliseconds)
 Turn the LED on for a limited amount of time, then turn it off again. More...
 
VariableColorLEDturn_off (const std::chrono::high_resolution_clock::duration &duration)
 Turn the LED off for a limited amount of time, then turn it on again. More...
 
VariableColorLEDturn_off (const size_t duration_in_milliseconds)
 Turn the LED off for a limited amount of time, then turn it on again. More...
 
bool operator== (const GroveBase &rhs) const
 Test object equality. More...
 
bool operator!= (const GroveBase &rhs) const
 Test object equality. More...
 

Public Attributes

bool turn_off_LED_when_destructing
 Determines whether the destructor attempts to turn off the light. This can be specified in the constructor. More...
 
EGroveType grove_type
 Grove type. More...
 
std::string grove_name
 User-supplied name. More...
 

Detailed Description

LED which can be turned on or off.

The exact red, green, and blue component is determined by physical screws that must be turned on the back of the twig.

Description Image
Variable Color LED connected to the Grove UART interface.
sg_104020001_VariableColorLED.jpg
RGB adjustement screws on the back of the variable color LED.
sg_104020001_VariableColorLED_screws.jpg
Using a small screwdriver to adjust the colour of the LED.
sg_104020001_VariableColorLED_adjust.jpg
See also
http://www.seeedstudio.com/wiki/Grove_-_Variable_Color_LED
https://www.seeedstudio.com/item_detail.html?p_id=852
Note
This is not the same as the chainable RGB LED, SKU #104030006, SG::ChainableRGBLED. The colour on the chainable RGB LED can be set programmatically. The colour on the variable colour LED can only be set by turning tiny screws on the back of the twig.

Constructor & Destructor Documentation

◆ ~VariableColorLED()

SG::VariableColorLED::~VariableColorLED ( void  )
virtual

Destructor.

See also
turn_off_LED_when_destructing

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

Here is the call graph for this function:

◆ VariableColorLED()

SG::VariableColorLED::VariableColorLED ( const std::string &  n = "",
const bool  turn_off_at_destruction = false 
)

Constructor.

Parameters
[in]nUser-supplied name which can be used to identify this LED. The name can be anything, it isn't parsed by SG++.
[in]turn_off_at_destructionNormally when an object of this class is destructed, the LED retains the very last state ("colour"). If turn_off_at_destruction is set to true, then the LED will be turned off by the destructor.

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

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_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.

◆ 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:

◆ turn_off() [1/3]

SG::VariableColorLED & SG::VariableColorLED::turn_off ( void  )

Turn the LED off.

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

Referenced by turn_on(), variable_led(), and ~VariableColorLED().

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

◆ turn_off() [2/3]

SG::VariableColorLED & SG::VariableColorLED::turn_off ( const std::chrono::high_resolution_clock::duration &  duration)

Turn the LED off for a limited amount of time, then turn it on again.

This call is synchronous, and will not return until the LED has cycled off then on again. The duration should be more than 5 milliseconds, otherwise the LED may not behave as expected.

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

Here is the call graph for this function:

◆ turn_off() [3/3]

VariableColorLED& SG::VariableColorLED::turn_off ( const size_t  duration_in_milliseconds)
inline

Turn the LED off for a limited amount of time, then turn it on again.

This call is synchronous, and will not return until the LED has cycled off then on again. The duration should be more than 5 milliseconds, otherwise the LED may not behave as expected.

References turn_off().

Referenced by turn_off().

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

◆ turn_on() [1/3]

SG::VariableColorLED & SG::VariableColorLED::turn_on ( void  )

Turn the LED on.

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

Referenced by variable_led().

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

◆ turn_on() [2/3]

SG::VariableColorLED & SG::VariableColorLED::turn_on ( const std::chrono::high_resolution_clock::duration &  duration)

Turn the LED on for a limited amount of time, then turn it off again.

This call is synchronous, and will not return until the LED has cycled on then off again. The duration should be more than 5 milliseconds, otherwise the LED may not behave as expected.

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

Here is the call graph for this function:

◆ turn_on() [3/3]

VariableColorLED& SG::VariableColorLED::turn_on ( const size_t  duration_in_milliseconds)
inline

Turn the LED on for a limited amount of time, then turn it off again.

This call is synchronous, and will not return until the LED has cycled on then off again. The duration should be more than 5 milliseconds, otherwise the LED may not behave as expected.

References turn_off(), and turn_on().

Referenced by turn_on().

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

◆ turn_off_LED_when_destructing

bool SG::VariableColorLED::turn_off_LED_when_destructing

Determines whether the destructor attempts to turn off the light. This can be specified in the constructor.

Referenced by ~VariableColorLED().


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