ECG Module code



  • Please help me understand your code for this module
    I got this module to work on a m5stack Fire but I would like an explanation of the library program, ECG.ino at:
    https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Module/ECG

    There are no comments in the code which makes it hard to follow the program.
    There is also no data dictionary for the following terms:
    measurements
    ECG_IDLE
    ECG_DATA_LENGTH
    ECG_DATA_H
    ECG_DATA_L
    ECG_END

    parameters:
    ECGdataFSM
    ECGWritePoint
    ECGReadPoint
    ECGData
    DataMAX
    DataMIN

    Difficult to understand constructs
    What does the following do?

    ECGdataFSM = ( data == 0xAA ) ? ECG_DATA_LENGTH : ECG_IDLE;
    DataMAX = ( ECGData > DataMAX ) ? ECGData : DataMAX;
    DataMIN = ( ECGData < DataMIN ) ? ECGData : DataMIN;

    The documentation for this product at https://docs.m5stack.com/#/en/module/ecg?id=related-link
    states that the MPU STM32 in the module supports a heart rate statistics algorithm. What does this algorithm do? What parameters does it use?



  • @dsrc12: I have now got this to work and it works best if I discount the USB link to Fire. The code I had difficult understanding is based on a C++ Ternary Operator in C. Returns either ECG_Data_LENGTH if data equals 0xAA or ECG_IDLE if false. At least this is a start. Still need to decode the meaning of the parameters.