MatrixMiniR4 1.1.5
Matrix Mini R4 Arduino Library API Documentation
Loading...
Searching...
No Matches
Adafruit_I2CDevice Class Reference

Adafruit I2CDevice Class for OLED. More...

#include <MiniR4_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.
 
void end (void)
 De-initialize device, turn off the Wire interface.
 
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=nullptr, 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.
 

Detailed Description

Adafruit I2CDevice Class for OLED.

The class which defines how we will talk to this device over I2C

Definition at line 43 of file MiniR4_I2CDevice.h.

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

Definition at line 39 of file MiniR4_I2CDevice.cpp.

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

Definition at line 287 of file MiniR4_I2CDevice.cpp.

◆ 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 don't respond well to a scan!
Returns
True if I2C initialized and a device with the addr found

Definition at line 59 of file MiniR4_I2CDevice.cpp.

◆ 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

Definition at line 91 of file MiniR4_I2CDevice.cpp.

◆ end()

void Adafruit_I2CDevice::end ( void )

De-initialize device, turn off the Wire interface.

Definition at line 72 of file MiniR4_I2CDevice.cpp.

◆ 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

Definition at line 61 of file MiniR4_I2CDevice.h.

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

Definition at line 209 of file MiniR4_I2CDevice.cpp.

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

Definition at line 296 of file MiniR4_I2CDevice.cpp.

◆ write()

bool Adafruit_I2CDevice::write ( const uint8_t * buffer,
size_t len,
bool stop = true,
const uint8_t * prefix_buffer = nullptr,
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.

Definition at line 128 of file MiniR4_I2CDevice.cpp.

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

Definition at line 273 of file MiniR4_I2CDevice.cpp.


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