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

I2C 1.12" rectangular OLED display. More...

#include <sg_104030008_OLED112.hpp>

Inheritance diagram for SG::OLED112:
Collaboration diagram for SG::OLED112:

Public Types

enum  EOrientation {
  EOrientation::kInvalid = 0,
  EOrientation::kLandscape,
  EOrientation::kPortrait,
  EOrientation::kLandscape180,
  EOrientation::kPortrait180
}
 Orientation for the display. 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 ~OLED112 (void)
 Destructor. More...
 
 OLED112 (const std::string &name="", const SG::GroveI2CDigital::I2CAddress addr=0)
 Constructor. If not specified, the I2C address will be obtained using get_address_from_type(). More...
 
virtual size_t pixel_width (void) const
 Get the width in pixels. This always returns 128 for the 1.12" OLED. More...
 
virtual size_t pixel_height (void) const
 Get the height in pixels. This always returns 64 for the 1.12" OLED. More...
 
virtual size_t pixel_depth (void) const
 Get the number of bits per pixel. This always returns 1 (meaning each pixel is either on or off) for the 1.12" OLED. More...
 
virtual size_t memory_width (void) const
 Get the number of pixels that can be stored in memory. This always returns 128 for the 1.12" OLED. More...
 
virtual size_t memory_height (void) const
 Get the number of pixels that can be stored in memory. This always returns 64 for the 1.12" OLED. More...
 
virtual size_t memory_depth (void) const
 Get the number of bits each pixel occupies in memory. This always returns 1 for the 1.12" OLED. More...
 
virtual OLED112reset (void)
 Reset the OLED. More...
 
virtual OLED112clear_screen (void)
 Set all of the GDDRAM to 0x00 to clear the screen. More...
 
virtual CommonOLEDturn_on (void)
 Turn ON the OLED. More...
 
virtual CommonOLEDturn_off (void)
 turn OFF the OLED. More...
 
virtual CommonOLEDset_contrast (const uint8_t level=0x7f)
 Set the contrast level to a value between 0 and 255. More...
 
virtual CommonOLEDlock (void)
 Lock the OLED driver IC MCU. Once locked, the only command that will be accepted is unlock(). All other commands and memory access are ignored. More...
 
virtual CommonOLEDunlock (void)
 Unlock the OLED driver IC MCU. More...
 
virtual CommonOLEDstart_scrolling (void)
 Start horizontal scrolling. Multiple calls can be made to start_scrolling() and stop_scrolling() to start and stop scrolling multiple times. More...
 
virtual CommonOLEDstop_scrolling (void)
 
virtual CommonOLEDsend_command (const uint8_t cmd)
 Stop horizontal scrolling. More...
 
virtual CommonOLEDsend_command (const uint8_t cmd, const uint8_t value)
 Send a command with an additional 1-byte parameter. More...
 
virtual CommonOLEDset_XY (const uint8_t x=0, const uint8_t y=0)
 
virtual CommonOLEDflood (const I2CBlock &pattern)
 Repeat the given pattern until it fills up the entire OLED. More...
 
virtual CommonOLEDfade_white_to_black (const size_t milliseconds_between_transitions=500)
 Fade from white to black. More...
 
virtual CommonOLEDfade_black_to_white (const size_t milliseconds_between_transitions=500)
 Fade from black to white. More...
 
virtual I2CBlock get_display_bitmap (void)
 Get the full display bitmap. More...
 
virtual CommonOLEDset_display_bitmap (const I2CBlock &block)
 Set the full display bitmap. More...
 
virtual EOrientation get_orientation (void) const
 Return the current orientation. The default after reset() is EOrientation::kLandscape. More...
 
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 OLED112normal_display (void)
 Toggle the various display modes. More...
 
virtual OLED112all_on_display (void)
 All pixels set ON. More...
 
virtual OLED112all_off_display (void)
 All pixels set OFF. More...
 
virtual OLED112do_not_invert_display (void)
 Do not invert display. More...
 
