Skip to content

Instantly share code, notes, and snippets.

@magnatronus
Created September 13, 2018 14:08
Show Gist options
  • Save magnatronus/acc51a60b5d707b44d6859022d6b7a14 to your computer and use it in GitHub Desktop.
Save magnatronus/acc51a60b5d707b44d6859022d6b7a14 to your computer and use it in GitHub Desktop.
Demo of Oscilloscope using Stream Data
/// 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),
],
),
);
}
}
@tawat25
Copy link

tawat25 commented Dec 12, 2022

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