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

LCD RGB backlight. More...

#include <sg_104030001_LCDRGBBacklight.hpp>

Inheritance diagram for SG::LCDRGBBacklight:
Collaboration diagram for SG::LCDRGBBacklight:

Public Types

enum  ERegister {
  ERegister::kModeReg1 = 0,
  ERegister::kModeReg2 = 1,
  ERegister::kBrightLED0 = 2,
  ERegister::kBrightLED1 = 3,
  ERegister::kBrightLED2 = 4,
  ERegister::kBrightLED3 = 5,
  ERegister::kGroupDutyCycle = 6,
  ERegister::kGroupFrequency = 7,
  ERegister::kLEDOutputState = 8,
  ERegister::kI2CBusSubAddr1 = 9,
  ERegister::kI2CBusSubAddr2 = 10,
  ERegister::kI2CBusSubAddr3 = 11,
  ERegister::kLEDAllCallAddr = 12
}
 I2C registers. More...
 
typedef uint8_t I2CBus
 I2C bus. More...
 
typedef uint8_t I2CAddress
 I2C addresses. More...
 
typedef uint8_t I2CRegister
 I2C register. More...
 
typedef std::vector< uint8_t > I2CBlock
 Block of sequential bytes to read or write. More...
 

Public Member Functions

virtual bool is_analog (void) const
 This is always false for GroveI2CDigital. More...
 
virtual bool is_digital (void) const
 This is always true for GroveI2CDigital. More...
 
I2CAddress get_address_from_type (void) const
 Get the address for this Grove type. More...
 
virtual uint8_t read8 (const I2CRegister reg)
 Read a byte (8 bits) from the specificed register. More...
 
virtual uint16_t read16 (const I2CRegister reg)
 Read a 16-bit word from the specified register. More...
 
virtual uint16_t read12 (const I2CRegister reg)
 Read a 16-bit word from the specified register, but only keep the bottom 12 bits. More...
 
virtual I2CBlock read_block (const I2CRegister reg)
 Read a consecutive block of bytes, anywhere between 1 and 32 bytes in length. More...
 
virtual GroveI2CDigitalwrite_byte (const uint8_t value)
 Write a single byte to the I2C bus. More...
 
virtual GroveI2CDigitalwrite_block (const I2CRegister reg, const I2CBlock &v)
 Write a consecutive block of bytes, anywhere between 1 and 32 bytes in length. More...
 
virtual GroveI2CDigitalwrite_block (const I2CBlock &v)
 Write a consecutive block of bytes directly to the I2C file handle. More...
 
virtual bool is_grove_uart (void) const
 This is always false for GroveI2C. More...
 
virtual bool is_grove_i2c (void) const
 This is always true for GroveI2C. More...
 
virtual bool is_grove_gpio (void) const
 This is always false for GroveI2C. 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...
 
virtual GroveI2CDigitalwrite8 (const I2CRegister reg, const uint8_t value)
 Write the given value to the specified register. More...
 
virtual GroveI2CDigitalwrite16 (const I2CRegister reg, const uint16_t value)
 
bool operator== (const GroveBase &rhs) const
 Test object equality. More...
 
bool operator!= (const GroveBase &rhs) const
 Test object equality. More...
 

Static Public Member Functions

static I2CBus detect_i2c_bus_number (const bool force_detect=false, const int force_bus_number=-1)
 Detect the I2C bus to use to talk to Grove I2C devices. More...
 
static I2CAddress get_address_from_type (const EGroveType &type)
 Get the default I2C address for a given type. More...
 

Public Attributes

I2CBus i2c_bus_number
 The bus number to use for I2C Grove twigs. More...
 
I2CAddress i2c_address
 The I2C address used to communicate with the Grove device. More...
 
int i2c_file_handle
 The file handle to /dev/i2c-* used to communicate with the Grove device. More...
 
EGroveType grove_type
 Grove type. More...
 
std::string grove_name
 User-supplied name. More...
 

Detailed Description

LCD RGB backlight.

Description Image
LCD RGB backlight connected to BBG.
sg_101030001_LCDRGBBacklight.jpg

Connect the LCD RGB backlight to the left-hand-side digital I2C interface. There are several I2C addresses for this device: 0x3e, 0x62, 0x70.

i2cdetect -y -r 2
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- *-- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 3e --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- --
60: -- -- 62 -- -- -- -- -- -- -- -- -- -- -- -- --
70: 70 -- -- -- -- -- -- --
I2C Address Description Source
0x3e JHD1214 LCD module, 16 characters x 2 lines JHD1214 data sheet, section 8, page 12
0x62 PCA9633 LED regular I2C-bus slave address PCA9633 data sheet, section 7.1.1, page 8
0x70 PCA9633 LED All Call address PCA9633 data sheet, section 7.1.1, page 8
See also
http://www.seeedstudio.com/item_detail.html?p_id=1643
http://www.seeedstudio.com/wiki/Grove_-_LCD_RGB_Backlight
http://www.seeedstudio.com/wiki/images/0/03/JHD1214Y_YG_1.0.pdf
http://www.seeedstudio.com/wiki/images/1/1c/PCA9633.pdf

