128x64 EasyC OLED Display 1.0.0
This is a library for Soldered OLED Display
Loading...
Searching...
No Matches
Adafruit_I2CDevice Class Reference

#include <Adafruit_I2CDevice.h>

Public Member Functions

 Adafruit_I2CDevice (uint8_t addr, TwoWire *theWire=&Wire)
 Create an I2C device at a given address.
 
uint8_t address (void)
 Returns the 7-bit address of this device.
 
bool begin (bool addr_detect=true)
 Initializes and does basic address detection.
 
bool detected (void)
 Scans I2C for the address - note will give a false-positive if there's no pullups on I2C.
 
bool read (uint8_t *buffer, size_t len, bool stop=true)
 Read from I2C into a buffer from the I2C device. Cannot be more than maxBufferSize() bytes.
 
bool write (const uint8_t *buffer, size_t len, bool stop=true, const uint8_t *prefix_buffer=NULL, size_t prefix_len=0)
 Write a buffer or two to the I2C device. Cannot be more than maxBufferSize() bytes.
 
bool write_then_read (const uint8_t *write_buffer, size_t write_len, uint8_t *read_buffer, size_t read_len, bool stop=false)
 Write some data, then read some data from I2C into another buffer. Cannot be more than maxBufferSize() bytes. The buffers can point to same/overlapping locations.
 
bool setSpeed (uint32_t desiredclk)
 Change the I2C clock speed to desired (relies on underlying Wire support!
 
size_t maxBufferSize ()
 How many bytes we can read in a transaction.
 

Private Attributes

uint8_t _addr
 
TwoWire * _wire
 
bool _begun
 
size_t _maxBufferSize
 

Constructor & Destructor Documentation

◆ Adafruit_I2CDevice()

Adafruit_I2CDevice::Adafruit_I2CDevice ( uint8_t addr,
TwoWire * theWire = &Wire )

Create an I2C device at a given address.

Parameters
addrThe 7-bit I2C address for the device
theWireThe I2C bus to use, defaults to &Wire

Member Function Documentation

◆ address()

uint8_t Adafruit_I2CDevice::address ( void )

Returns the 7-bit address of this device.

Returns
The 7-bit address of this device

◆ begin()

bool Adafruit_I2CDevice::begin ( bool addr_detect = true)

Initializes and does basic address detection.

Parameters
addr_detectWhether we should attempt to detect the I2C address with a scan. 99% of sensors/devices don't mind but once in a while, they spaz on a scan!
Returns
True if I2C initialized and a device with the addr found

◆ detected()

bool Adafruit_I2CDevice::detected ( void )

Scans I2C for the address - note will give a false-positive if there's no pullups on I2C.

Returns
True if I2C initialized and a device with the addr found

◆ maxBufferSize()

size_t Adafruit_I2CDevice::maxBufferSize ( )
inline

How many bytes we can read in a transaction.

Returns
The size of the Wire receive/transmit buffer

◆ read()

bool Adafruit_I2CDevice::read ( uint8_t * buffer,
size_t len,
bool stop = true )

Read from I2C into a buffer from the I2C device. Cannot be more than maxBufferSize() bytes.

Parameters
bufferPointer to buffer of data to read into
lenNumber of bytes from buffer to read.
stopWhether to send an I2C STOP signal on read
Returns
True if read was successful, otherwise false.

◆ setSpeed()

bool Adafruit_I2CDevice::setSpeed ( uint32_t desiredclk)

Change the I2C clock speed to desired (relies on underlying Wire support!

Parameters
desiredclkThe desired I2C SCL frequency
Returns
True if this platform supports changing I2C speed. Not necessarily that the speed was achieved!

◆ write()

bool Adafruit_I2CDevice::write ( const uint8_t * buffer,
size_t len,
bool stop = true,
const uint8_t * prefix_buffer = NULL,
size_t prefix_len = 0 )

Write a buffer or two to the I2C device. Cannot be more than maxBufferSize() bytes.

Parameters
bufferPointer to buffer of data to write. This is const to ensure the content of this buffer doesn't change.
lenNumber of bytes from buffer to write
prefix_bufferPointer to optional array of data to write before buffer. Cannot be more than maxBufferSize() bytes. This is const to ensure the content of this buffer doesn't change.
prefix_lenNumber of bytes from prefix buffer to write
stopWhether to send an I2C STOP signal on write
Returns
True if write was successful, otherwise false.

◆ write_then_read()

bool Adafruit_I2CDevice::write_then_read ( const uint8_t * write_buffer,
size_t write_len,
uint8_t * read_buffer,
size_t read_len,
bool stop = false )

Write some data, then read some data from I2C into another buffer. Cannot be more than maxBufferSize() bytes. The buffers can point to same/overlapping locations.

Parameters
write_bufferPointer to buffer of data to write from
write_lenNumber of bytes from buffer to write.
read_bufferPointer to buffer of data to read into.
read_lenNumber of bytes from buffer to read.
stopWhether to send an I2C STOP signal between the write and read
Returns
True if write & read was successful, otherwise false.

Member Data Documentation

◆ _addr

uint8_t Adafruit_I2CDevice::_addr
private

◆ _begun

bool Adafruit_I2CDevice::_begun
private

◆ _maxBufferSize

size_t Adafruit_I2CDevice::_maxBufferSize
private

◆ _wire

TwoWire* Adafruit_I2CDevice::_wire
private

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