|
@@ -47,19 +47,19 @@ class _HeartRateState extends State<HeartRate> {
|
|
|
@override
|
|
|
void initState() {
|
|
|
initHeart();
|
|
|
- mockECG();
|
|
|
+ // mockECG();
|
|
|
super.initState();
|
|
|
}
|
|
|
|
|
|
void mockECG() {
|
|
|
Random random = Random();
|
|
|
- int min = 125;
|
|
|
- int max = 200;
|
|
|
+ int min = -125;
|
|
|
+ int max = 125;
|
|
|
int time = 1;
|
|
|
int duration = 500 + random.nextInt(501); // 生成500到1000之间的随机持续时间
|
|
|
|
|
|
Timer.periodic(Duration(milliseconds: duration), (timer) {
|
|
|
- if (time > 35) {
|
|
|
+ if (time > 1) {
|
|
|
timer.cancel(); // 取消定时器
|
|
|
} else {
|
|
|
time++;
|
|
@@ -177,9 +177,12 @@ class _HeartRateState extends State<HeartRate> {
|
|
|
}
|
|
|
|
|
|
void _onEcgValueUpdate(_, List<int> e) {
|
|
|
- setState(() {
|
|
|
- ecgPoint.addAll(e);
|
|
|
- });
|
|
|
+ try {
|
|
|
+ EcgViewController ecgViewController = Get.find<EcgViewController>();
|
|
|
+ ecgViewController.addData(e);
|
|
|
+ } catch (e) {
|
|
|
+ print(e);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void _onDeviceCloseSuccess(sender, e) {
|