virtual OLED112invert_display (void)
 Invert display mode. More...
 
virtual CommonOLEDset_font (const Font::EType type=SG::Font::EType::k8x8CapRouge)
 Set a font to use when writing text to the OLED. By default, if not explicitely set, the font used will be SG::Font::CapRouge. More...
 
virtual CommonOLEDset_font (std::shared_ptr< SG::Font::Monospace > font_to_use)
 
virtual CommonOLEDshow (const char c)
 Display the given text. More...
 
virtual CommonOLEDshow (const std::string &str)
 Display the given text. More...
 
bool is_portrait (void) const
 Quickly determine if the OLED is in portrait or landscape mode. More...
 
bool is_landscape (void) const
 Quickly determine if the OLED is in portrait or landscape mode. More...
 
virtual CommonOLEDrotate_90 (void)
 Set the orientation for the display. More...
 
virtual CommonOLEDrotate_180 (void)
 Set the orientation for the display. More...
 
virtual CommonOLEDrotate_270 (void)
 Set the orientation for the display. More...
 
virtual CommonOLEDset_orientation (const EOrientation new_orientation=EOrientation::kLandscape)
 
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...
 

Protected Attributes

EOrientation orientation
 Landscape or portrait mode. More...
 
std::shared_ptr< Font::Monospacefont
 Font used when writing text to the OLED. Default is SG::Font::CapRouge. More...
 
Font::Monospace::Fontmap font_map
 Font used when writing text to the OLED. Default is SG::Font::CapRouge. More...
 

Detailed Description

I2C 1.12" rectangular OLED display.

This I2C Grove twig has 128 pixels across and 64 pixels in height, each of which is exactly 1 bit in depth. With a typical 8x8 font, this means you can display 8 lines of text, each one with 16 characters, for a total of 128 characters of text. This OLED is exactly half the height of OLED096.

The following measurements are approximate:

Description Dimension (Imperial) Dimension (Metric)
total width 1.5" 3.8 cm
total height 0.75" 1.9 cm
display width 1" 2.5 cm
display height 0.5" 1.3 cm
Warning
The Seeed web site and wiki has conflicting and/or confusing information on this device, including some wiki links to the wrong device image. The SSD1308 driver IC has a 128 x 64 bit memory buffer, for a total of 1 KiB of memory, and this Grove twig has a display with exactly 8192 pixels (128 x 64). It is rectangular in shape, not square.
Description Image
OLED with sample text.
sg_104030008_OLED112.jpg

Connect the OLED display to the left-hand-side I2C interface. The I2C address for this I2C device is 0x3c.

i2cdetect -y -r 2
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
See also
SG::OLED096
http://www.seeedstudio.com/wiki/Grove_-_OLED_Display_128%2A64
http://www.seeedstudio.com/depot/grove-oled-display-12864-p-781.html
http://garden.seeedstudio.com/images/4/46/SSD1308_1.0.pdf
http://garden.seeedstudio.com/images/c/c4/LY190-128064.pdf

Member Typedef Documentation

typedef uint8_t SG::GroveI2CDigital::I2CAddress
inherited

I2C addresses.

See also
get_address_from_type()
typedef std::vector<uint8_t> SG::GroveI2CDigital::I2CBlock
inherited

Block of sequential bytes to read or write.

typedef uint8_t SG::GroveI2CDigital::I2CBus
inherited

I2C bus.

See also
detect_i2c_bus_number()
typedef uint8_t SG::GroveI2CDigital::I2CRegister
inherited

I2C register.

Member Enumeration Documentation

enum SG::CommonOLED::EOrientation
stronginherited

Orientation for the display.

Enumerator
kInvalid 
kLandscape 
kPortrait 
kLandscape180 

"upside-down" landscape

kPortrait180 

"upside-down" portrait

Constructor & Destructor Documentation

SG::OLED112::~OLED112 ( void  )
virtual

Destructor.

