Created
September 13, 2018 14:08
-
-
Save magnatronus/acc51a60b5d707b44d6859022d6b7a14 to your computer and use it in GitHub Desktop.
Demo of Oscilloscope using Stream Data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Demo of using the oscilloscope package | |
/// This uses the output from the Acceleromter on a device | |
import 'package:flutter/material.dart'; | |
import 'package:oscilloscope/oscilloscope.dart'; | |
import 'package:sensors/sensors.dart'; | |
void main() => runApp(new MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return new MaterialApp( | |
title: "Oscilloscope Display Example", | |
home: Shell(), | |
); | |
} | |
} | |
class Shell extends StatefulWidget { | |
@override | |
_ShellState createState() => _ShellState(); | |
} | |
class _ShellState extends State<Shell> { | |
List<double> traceX = List(); | |
@override | |
initState() { | |
super.initState(); | |
accelerometerEvents.listen( (AccelerometerEvent event){ | |
setState(() { | |
traceX.add(event.x); | |
}); | |
}); | |
} | |
@override | |
void dispose() { | |
super.dispose(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
// Create A Scope Display | |
Oscilloscope scopeOne = Oscilloscope( | |
padding: 20.0, | |
backgroundColor: Colors.black, | |
traceColor: Colors.green, | |
yAxisMax: 10.0, | |
yAxisMin: -10.0, | |
dataSet: traceX, | |
); | |
// Generate the Scaffold | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("OscilloScope Demo"), | |
), | |
body: Column( | |
children: <Widget>[ | |
Expanded(flex: 1, child: scopeOne), | |
], | |
), | |
); | |
} | |
} | |
hi i have test code but i think slowl not real time . How to speed up to real time.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem was solved! Thank you.