Member Typedef Documentation

◆ I2CAddress

typedef uint8_t SG::GroveI2CDigital::I2CAddress
inherited

I2C addresses.

See also
get_address_from_type()

◆ I2CBlock

typedef std::vector<uint8_t> SG::GroveI2CDigital::I2CBlock
inherited

Block of sequential bytes to read or write.

◆ I2CBus

typedef uint8_t SG::GroveI2CDigital::I2CBus
inherited

I2C bus.

See also
detect_i2c_bus_number()

◆ I2CRegister

typedef uint8_t SG::GroveI2CDigital::I2CRegister
inherited

I2C register.

Member Enumeration Documentation

◆ ERegister

I2C registers.

See also
PCA9633 datasheet page 11
Enumerator
kModeReg1 
kModeReg2 
kBrightLED0 
kBrightLED1 
kBrightLED2 
kBrightLED3 
kGroupDutyCycle 
kGroupFrequency 
kLEDOutputState 
kI2CBusSubAddr1 
kI2CBusSubAddr2 
kI2CBusSubAddr3 
kLEDAllCallAddr 

Member Function Documentation

◆ detect_i2c_bus_number()

SG::GroveI2CDigital::I2CBus SG::GroveI2CDigital::detect_i2c_bus_number ( const bool  force_detect = false,
const int  force_bus_number = -1 
)
staticinherited

Detect the I2C bus to use to talk to Grove I2C devices.

This is normally 1 or 2. The detection consists of looking at /dev/i2c* devices.

Parameters
[in]force_detectThe detected bus number is usually remembered to prevent having to re-detect it every time a new GroveI2C object is instantiated. If force_detect is set to true, then this will force GroveI2C to ignore the previously cached bus number and re-detect the I2C bus.
[in]force_bus_numberIf an explicit bus number should be used, then force_bus_number can be set to the correct bus value. This will prevent calls to detect_i2c_bus_number() from attempting to auto-detect the I2C bus. Setting the I2C bus number this way wont change existing GroveI2C objects that have already been instantiated. Only new objects will use the new bus number. The actual bus number used by specific objects is i2c_bus_number.
Exceptions
std::system_errorif /dev cannot be opened.
std::runtime_errorif the I2C bus cannot be found in /dev.

Referenced by SG::GroveI2CDigital::is_digital().

Here is the caller graph for this function:

◆ get_address_from_type() [1/2]

◆ get_address_from_type() [2/2]

I2CAddress SG::GroveI2CDigital::get_address_from_type ( void  ) const
inlineinherited

Get the address for this Grove type.

References SG::GroveI2CDigital::get_address_from_type(), SG::GroveBase::get_type(), SG::GroveI2CDigital::read16(), and SG::GroveI2CDigital::read8().

Referenced by SG::GroveI2CDigital::get_address_from_type(), SG::GroveI2CDigital::GroveI2CDigital(), and SG::GroveI2CDigital::is_digital().

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

◆ 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_analog()

virtual bool SG::GroveI2CDigital::is_analog ( void  ) const
inlinevirtualinherited

This is always false for GroveI2CDigital.

Implements SG::GroveI2C.

◆ is_digital()

virtual bool SG::GroveI2CDigital::is_digital ( void  ) const
inlinevirtualinherited

This is always true for GroveI2CDigital.

Implements SG::GroveI2C.

References SG::GroveI2CDigital::detect_i2c_bus_number(), and SG::GroveI2CDigital::get_address_from_type().

Here is the call graph for this function:

◆ is_grove_gpio()

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

This is always false for GroveI2C.

Implements SG::GroveBase.

References SG::GroveI2C::is_analog(), and SG::GroveI2C::is_digital().

Here is the call graph for this function:

◆ is_grove_i2c()

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

This is always true for GroveI2C.

Implements SG::GroveBase.

◆ is_grove_uart()

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

This is always false for GroveI2C.

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:

◆ read12()

virtual uint16_t SG::GroveI2CDigital::read12 ( const I2CRegister  reg)
inlinevirtualinherited

Read a 16-bit word from the specified register, but only keep the bottom 12 bits.

Some devices such as the I2CADC return 12-bit values.

References SG::GroveI2CDigital::read16(), SG::GroveI2CDigital::read_block(), SG::GroveI2CDigital::write16(), SG::GroveI2CDigital::write8(), SG::GroveI2CDigital::write_block(), and SG::GroveI2CDigital::write_byte().

Referenced by SG::I2CADC::read12().

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

◆ read16()

uint16_t SG::GroveI2CDigital::read16 ( const I2CRegister  reg)
virtualinherited

Read a 16-bit word from the specified register.

Exceptions
std::system_errorif the register cannot be read.
Note
The high/low bytes in the 16-bit word are swapped after reading.