SG::OLED112::OLED112 ( const std::string &  name = "",
const SG::GroveI2CDigital::I2CAddress  addr = 0 
)

Constructor. If not specified, the I2C address will be obtained using get_address_from_type().

Member Function Documentation

virtual OLED112& SG::OLED112::all_off_display ( void  )
inlinevirtual

All pixels set OFF.

Warning
This command is not supported by the 1.12" OLED.

Implements SG::CommonOLED.

virtual OLED112& SG::OLED112::all_on_display ( void  )
inlinevirtual

All pixels set ON.

See also
normal_display()

Implements SG::CommonOLED.

References SG::CommonOLED::send_command().

Here is the call graph for this function:

SG::OLED112 & SG::OLED112::clear_screen ( void  )
virtual

Set all of the GDDRAM to 0x00 to clear the screen.

Implements SG::CommonOLED.

References SG::CommonOLED::flood(), pixel_height(), pixel_width(), and SG::CommonOLED::stop_scrolling().

Referenced by invert_display(), and reset().

Here is the call graph for this function:

Here is the caller graph for this function:

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:

virtual OLED112& SG::OLED112::do_not_invert_display ( void  )
inlinevirtual

Do not invert display.

See also
invert_display()

References SG::CommonOLED::send_command().

Referenced by reset().

Here is the call graph for this function:

Here is the caller graph for this function:

SG::CommonOLED & SG::CommonOLED::fade_black_to_white ( const size_t  milliseconds_between_transitions = 500)
virtualinherited

Fade from black to white.

There are 4 transitions, so the default 500 millisecond pause between each transition means a total time of 2 seconds before this function returns.

See also
fade_white_to_black()

References SG::CommonOLED::flood().

Referenced by reset(), and SG::CommonOLED::stop_scrolling().

Here is the call graph for this function:

Here is the caller graph for this function:

SG::CommonOLED & SG::CommonOLED::fade_white_to_black ( const size_t  milliseconds_between_transitions = 500)
virtualinherited

Fade from white to black.

There are 4 transitions, so the default 500 millisecond pause between each transition means a total time of 2 seconds before this function returns.

See also
fade_black_to_white()

References SG::CommonOLED::flood().

Referenced by reset(), and SG::CommonOLED::stop_scrolling().

Here is the call graph for this function:

Here is the caller graph for this function:

SG::CommonOLED & SG::CommonOLED::flood ( const I2CBlock pattern)
virtualinherited

Repeat the given pattern until it fills up the entire OLED.

References SG::CommonOLED::clear_screen(), SG::CommonOLED::pixel_height(), SG::CommonOLED::pixel_width(), SG::CommonOLED::set_XY(), and SG::GroveI2CDigital::write_block().

Referenced by clear_screen(), SG::CommonOLED::fade_black_to_white(), SG::CommonOLED::fade_white_to_black(), and SG::CommonOLED::stop_scrolling().

Here is the call graph for this function:

Here is the caller graph for this function:

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:

SG::GroveI2CDigital::I2CBlock SG::CommonOLED::get_display_bitmap ( void  )
virtualinherited

Get the full display bitmap.

The display contains 128 x 128 pixels, and each pixels has 4 bits, for a total of 65536 bits, or 8192 bytes (8 KiB).

Todo:
TODO BOOOO booooo

Referenced by SG::CommonOLED::stop_scrolling().

Here is the caller graph for this function:

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:

virtual EOrientation SG::CommonOLED::get_orientation ( void  ) const
inlinevirtualinherited

Return the current orientation. The default after reset() is EOrientation::kLandscape.

References SG::CommonOLED::orientation.

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:

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:

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:

virtual OLED112& SG::OLED112::invert_display ( void  )
inlinevirtual

Invert display mode.

See also
do_not_invert_display()

Implements SG::CommonOLED.

References clear_screen(), reset(), and SG::CommonOLED::send_command().

Here is the call graph for this function:

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

This is always false for GroveI2CDigital.

