HeartBeatRate/Software/dashboard/lib/main.dart

206 lines
6.8 KiB
Dart

//import 'dart:nativewrappers/_internal/vm/lib/core_patch.dart';
import 'package:dashboard/hardware/heartbeatmice.dart';
import 'ui/plot.dart';
import 'package:flutter/material.dart';
import 'util/mouse_cursor.dart';
import 'package:logging/logging.dart';
import 'dart:core';
void main() {
Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((record){
print('[${record.time.hour}:${record.time.minute}:${record.time.second}][${record.level.name}][${record.loggerName}] ${record.message}');
});
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return SoftwareMouseCursor(
child : MaterialApp(
title: 'Heart Beat Mice',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Heart Beat Mice Coba'),
)
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
late HeartBeatMice device;
Logger log = Logger("_MyHomePageState");
@override
void initState() {
super.initState();
device = HeartBeatMice();
device.init();
}
@override
void dispose() {
super.dispose();
device.dispose();
}
@override
Widget build(BuildContext context) {
double height = 300/4;
double width = (MediaQuery.of(context).size.width-30)/4;
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Row(children: [
SizedBox(
width: width,
child: ListView.builder(
itemCount: 4,
itemBuilder: (context, i){
var index = i+12;
return Column(
children: <Widget>[
Text("Analog $index"),
SizedBox (
height: height.toDouble(),
width: width,
child : Plot(
title: "Analog $index",
aspectRatio: (height/ width),
minY: -5,
maxY: 5,
maxTimeSeconds: 0.5,
sampleTimeMicross: 1,
readAnalog: () async { return device.readAnalog(index); }
),
),
],
);
},
)),
SizedBox(
width: width,
child: ListView.builder(
itemCount: 4,
itemBuilder: (context, i){
var index = i+8;
return Column(
children: <Widget>[
Text("Analog $index"),
SizedBox (
height: height.toDouble(),
width: width,
child : Plot(
title: "Analog $index",
aspectRatio: (height/ width),
minY: -5,
maxY: 5,
maxTimeSeconds: 0.5,
sampleTimeMicross: 1,
readAnalog: () async { return device.readAnalog(index); }
),
),
],
);
},
)),
SizedBox(
width: width,
child: ListView.builder(
itemCount: 4,
itemBuilder: (context, i){
var index = i+4;
return Column(
children: <Widget>[
Text("Analog $index"),
SizedBox (
height: height.toDouble(),
width: width,
child : Plot(
title: "Analog $index",
aspectRatio: (height/ width),
minY: -5,
maxY: 5,
maxTimeSeconds: 0.5,
sampleTimeMicross: 1,
readAnalog: () async { return device.readAnalog(index); }
),
),
],
);
},
)),
SizedBox(
width: width,
child: ListView.builder(
itemCount: 4,
itemBuilder: (context, i){
var index = i;
return Column(
children: <Widget>[
Text("Analog $index"),
SizedBox (
height: height.toDouble(),
width: width,
child : Plot(
title: "Analog $index",
aspectRatio: (height/ width),
minY: -5,
maxY: 5,
maxTimeSeconds: 0.5,
sampleTimeMicross: 1,
readAnalog: () async { return device.readAnalog(index); }
),
),
],
);
},
)),
])
);
}
}
// Column(children: [
// Row(children: [
// Row(children: [
// IconButton(
// onPressed: () async {device.offset[index].wipeUp();} ,
// icon: const Icon(Icons.arrow_drop_up_outlined)),
// const Text("Offset"),
// IconButton(
// onPressed: () async {device.offset[index].wipeDown();} ,
// icon: const Icon(Icons.arrow_drop_down_outlined))
// ]),
// Row(children: [
// IconButton(
// onPressed: () async {device.gain[index].wipeUp();} ,
// icon: const Icon(Icons.arrow_drop_up_outlined)),
// const Text("Gain"),
// IconButton(
// onPressed: () async {device.gain[index].wipeDown();} ,
// icon: const Icon(Icons.arrow_drop_down_outlined)),
// ]),
// ],),
// ],
// ),