LCC Fusion Project 1.0
LCC Automation
Loading...
Searching...
No Matches
I2cCard Class Reference

used by the I2cCardHelper class to manage I2C card information for connsumers and producers classes The I2cCardHelper class creates an I2cCard instance for each of the producer/consumer configured cards Handles I2C connection initialization and status, including callbacks for I2C devices connect/disconnects (hot-plug and play support). For producers, handles managing Event IDs associated with the specific card. More...

#include <LccNodeCommons.h>

Collaboration diagram for I2cCard:

Public Member Functions

 ~I2cCard ()
 destructor to delete objects created by the class
 
bool begin (uint8_t bus, uint8_t offset)
 initializes the I2C connection to a device More...
 
LccNodeI2cgetLccNodeI2c ()
 returns handle to the I2C object
 
bool isConnected ()
 
void initI2cCardPins (uint8_t startPin=0, uint8_t endPin=MAX_NUM_MCP_PINS, uint8_t mode=OUTPUT, lccnode::McpGpioPullup pullup=lccnode::McpGpioPullup::NO_PULLUP)
 Initializes a range of pins for the current I2C card type. More...
 
void pwmSetDuty (uint8_t channel, uint16_t duty)
 Sets the PWM duty cycle for a specific PCA9685 channel using a FaBo PWM pin wrapper. More...
 
void write (uint8_t channel, uint16_t value)
 sets a MCP pin to either HIGH or LOW, or a PWM channel to a value More...
 
uint16_t read (uint8_t channel)
 reads the value of a MCP pin More...
 
bool isSet (uint8_t pinNum)
 returns the current state of a pin More...
 
bool isMcpPinLow (uint8_t pin)
 

Private Attributes

Adafruit_MCP23017 * pMcp_ = nullptr
 Object for card's I2C connection.
 

Detailed Description

used by the I2cCardHelper class to manage I2C card information for connsumers and producers classes The I2cCardHelper class creates an I2cCard instance for each of the producer/consumer configured cards Handles I2C connection initialization and status, including callbacks for I2C devices connect/disconnects (hot-plug and play support). For producers, handles managing Event IDs associated with the specific card.


Definition at line 136 of file LccNodeCommons.h.

Member Function Documentation

◆ begin()

bool I2cCard::begin ( uint8_t  bus,
uint8_t  offset 
)
inline

initializes the I2C connection to a device

Parameters
bususer configured hardware bus (0 or 1) for I2C connection
offsetuser configured I2C address offset (0-7) of the I2C (slave) device. Must match the address settings of the physical I2C device (dip slide switches)
Note
the bus and address values are set by the user via the CDI based configuration
Returns
true if the I2C device is connect and initialized.

Definition at line 178 of file LccNodeCommons.h.

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

◆ initI2cCardPins()

void I2cCard::initI2cCardPins ( uint8_t  startPin = 0,
uint8_t  endPin = MAX_NUM_MCP_PINS,
uint8_t  mode = OUTPUT,
lccnode::McpGpioPullup  pullup = lccnode::McpGpioPullup::NO_PULLUP 
)
inline

Initializes a range of pins for the current I2C card type.

For MCP cards, sets the pin mode (INPUT/OUTPUT) and pull-up state. For PWM cards (PCA9685), sets output mode and default value. No action for unsupported types.

Parameters
startPinFirst pin in the range (0-15 for MCP/PWM)
endPinLast pin in the range (0-15 for MCP/PWM)
modePin mode (INPUT/OUTPUT for MCP; default OUTPUT for PWM)
pullupPull-up resistor state (MCP only; default NO_PULLUP)

Definition at line 218 of file LccNodeCommons.h.

Here is the caller graph for this function:

◆ isConnected()

bool I2cCard::isConnected ( )
inline
Returns
the current I2C connection status. Connection status can change dynamically as I2C cards are hot-pluggable in the network.

Definition at line 202 of file LccNodeCommons.h.

◆ isMcpPinLow()

bool I2cCard::isMcpPinLow ( uint8_t  pin)
inline

MCP Pins

Definition at line 319 of file LccNodeCommons.h.

Here is the caller graph for this function:

◆ isSet()

bool I2cCard::isSet ( uint8_t  pinNum)
inline

returns the current state of a pin

Parameters
pinNumis the pin to check
Returns
is the pin's current state; Gpio::Value::SET=HIGH or Gpio::Value::CLR=LOW

Definition at line 314 of file LccNodeCommons.h.

Here is the caller graph for this function:

◆ pwmSetDuty()

void I2cCard::pwmSetDuty ( uint8_t  channel,
uint16_t  duty 
)
inline

Sets the PWM duty cycle for a specific PCA9685 channel using a FaBo PWM pin wrapper.

This sets the pulse width used to control a servo position. For example, a duty of ~205 sets ~1ms (0%), and ~410 sets ~2ms (100%) at 60Hz.

Parameters
channelPWM output channel (0–15).
dutyDuty cycle in ticks (0–4095), corresponds to servo position.

Definition at line 262 of file LccNodeCommons.h.

Here is the caller graph for this function:

◆ read()

uint16_t I2cCard::read ( uint8_t  channel)
inline

reads the value of a MCP pin

Parameters
channelis the pin to read
Returns
the value of the pin; 0=LOW, 1=HIGH

Definition at line 299 of file LccNodeCommons.h.

Here is the caller graph for this function:

◆ write()

void I2cCard::write ( uint8_t  channel,
uint16_t  value 
)
inline

sets a MCP pin to either HIGH or LOW, or a PWM channel to a value

Parameters
channelis the MCP/PWM pin (0-15) to set
valueis the value (HIGH or LOW) to set the pin too

Definition at line 283 of file LccNodeCommons.h.

Here is the caller graph for this function:

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