Implements SG::GroveI2C.

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:

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:

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

This is always true for GroveI2C.

Implements SG::GroveBase.

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

This is always false for GroveI2C.

Implements SG::GroveBase.

bool SG::CommonOLED::is_landscape ( void  ) const
inlineinherited

Quickly determine if the OLED is in portrait or landscape mode.

References SG::CommonOLED::kLandscape, SG::CommonOLED::kLandscape180, SG::CommonOLED::orientation, SG::CommonOLED::rotate_180(), SG::CommonOLED::rotate_270(), SG::CommonOLED::rotate_90(), and SG::CommonOLED::set_orientation().

Here is the call graph for this function:

bool SG::CommonOLED::is_portrait ( void  ) const
inlineinherited

Quickly determine if the OLED is in portrait or landscape mode.

References SG::CommonOLED::kPortrait, SG::CommonOLED::kPortrait180, and SG::CommonOLED::orientation.

Referenced by SG::CommonOLED::show().

Here is the caller graph for this function:

virtual CommonOLED& SG::CommonOLED::lock ( void  )
inlinevirtualinherited

Lock the OLED driver IC MCU. Once locked, the only command that will be accepted is unlock(). All other commands and memory access are ignored.

References SG::CommonOLED::send_command().

Referenced by common_oled().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual size_t SG::OLED112::memory_depth ( void  ) const
inlinevirtual

Get the number of bits each pixel occupies in memory. This always returns 1 for the 1.12" OLED.

Implements SG::CommonOLED.

virtual size_t SG::OLED112::memory_height ( void  ) const
inlinevirtual

Get the number of pixels that can be stored in memory. This always returns 64 for the 1.12" OLED.

Implements SG::CommonOLED.

virtual size_t SG::OLED112::memory_width ( void  ) const
inlinevirtual

Get the number of pixels that can be stored in memory. This always returns 128 for the 1.12" OLED.

Implements SG::CommonOLED.

virtual OLED112& SG::OLED112::normal_display ( void  )
inlinevirtual

Toggle the various display modes.

Normal display mode.

Implements SG::CommonOLED.

References SG::CommonOLED::send_command().

Referenced by reset().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Test object equality.

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

Here is the call graph for this function:

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:

virtual size_t SG::OLED112::pixel_depth ( void  ) const
inlinevirtual

Get the number of bits per pixel. This always returns 1 (meaning each pixel is either on or off) for the 1.12" OLED.

Implements SG::CommonOLED.

virtual size_t SG::OLED112::pixel_height ( void  ) const
inlinevirtual

Get the height in pixels. This always returns 64 for the 1.12" OLED.

Implements SG::CommonOLED.

Referenced by clear_screen().

Here is the caller graph for this function:

virtual size_t SG::OLED112::pixel_width ( void  ) const
inlinevirtual

Get the width in pixels. This always returns 128 for the 1.12" OLED.

Implements SG::CommonOLED.

Referenced by clear_screen().

Here is the caller graph for this function:

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:

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.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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.

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

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 call graph for this function:

Here is the caller graph for this function:

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.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

SG::OLED112 & SG::OLED112::reset ( void  )
virtual

Reset the OLED.

The OLED112 uses the Solomon Systech SSD1308 (128x64 dot matrix). Inspiration for the commands in reset() came from LY190-128064.pdf section 9.4. Additional details came from SSD1308_1.0.pdf sections 8-9, pages 27-44.

Implements SG::CommonOLED.

References clear_screen(), do_not_invert_display(), SG::CommonOLED::fade_black_to_white(), SG::CommonOLED::fade_white_to_black(), SG::Font::k8x8CapRouge, SG::Font::k8x8CourierNew, SG::CommonOLED::kLandscape, normal_display(), SG::CommonOLED::send_command(), SG::CommonOLED::set_contrast(), SG::CommonOLED::set_font(), SG::CommonOLED::set_orientation(), SG::CommonOLED::set_XY(), SG::CommonOLED::show(), SG::CommonOLED::stop_scrolling(), SG::CommonOLED::turn_off(), SG::CommonOLED::turn_on(), and SG::CommonOLED::unlock().

