healthrian_visualization_support 2.3.4 copy "healthrian_visualization_support: ^2.3.4" to clipboard
healthrian_visualization_support: ^2.3.4 copied to clipboard

unlisted

Healthrian visualization support library

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:healthrian_ble_support_for_cardio_em_cdc/healthrian_ble_support_for_cardio_em_cdc.dart';
import 'package:healthrian_visualization_support/healthrian_visualization_support.dart';
import 'package:rxdart/rxdart.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  void initState() {
    super.initState();
    BLEManager().samplingRate = SamplingRate.freq4000hz;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          ConnectionMonitor(module: BLEManager().module),
          HeartRateMonitor(module: BLEManager().module, isUsingMean: false),
          LeadstateMonitor(module: BLEManager().module),
          Observer(
            builder: (context) {
              return StreamBuilder(
                stream: BLEManager()
                    .module
                    .ble
                    .streams
                    .ecg
                    .meta
                    .value
                    ?.expand((e) => e.first)
                    .bufferTime(Duration(seconds: 1))
                    .map((e) => e.length),
                builder: (context, snapshot) => Text('${snapshot.data} Samples/sec.'),
              );
            },
          ),
          // Expanded(
          //   child: SingleChildScrollView(
          //     child: Observer(
          //       builder: (context) {
          //         return StreamBuilder(
          //           stream: module.ble.streams.ecg.filter.buffer,
          //           builder: (context, snapshot) => Text('${snapshot.data?.l2.length}'),
          //         );
          //       },
          //     ),
          //   ),
          // ),
          // Expanded(
          //   child: Observer(
          //     builder: (context) {
          //       return StreamBuilder(
          //         stream: module.ble.streams.ecg.meta.raw,
          //         builder: (context, snapshot) {
          //           if (!snapshot.hasData) return const SizedBox();
          //           final spots = List.generate(
          //             snapshot.data!.length,
          //             (i) => FlSpot(i.toDouble(), snapshot.data![i].toDouble()),
          //           );
          //           return LineChart(
          //             duration: Duration.zero,
          //             LineChartData(
          //               lineBarsData: [
          //                 LineChartBarData(
          //                   spots: spots,
          //                 ),
          //               ],
          //             ),
          //           );
          //         },
          //       );
          //     },
          //   ),
          // ),
          // Observer(
          //   builder: (context) => StreamBuilder(
          //     stream: module.ble.streams.ecg.meta.raw?.scan(
          //           (acc, v, i) {
          //         if ((acc.$2 + 1) % 0x100 != v[2]) print((acc.$2, v[2], DateTime.now()));
          //         return ((acc.$2 + 1) % 0x100 == v[2], v[2]);
          //       },
          //       (false, -1),
          //     ),
          //     builder: (context, snapshot) {
          //       return Text(snapshot.data.toString());
          //     },
          //   ),
          // ),
          Expanded(
            child: SingleChildScrollView(
              child: EcgMonitor(
                module: BLEManager().module,
                // isFiltered: false,
              ),
            ),
          ),
        ],
      ),
      floatingActionButton: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          ControlPanel(module: BLEManager().module),
          FloatingActionButton(
            onPressed: () {
              BLEManager().module.ecg?.dataFilter?.dcBlock = DcBlock.off;
              BLEManager().module.ecg?.dataFilter?.lowPass = LowPass.off;
              BLEManager().module.ecg?.dataFilter?.highPass = HighPass.off;
              BLEManager().module.ecg?.dataFilter?.bandStop = BandStop.off;
            },
          ),
        ],
      ),
    );
  }
}