ECG
Sets ECG listener
Sets the ECG monitor and get the return value through ecgEveStm.
_blePlugin.ecgEveStm.listen(
(EgcBean event) {
/// Do something with new state,for example:
setState(() {
switch (event.type) {
case ECGType.ecgChangeInts:
_ints = event.ints!;
break;
case ECGType.measureComplete:
break;
case ECGType.date:
_date = event.date!;
break;
case ECGType.cancel:
break;
case ECGType.fail:
break;
}
});
});
Callback Description(event):
EgcBean:
callback value | callback value type | callback value description |
---|---|---|
type | int | Get the corresponding return value according to type, where type is the value corresponding to ECGType |
ints | int[] | ECG information |
date | Date | date |
ECGType:
type | value | value description |
---|---|---|
ecgChangeInts | 1 | measure ECG |
measureComplete | 2 | ECG measurement complete |
date | 3 | ECG measurement date |
cancel | 4 | ECG measurement off |
fail | 5 | ECG measurement failed |
Measuring ECG
Start to measure the ECG, the ECG measurement time is 30 seconds, and the user needs to touch the left and right electrodes of the watch with both hands. The value is obtained by listening to the ecgEveStm data stream, and the value is saved in EgcBean.ints,type is ecgChangeInts.
_blePlugin.startECGMeasure;
Stop measuring ECG
_blePlugin.stopECGMeasure;
Detect new ECG measurement methods
In the new measurement mode, the watch can save the last unsent measurement result; the old version does not.
bool newMeasurementVersion = await _blePlugin.isNewECGMeasurementVersion;
Gets the last ECG data
Gets the ECG data saved by the watch, monitor the data stream through ecgEveStm , and save the value in EgcBean.ints,type is ecgChangeInts.
_blePlugin.queryLastMeasureECGData;
Sets heart rate during ECG measurement
Using the measured data, the instantaneous heart rate is calculated through the ECG algorithm library and sent to the watch.
_blePlugin.sendECGHeartRate(int heartRate);