Referenced by invert_display().

Here is the call graph for this function:

Here is the caller graph for this function:

SG::CommonOLED & SG::CommonOLED::rotate_180 ( void  )
virtualinherited

Set the orientation for the display.

References SG::CommonOLED::kLandscape, SG::CommonOLED::kLandscape180, SG::CommonOLED::kPortrait, SG::CommonOLED::kPortrait180, SG::CommonOLED::orientation, and SG::CommonOLED::set_orientation().

Referenced by SG::CommonOLED::is_landscape().

Here is the call graph for this function:

Here is the caller graph for this function:

SG::CommonOLED & SG::CommonOLED::rotate_270 ( void  )
virtualinherited

Set the orientation for the display.

References SG::CommonOLED::kLandscape, SG::CommonOLED::kLandscape180, SG::CommonOLED::kPortrait, SG::CommonOLED::kPortrait180, SG::CommonOLED::orientation, and SG::CommonOLED::set_orientation().

Referenced by SG::CommonOLED::is_landscape().

Here is the call graph for this function:

Here is the caller graph for this function:

SG::CommonOLED & SG::CommonOLED::rotate_90 ( void  )
virtualinherited

Set the orientation for the display.

References SG::CommonOLED::kLandscape, SG::CommonOLED::kLandscape180, SG::CommonOLED::kPortrait, SG::CommonOLED::kPortrait180, SG::CommonOLED::orientation, and SG::CommonOLED::set_orientation().

Referenced by SG::CommonOLED::is_landscape().

Here is the call graph for this function:

Here is the caller graph for this function:

SG::CommonOLED & SG::CommonOLED::send_command ( const uint8_t  cmd)
virtualinherited

Stop horizontal scrolling.

See also
setup_scrolling()
start_scrolling() Send a single-byte command that doesn't have any parameters.

References SG::GroveI2CDigital::write_block().

Referenced by all_on_display(), do_not_invert_display(), invert_display(), SG::CommonOLED::lock(), normal_display(), reset(), SG::CommonOLED::set_contrast(), SG::CommonOLED::start_scrolling(), SG::CommonOLED::stop_scrolling(), SG::CommonOLED::turn_off(), SG::CommonOLED::turn_on(), and SG::CommonOLED::unlock().

Here is the call graph for this function:

Here is the caller graph for this function:

SG::CommonOLED & SG::CommonOLED::send_command ( const uint8_t  cmd,
const uint8_t  value 
)
virtualinherited

Send a command with an additional 1-byte parameter.

References SG::GroveI2CDigital::write_block().

Here is the call graph for this function:

virtual CommonOLED& SG::CommonOLED::set_contrast ( const uint8_t  level = 0x7f)
inlinevirtualinherited

Set the contrast level to a value between 0 and 255.

Parameters
[in]levelDefault level is 127 (0x7f). 0 is dark, and 255 is bright.

References SG::CommonOLED::send_command().

Referenced by common_oled(), and reset().

Here is the call graph for this function:

Here is the caller graph for this function:

SG::CommonOLED & SG::CommonOLED::set_display_bitmap ( const I2CBlock block)
virtualinherited

Set the full display bitmap.

Parameters
[in]blockMust be exactly 8192 bytes to represent 128 x 128 pixels x 4 bits grayscale.

References SG::GroveBase::get_description(), SG::GroveI2CDigital::write_block(), and SG::GroveI2CDigital::write_byte().

Referenced by SG::CommonOLED::stop_scrolling().

Here is the call graph for this function:

Here is the caller graph for this function:

SG::CommonOLED & SG::CommonOLED::set_font ( const Font::EType  type = SG::Font::EType::k8x8CapRouge)
virtualinherited

