TsPpg
teslasuit_sdk.subsystems.ts_ppg.TsPpg
Streams and processes PPG sensor data from a TESLASUIT device.
Supports raw waveform streaming and processed data (heart rate, HRV).
Calibration is triggered automatically on start and can be re-triggered
manually via calibrate().
Methods#
__init__#
def __init__(lib, device):
Initialize the PPG interface for a specific device.
Parameters
lib
Loaded TESLASUIT C API library object (CDLL or WinDLL).
device
Handle to the open TESLASUIT device.
start_raw_streaming#
def start_raw_streaming() -> None:
Start raw PPG data streaming.
Subscribes to both the processed and raw data update callbacks, then starts the C API raw streaming pipeline. Has no effect if raw streaming is already active.
stop_raw_streaming#
def stop_raw_streaming() -> None:
Stop raw PPG data streaming.
Halts the C API raw streaming pipeline. Has no effect if raw streaming is not currently active.
get_hrv_data_on_ready#
def get_hrv_data_on_ready() -> TsHrv:
Block until a new HRV data frame is available and return it.
Returns: TsHrv
The latest HRV metrics.
get_raw_data_on_ready#
def get_raw_data_on_ready() -> TsPpgRawData:
Block until a new raw PPG data frame is available and return it.
Returns: TsPpgRawData
The latest raw PPG data.
get_hrv#
def get_hrv() -> TsHrv:
Return the most recently received HRV data without blocking.
Returns: TsHrv
The latest HRV metrics.
get_data#
def get_data() -> TsPpgData:
Return the most recently received processed PPG data without blocking.
Returns: TsPpgData
The latest processed PPG data.
get_data_raw#
def get_data_raw() -> TsPpgRawData:
Return the most recently received raw PPG data without blocking.
Returns: TsPpgRawData
The latest raw PPG data.
calibrate#
def calibrate() -> None:
Re-trigger the PPG processor calibration procedure.
Calibration captures a 3-second interval of raw data that is used as a baseline for all subsequent PPG calculations. It starts automatically when the PPG processor is started; call this method only if the initial calibration was unsuccessful.
Data Structures#
ts_ppg.TsHrv#
C structure holding Heart Rate Variability (HRV) metrics.
Fields
mean_rr float
Mean RR interval in milliseconds.
sdnn float
Standard deviation of NN intervals (overall HRV).
sdsd float
Standard deviation of successive RR interval differences.
rmssd float
Root mean square of successive RR differences (short-term HRV).
sd1 float
Poincaré SD1 — short-term HRV component.
sd2 float
Poincaré SD2 — long-term HRV component.
hlf float
High-frequency HRV component (parasympathetic activity).
ts_ppg.TsPpgNodeData#
C structure holding processed PPG data for a single sensor node.
Fields
heart_rate int
Calculated heart rate in BPM.
is_heart_rate_valid bool
Whether the calculated heart rate is valid.
timestamp int
Time of the last processed raw PPG sample in milliseconds.
ts_ppg.TsPpgData#
C structure holding processed PPG data from all sensor nodes.
Fields
number_of_nodes int
Number of PPG sensor nodes providing data.
nodes POINTER(TsPpgNodeData)
Pointer to the array of per-node data.
ts_ppg.TsPpgRawNodeData#
C structure holding raw PPG sensor samples for a single node.
Fields
sample_size int
Number of samples in each colour channel array.
ir_data POINTER(c_uint64)
Infrared channel samples.
red_data POINTER(c_uint64)
Red channel samples.
blue_data POINTER(c_uint64)
Blue channel samples.
green_data POINTER(c_uint64)
Green channel samples.
timestamp int
Timestamp of the last sample in microseconds.
ts_ppg.TsPpgRawData#
C structure holding raw PPG data from all sensor nodes.
Fields
number_of_nodes int
Number of PPG sensor nodes providing raw data.
nodes POINTER(TsPpgRawNodeData)
Pointer to the array of per-node raw data.
Enumerations#
ts_ppg.PpgSensorType#
Enumeration of supported PPG sensor hardware types.
UNDEFINED(0): Sensor type not identified.MAX30102(1): Maxim MAX30102 IR/red sensor.MAX86916(2): Maxim MAX86916 multi-wavelength sensor.
Members
UNDEFINED 0
MAX30102 1
MAX86916 2
