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

Manages alerts and notifications (voltage checks, communication statuses). More...

#include <LccNodeAlerts.h>

Collaboration diagram for LccNodeAlerts:

Public Member Functions

 LccNodeAlerts ()
 Constructor for LccNodeAlerts class.
 
 ~LccNodeAlerts ()
 Destructor for LccNodeAlerts class.
 
void init (Esp32HardwareTwai *pTwai, LccNodeSerialMonitor *pMonitor)
 Initializes timers and verifies I2C connectivity.
 
void update ()
 Updates alerts and timers periodically.
 

Private Member Functions

float _readVoltageAveraged (gpio_num_t pin, float vrefScale, int samples=8)
 Read and average multiple ADC voltage samples from a given pin. More...
 
void _handle3v3VoltageAlerts ()
 _handle3v3VoltageAlerts check to see Node Card's 3v3 is below 3v indicating low battery, or other power source More...
 
void _handle5vVoltageAlerts ()
 _handle5vVoltageAlerts check to see Node Card's 5v is below 5 V indicating low power source More...
 
void _handle12vVoltageAlerts ()
 _handle12vVoltageAlerts check to see Node Card's 12 V is below 12 V indicating low power source More...
 
bool _isTwaiConnected ()
 Determines if TWAI connectivity is active. More...
 
void _handleTwaiConnectivityAlerts ()
 Checks for TWAI connectivity issues.
 
bool _isIoPinConnected (int pinNum)
 Checks if a pin is connected. More...
 
void _handleNodeIoDeviceAlerts ()
 Checks for attached IO devices and alerts only for changes.
 
void _handleCanhVoltageRangeAlerts ()
 Check CANH bias window and emit alerts with hysteresis and debouncing. Notes: More...
 

Detailed Description

Manages alerts and notifications (voltage checks, communication statuses).

Definition at line 218 of file LccNodeAlerts.h.

Member Function Documentation

◆ _handle12vVoltageAlerts()

void LccNodeAlerts::_handle12vVoltageAlerts ( )
inlineprivate

_handle12vVoltageAlerts check to see Node Card's 12 V is below 12 V indicating low power source


Note
low voltage can lead to a brown out and reboot. Results from insufficient power (using Wi-Fi from USB based power), or unstable power (noise, temperature)

Definition at line 370 of file LccNodeAlerts.h.

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

◆ _handle3v3VoltageAlerts()

void LccNodeAlerts::_handle3v3VoltageAlerts ( )
inlineprivate

_handle3v3VoltageAlerts check to see Node Card's 3v3 is below 3v indicating low battery, or other power source


Note
low voltage can lead to a brown out and reboot. Results from insufficient power (using Wi-Fi from USB based power), or unstable power (noise, temperature)

Definition at line 334 of file LccNodeAlerts.h.

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

◆ _handle5vVoltageAlerts()

void LccNodeAlerts::_handle5vVoltageAlerts ( )
inlineprivate

_handle5vVoltageAlerts check to see Node Card's 5v is below 5 V indicating low power source


Note
low voltage can lead to a brown out and reboot. Results from insufficient power (using Wi-Fi from USB based power), or unstable power (noise, temperature)

Definition at line 352 of file LccNodeAlerts.h.

Here is the call graph for this function:

◆ _handleCanhVoltageRangeAlerts()

void LccNodeAlerts::_handleCanhVoltageRangeAlerts ( )
inlineprivate

Check CANH bias window and emit alerts with hysteresis and debouncing. Notes:

  • Expects a small RC (e.g., 640k // 10nF) on the ADC pin for stability.
  • readVoltage(pin, vref_or_scale) should return volts at the pin.

Definition at line 551 of file LccNodeAlerts.h.

Here is the call graph for this function:

◆ _isIoPinConnected()

bool LccNodeAlerts::_isIoPinConnected ( int  pinNum)
inlineprivate

Checks if a pin is connected.

Parameters
pinNumPin number to check.
Returns
True if pin is connected, false otherwise.

Definition at line 500 of file LccNodeAlerts.h.

Here is the caller graph for this function:

◆ _isTwaiConnected()

bool LccNodeAlerts::_isTwaiConnected ( )
inlineprivate

Determines if TWAI connectivity is active.

Returns
True if TWAI is connected, false otherwise.

Definition at line 388 of file LccNodeAlerts.h.

Here is the caller graph for this function:

◆ _readVoltageAveraged()

float LccNodeAlerts::_readVoltageAveraged ( gpio_num_t  pin,
float  vrefScale,
int  samples = 8 
)
inlineprivate

Read and average multiple ADC voltage samples from a given pin.

This helper function repeatedly calls readVoltage() on the specified ADC pin and returns the arithmetic mean of the collected samples. Averaging is recommended on the ESP32 because raw ADC values often fluctuate due to noise, ground bounce, and regulator ripple.

Parameters
pinGPIO number configured as an ADC input.
vrefScaleReference scaling factor passed through to readVoltage(). This usually represents either the ADC reference voltage (e.g., 3.3 V, 3.95 V measured) or a correction multiplier determined by calibration.
samplesNumber of readings to collect and average. Typical values are 8–16. More samples improve stability at the cost of slightly longer measurement time.
Returns
float Average voltage measured on the specified pin, in volts.
Note
Usage example:
float v3v3 = _readVoltageAveraged(LCC_NODE_3V3_REGULATOR_PIN, 3.95f, 8);
if (v3v3 < NODE_3V3_LOW_VOLTAGE_THRESHOLD) {
pMonitor_->print(serialMonitorMri::NODE_LOW_3V3_VOLTAGE_WARNING);
}
float _readVoltageAveraged(gpio_num_t pin, float vrefScale, int samples=8)
Read and average multiple ADC voltage samples from a given pin.
void print(const char *format,...)
Print a formatted message to all enabled outputs.
See also
readVoltage() for the single-sample implementation.

Definition at line 321 of file LccNodeAlerts.h.

Here is the caller graph for this function:

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