Set a font to use when writing text to the OLED. By default, if not explicitely set, the font used will be SG::Font::CapRouge.

Fonts included with SG++:

CapRouge_8x8.png
8x8 Cap Rouge
CourierNew_8x8.png
8x8 Courier New
DejaVuSansMono_8x8.png
8x8 DejaVu Sans
UbuntuMono_8x8.png
8x8 Ubuntu Mono
See also
SG::Font::EType
SG::Font::get()

References SG::Font::get().

Referenced by SG::CommonOLED::CommonOLED(), reset(), and SG::CommonOLED::stop_scrolling().

Here is the call graph for this function:

Here is the caller graph for this function:

SG::CommonOLED & SG::CommonOLED::set_font ( std::shared_ptr< SG::Font::Monospace font_to_use)
virtualinherited

For example:

SG::OLED112 oled( "test grove" );
oled.reset();
set_font( user_supplied_font );
oled.show( "hello" );

References SG::CommonOLED::font, and SG::CommonOLED::font_map.

SG::CommonOLED & SG::CommonOLED::set_orientation ( const EOrientation  new_orientation = EOrientation::kLandscape)
virtualinherited
SG::CommonOLED & SG::CommonOLED::set_XY ( const uint8_t  x = 0,
const uint8_t  y = 0 
)
virtualinherited

Referenced by SG::CommonOLED::flood(), reset(), and SG::CommonOLED::stop_scrolling().

Here is the caller graph for this function:

SG::CommonOLED & SG::CommonOLED::show ( const char  c)
virtualinherited

Display the given text.

Exceptions
std::runtime_errorif the font bitmap is the wrong size.

References SG::CommonOLED::font, SG::CommonOLED::font_map, SG::CommonOLED::is_portrait(), SG::BeagleBone::Detect::to_string(), and SG::GroveI2CDigital::write_block().

Referenced by reset(), SG::CommonOLED::show(), and SG::CommonOLED::stop_scrolling().

Here is the call graph for this function:

Here is the caller graph for this function:

SG::CommonOLED & SG::CommonOLED::show ( const std::string &  str)
virtualinherited

Display the given text.

Exceptions
std::runtime_errorif the font bitmap is the wrong size.

References SG::CommonOLED::show().

Here is the call graph for this function:

virtual CommonOLED& SG::CommonOLED::start_scrolling ( void  )
inlinevirtualinherited

Start horizontal scrolling. Multiple calls can be made to start_scrolling() and stop_scrolling() to start and stop scrolling multiple times.

See also
setup_scrolling()
stop_scrolling()

References SG::CommonOLED::send_command().

Referenced by common_oled().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual CommonOLED& SG::CommonOLED::turn_off ( void  )
inlinevirtualinherited

turn OFF the OLED.

References SG::CommonOLED::send_command().

Referenced by common_oled(), and reset().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual CommonOLED& SG::CommonOLED::turn_on ( void  )
inlinevirtualinherited

Turn ON the OLED.

References SG::CommonOLED::send_command().

Referenced by common_oled(), SG::OLED096::reset(), and reset().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual CommonOLED& SG::CommonOLED::unlock ( void  )
inlinevirtualinherited

Unlock the OLED driver IC MCU.

See also
lock()

References SG::CommonOLED::send_command().

Referenced by common_oled(), and reset().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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, SG::GroveI2CDigital::i2c_file_handle, 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:

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:

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.

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

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 call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

std::shared_ptr<Font::Monospace> SG::CommonOLED::font
protectedinherited

Font used when writing text to the OLED. Default is SG::Font::CapRouge.

See also
set_font()

Referenced by SG::CommonOLED::set_font(), and SG::CommonOLED::show().

Font::Monospace::Fontmap SG::CommonOLED::font_map
protectedinherited

Font used when writing text to the OLED. Default is SG::Font::CapRouge.

See also
set_font()

Referenced by SG::CommonOLED::set_font(), and SG::CommonOLED::show().

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

User-supplied name.

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

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().


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