Referenced by SG::GroveI2CDigital::get_address_from_type(), and SG::GroveI2CDigital::read12().

Here is the caller graph for this function:

◆ read8()

uint8_t SG::GroveI2CDigital::read8 ( const I2CRegister  reg)
virtualinherited

Read a byte (8 bits) from the specificed register.

Exceptions
std::system_errorif the register cannot be read.

Referenced by SG::GroveI2CDigital::get_address_from_type(), SG::ThreeAxisDigitalCompass::get_config(), SG::ThreeAxisDigitalCompass::get_data(), SG::ThreeAxisDigitalCompass::get_mode(), SG::ThreeAxisDigitalCompass::get_status(), and SG::I2CADC::read8().

Here is the caller graph for this function:

◆ read_block()

SG::GroveI2CDigital::I2CBlock SG::GroveI2CDigital::read_block ( const I2CRegister  reg)
virtualinherited

Read a consecutive block of bytes, anywhere between 1 and 32 bytes in length.

See also
write_block()
Exceptions
std::system_errorif the register cannot be read.

Referenced by SG::GroveI2CDigital::read12().

Here is the caller graph for this function:

◆ write16()

SG::GroveI2CDigital & SG::GroveI2CDigital::write16 ( const I2CRegister  reg,
const uint16_t  value 
)
virtualinherited
Note
The high/low bytes in the 16-bit word are swapped prior to writting.
Exceptions
std::system_errorif the value cannot be written.

Referenced by SG::GroveI2CDigital::read12(), and SG::I2CADC::write16().

Here is the caller graph for this function:

◆ write8()

SG::GroveI2CDigital & SG::GroveI2CDigital::write8 ( const I2CRegister  reg,
const uint8_t  value 
)
virtualinherited

Write the given value to the specified register.

Exceptions
std::system_errorif the value cannot be written.

Referenced by SG::GroveI2CDigital::read12(), SG::ThreeAxisDigitalCompass::set_config(), SG::ThreeAxisDigitalCompass::set_mode(), and SG::I2CADC::write8().

Here is the caller graph for this function:

◆ write_block() [1/2]

SG::GroveI2CDigital & SG::GroveI2CDigital::write_block ( const I2CRegister  reg,
const I2CBlock v 
)
virtualinherited

Write a consecutive block of bytes, anywhere between 1 and 32 bytes in length.

See also
read_block()
Exceptions
std::length_errorif the block is too long to write.
std::system_errorif the block failed to write.

References SG::GroveBase::get_description(), SG::GroveI2CDigital::i2c_address, and SG::BeagleBone::Detect::to_string().

Referenced by SG::CommonOLED::flood(), SG::GroveI2CDigital::read12(), SG::OLED096::reset(), SG::CommonOLED::send_command(), SG::CommonOLED::set_display_bitmap(), SG::CommonOLED::set_orientation(), and SG::CommonOLED::show().

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

◆ write_block() [2/2]

SG::GroveI2CDigital & SG::GroveI2CDigital::write_block ( const I2CBlock v)
virtualinherited

Write a consecutive block of bytes directly to the I2C file handle.

Exceptions
std::system_errorif the block failed to write.

References SG::GroveBase::get_description(), SG::GroveI2CDigital::i2c_address, SG::GroveI2CDigital::i2c_file_handle, and SG::BeagleBone::Detect::to_string().

Here is the call graph for this function:

◆ write_byte()

SG::GroveI2CDigital & SG::GroveI2CDigital::write_byte ( const uint8_t  value)
virtualinherited

Write a single byte to the I2C bus.

Exceptions
std::system_errorif the value cannot be writen.

Referenced by SG::OLED096::all_off_display(), SG::OLED096::all_on_display(), SG::OLED096::invert_display(), SG::OLED096::normal_display(), SG::GroveI2CDigital::read12(), and SG::CommonOLED::set_display_bitmap().

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

◆ i2c_address

I2CAddress SG::GroveI2CDigital::i2c_address
inherited

The I2C address used to communicate with the Grove device.

Referenced by SG::GroveI2CDigital::GroveI2CDigital(), SG::I2CADC::operator==(), and SG::GroveI2CDigital::write_block().

◆ i2c_bus_number

I2CBus SG::GroveI2CDigital::i2c_bus_number
inherited

The bus number to use for I2C Grove twigs.

The exposed I2C bus is usually 1 or 2. This is normally auto-detected by detect_i2c_bus_number() called by the constructor, and doesn't need to be manually set.

Referenced by SG::GroveI2CDigital::GroveI2CDigital().

◆ i2c_file_handle

int SG::GroveI2CDigital::i2c_file_handle
inherited

The file handle to /dev/i2c-* used to communicate with the Grove device.

Referenced by SG::GroveI2CDigital::GroveI2CDigital(), SG::GroveI2CDigital::write_block(), and SG::GroveI2CDigital::~GroveI2CDigital().


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