FabGL
ESP32 Display Controller and Graphics Library
I2C Class Reference

I2C class allows multiple tasks to communicate with I2C devices, serializing read/write jobs. More...

#include <tsi2c.h>

Public Member Functions

 I2C (int bus=0)
 I2C class constructor. More...
 
bool begin (gpio_num_t SDAGPIO, gpio_num_t SCLGPIO)
 Initializes I2C instance associating GPIOs to I2C signals. More...
 
int getMaxBufferLength ()
 Returns maximum size of read and write buffers. More...
 
int read (int address, uint8_t *buffer, int size, int frequency=100000, int timeOutMS=50)
 Receives a buffer from I2C bus. More...
 
bool write (int address, uint8_t *buffer, int size, int frequency=100000, int timeOutMS=50)
 Sends a buffer to I2C bus. More...
 

Detailed Description

I2C class allows multiple tasks to communicate with I2C devices, serializing read/write jobs.

A single instance of I2C class can be shared among multiple tasks or timers (not interrupts).

Example:

fabgl::I2C I2C;

void setup() {
  I2C.begin(GPIO_NUM_4, GPIO_NUM_15);  // 4 = SDA, 15 = SCL (WARN: disconnect VGA connector!!)
}
Examples
SSD1306_OLED/128x32/CollisionDetection/CollisionDetection.ino, SSD1306_OLED/128x32/SimpleTerminalOut/SimpleTerminalOut.ino, SSD1306_OLED/128x64/CollisionDetection/CollisionDetection.ino, SSD1306_OLED/128x64/DoubleBuffer/DoubleBuffer.ino, SSD1306_OLED/128x64/NetworkTerminal/NetworkTerminal.ino, SSD1306_OLED/128x64/RTClock/RTClock.ino, SSD1306_OLED/128x64/SimpleTerminalOut/SimpleTerminalOut.ino, and SSD1306_OLED/128x64/UI/UI.ino.

Definition at line 85 of file tsi2c.h.


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