update berhasil signal tertangkap, saatnya troubleshoot front end

software
a2nr 2024-09-24 10:10:13 +07:00
parent 7a881cd52a
commit eed9e324a7
8 changed files with 463 additions and 245 deletions

Binary file not shown.

View File

@ -21,7 +21,7 @@ comp:
copy_target:
sshpass -p $(TARGET_PASS) rsync -a --info=progress2 ./build/flutter_assets $(TARGET_USER)@$(TARGET_HOST):$(TARGET_PATH)
run:
sshpass -p $(TARGET_PASS) ssh -t $(TARGET_USER)@$(TARGET_HOST) 'echo $(TARGET_PASS) | sudo -S flutter-pi -r 90 --release $(TARGET_PATH)/flutter_assets'
sshpass -p $(TARGET_PASS) ssh -t $(TARGET_USER)@$(TARGET_HOST) 'echo $(TARGET_PASS) | sudo -S flutter-pi -r 270 --release $(TARGET_PATH)/flutter_assets'
run_debug:
sshpass -p $(TARGET_PASS) ssh -t $(TARGET_USER)@$(TARGET_HOST) 'echo $(TARGET_PASS) | sudo -S flutter-pi -o landscape_left $(TARGET_PATH)/flutter_assets'
install_dep:
@ -29,8 +29,8 @@ install_dep:
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-alsa'
install_flutter_pi:
sshpass -p $(TARGET_PASS) ssh -t $(TARGET_USER)@$(TARGET_HOST) 'cd ~/Documents && git clone --recursive https://github.com/ardera/flutter-pi || cd flutter-pi && mkdir build || cd build && cmake .. && make -j`nproc` && echo $(TARGET_PASS) | sudo -S make install'
# -C D0=CS1,D6=CS2,D1=MISO,D2=MOSI,D3=CLK,D4=DRDY1,D5=DRDY2
probe:
sshpass -p $(PROBE_PASS) ssh -t $(PROBE_USER)@$(PROBE_HOST) 'echo $(PROBE_PASS) | sudo -S sigrok-cli -d fx2lafw:conn=2.4 -o $(PROBE_PATH)/test.sr -w -t D0=f -M spi --config samplerate=100k --samples 500k --time 1s' \
&& sshpass -p $(PROBE_PASS) rsync -a --info=progress2 $(PROBE_USER)@$(PROBE_HOST):$(PROBE_PATH)/test.sr ./build/
sshpass -p $(PROBE_PASS) ssh -t $(PROBE_USER)@$(PROBE_HOST) 'echo $(PROBE_PASS) | sudo -S sigrok-cli -d fx2lafw -o $(PROBE_PATH)/test.sr -w -t D3=f -M spi --config samplerate=200k --samples 2m --time 5s' \
&& sshpass -p $(PROBE_PASS) rsync -a --info=progress2 $(PROBE_USER)@$(PROBE_HOST):$(PROBE_PATH)/test.sr ./build/ \
&& pulseview -i ./build/test.sr -s ./pulseview_session_setup.pvs

View File

@ -50,5 +50,10 @@ class X9c10x {
inc.write(true);
onRelease.call();
}
void dispose(){
inc.dispose();
ud.dispose();
ss?.dispose();
}
}

View File

@ -14,6 +14,10 @@ extension Ads1265Int on int {
}
double toMilliVolt() => toMicroVolt() / 1000.0;
double toVolt() => toMicroVolt() / 1000000.0;
toListBoolbit() => [(this & 0x01)==0x01?true:false, (this &0x02)==0x02?true:false, (this &0x04)==0x04?true:false, (this &0x08)==0x08?true:false];
}
extension Ads1265ListBool on List<bool> {
toNibble() => (this[0]?0x01:0x00) | (this[1]?0x02:0x00) | (this[2]?0x04:0x00) | (this[3]?0x08:0x00);
}
class Ads1256 {
late SPI spi; //SPI
@ -21,12 +25,14 @@ class Ads1256 {
late GPIO? rst;
late GPIO? cs; //GPIO
late Logger log;
bool isCSActiveHigh;
Ads1256({
required int spiBus,
required int spiChip,
required int gpioChip,
required int pinDrdy,
required this.isCSActiveHigh,
String? tag,
int? pinReset,
int? pinCS }){
@ -37,10 +43,10 @@ class Ads1256 {
log = Logger("[Ads1256][$tag]");
}
void skipClk()=>sleep(const Duration(microseconds: 1 ));
void skipClk() => sleep(const Duration(microseconds: 1 ));
void writeRegister(int reg, int wdata) {
log.info(' writeRegistere() <${reg.toRadixString(16)}> <${wdata.toRadixString(8)}>');
log.info(' writeRegistere() <${reg.toRadixString(16)}> <${wdata.toRadixString(16)}>');
waitDRDY();
spi.transfer([CMD_WREG | reg, 0, wdata], false);
skipClk();
@ -62,27 +68,30 @@ class Ads1256 {
csOn();
waitDRDY();
spi.transfer([cmd], false);
skipClk();
csOff();
}
int get offsetCalibration {
csOn();
skipClk();
int x = readRegister(RADD_OFC0) | readRegister(RADD_OFC1) <<8 | readRegister(RADD_OFC2) <<16;
csOff();
return x;
return x;
}
int get fullscaleCalibration {
csOn();
skipClk();
int x = readRegister(RADD_FSC0) | readRegister(RADD_FSC1) <<8 | readRegister(RADD_FSC2) <<16;
csOff();
return x;
}
void calibrateOffsetGain()=>sendCommand(CMD_SELFCAL);
void calibrateOffset()=>sendCommand(CMD_SELFOCAL);
void calibrateGain()=>sendCommand(CMD_SELFGCAL);
void calibrateSystemOffset()=>sendCommand(CMD_SYSOCAL);
void calibrateSystemGain()=>sendCommand(CMD_SYSGCAL);
void stopContinueRead()=>sendCommand(CMD_SDATAC);
void resetCommand()=>sendCommand(CMD_RESET);
void calibrateOffsetGain() => sendCommand(CMD_SELFCAL);
void calibrateOffset() => sendCommand(CMD_SELFOCAL);
void calibrateGain() => sendCommand(CMD_SELFGCAL);
void calibrateSystemOffset() => sendCommand(CMD_SYSOCAL);
void calibrateSystemGain() => sendCommand(CMD_SYSGCAL);
void stopContinueRead() => sendCommand(CMD_SDATAC);
void resetCommand() => sendCommand(CMD_RESET);
void doReset(){
waitDRDY();
@ -98,34 +107,47 @@ class Ads1256 {
}
void csOn(){
cs?.write(false);
log.info("============== Start transfer");
cs?.write(isCSActiveHigh?true:false);
skipClk();
skipClk();
skipClk();
log.info(" > Start transfer");
}
void csOff(){
log.info("============== End transfer");
cs?.write(true);
log.info(" > End transfer");
cs?.write(isCSActiveHigh?false:true);
skipClk();
skipClk();
skipClk();
}
void begin(int drate, int gain, bool buffen) {
log.info("begin() : <${drate.toRadixString(16)}> <${gain.toRadixString(8)}> <$buffen>");
doReset();
csOn();
resetCommand();
skipClk();
skipClk();
csOn();
syncIt();
buffer = buffen;
autoCalibration = true;
clockOutRate = CLKOUT_1;
programmableGain = gain;
dataRate = drate;
log.info(" status : ${status.toRadixString(16)}");
log.info(" adcon : ${controlRegister.toRadixString(16)}");
log.info(" drate : ${dataRate.toRadixString(16)}");
skipClk();
skipClk();
bufferNCS = buffen;
autoCalibrationNCS = true;
clockOutRateNCS = CLKOUT_1;
programmableGainNCS = gain;
dataRateNCS = drate;
var st = statusNCS.toRadixString(16);
var ac = controlRegisterNCS.toRadixString(16);
var dt = dataRateNCS.toRadixString(16);
csOff();
log.info(" status : $st");
log.info(" adcon : $ac");
log.info(" drate : $dt");
skipClk();
calibrateOffsetGain();
}
void syncIt(){
spi.transfer([CMD_SYNC], false);
skipClk();
skipClk();
@ -134,54 +156,54 @@ class Ads1256 {
skipClk();
}
int get status => readRegister(RADD_STATUS);
int get statusNCS => readRegister(RADD_STATUS);
set buffer(bool isEnable){
isEnable ? writeRegister(RADD_STATUS, (status | (0x01 << 1))):
writeRegister(RADD_STATUS, (status & ~(0x01 << 1)));
set bufferNCS(bool isEnable){
isEnable ? writeRegister(RADD_STATUS, (statusNCS | (0x01 << 1))):
writeRegister(RADD_STATUS, (statusNCS & ~(0x01 << 1)));
}
set autoCalibration(bool isEnable){
isEnable ? writeRegister(RADD_STATUS, (status | (0x01 << 2))):
writeRegister(RADD_STATUS, (status & ~(0x01 << 2)));
set autoCalibrationNCS(bool isEnable){
isEnable ? writeRegister(RADD_STATUS, (statusNCS | (0x01 << 2))):
writeRegister(RADD_STATUS, (statusNCS & ~(0x01 << 2)));
}
int get controlRegister => readRegister(RADD_ADCON);
set clockOutRate(int clk)=>writeRegister(RADD_ADCON, controlRegister | (clk << 5 ));
set programmableGain(int gain)=>writeRegister(RADD_ADCON, controlRegister | gain);
int get controlRegisterNCS => readRegister(RADD_ADCON);
set clockOutRateNCS(int clk) => writeRegister(RADD_ADCON, controlRegisterNCS | (clk << 5 ));
set programmableGainNCS(int gain) => writeRegister(RADD_ADCON, controlRegisterNCS | gain);
int get dataRate =>readRegister(RADD_DRATE);
set dataRate(int rate) => writeRegister(RADD_DRATE, rate);
int get dataRateNCS => readRegister(RADD_DRATE);
set dataRateNCS(int rate) => writeRegister(RADD_DRATE, rate);
set ioDir(List<int> dir){
csOn();
int d = dir[0] | dir[1]<<1 | dir[2]<<2 | dir[3]<<3;
writeRegister(RADD_IO, d <<4);
int d = (dir[0] | dir[1]<<1 | dir[2]<<2 | dir[3]<<3) <<4;
writeRegister(RADD_IO, d);
csOff();
}
List<bool> get dIO {
csOn();
int dio = readRegister(RADD_IO);
csOff();
return [(dio & 0x01)==0x01?true:false, (dio &0x02)==0x02?true:false, (dio &0x04)==0x04?true:false, (dio &0x08)==0x08?true:false];
return dio.toListBoolbit();
}
set dIO(List<bool> io){
csOn();
writeRegister(RADD_IO, (io[0]?0x01:0x00) | (io[1]?0x02:0x00) | (io[2]?0x04:0x00) | (io[3]?0x08:0x00) );
writeRegister(RADD_IO, io.toNibble() );
csOff();
}
set channel(int c) => writeRegister(RADD_MUX, c<<4);
set channelNCS(int c) => writeRegister(RADD_MUX, c);
int analogRead(int channel){
log.info(" analogRead() <${channel.toRadixString(16)}>");
int analogRead(int pChannel, int nChannel){
var nc = pChannel | nChannel;
log.info(" analogRead() <${pChannel.toRadixString(16)}> <${nChannel.toRadixString(16)}> = <${nc.toRadixString(16)}>");
csOn();
waitDRDY();
this.channel = channel;
channelNCS = nc;
waitDRDY();
spi.transfer([CMD_RDATA], false);
skipClk();
List<int> d = spi.transfer([0, 0, 0], true);
var d = spi.transfer([0, 0, 0], true);
csOff();
int v = d[0] << 16 | d[1] << 8 | d[2];
log.info(" > $v");

View File

@ -1,11 +1,28 @@
import 'package:dashboard/hal/X9C10X.dart';
import 'package:logging/logging.dart';
import '../hal/ads1256.dart';
class HeartBeatMice {
Ads1256 adc1 = Ads1256(tag: "adc1", spiBus: 1, spiChip: 0, gpioChip: 1, pinDrdy: 202, pinCS: 13, pinReset: 20);
Ads1256 adc2 = Ads1256(tag: "adc2", spiBus: 1, spiChip: 0, gpioChip: 1, pinDrdy: 6, pinCS: 21);
Ads1256 adc1 = Ads1256(tag: "adc1",
spiBus: 1,
spiChip: 0,
gpioChip: 1,
pinDrdy: 202,
pinCS: 13,
isCSActiveHigh: false,
pinReset: 20);
Ads1256 adc2 = Ads1256(tag: "adc2",
spiBus: 1,
spiChip: 0,
gpioChip: 1,
pinDrdy: 6,
pinCS: 21,
isCSActiveHigh: false,
/*pinReset: 20*/);
X9c10x pot = X9c10x(ohm: 104000, gpioChip: 1, pinUd: 204, pinInc: 205);
Logger log = Logger("[HeartBeatMice]");
void potSelect(){
@ -14,17 +31,38 @@ class HeartBeatMice {
}
void init(){
adc1.begin(Ads1256.DRATE_500SPS, Ads1256.GAIN_1, false);
adc2.begin(Ads1256.DRATE_500SPS, Ads1256.GAIN_1, false);
adc1.begin(Ads1256.DRATE_500SPS, Ads1256.GAIN_1, true);
adc2.begin(Ads1256.DRATE_500SPS, Ads1256.GAIN_1, true);
adc1.ioDir = [Ads1256.IO_DIR_OUT, Ads1256.IO_DIR_OUT, Ads1256.IO_DIR_OUT, Ads1256.IO_DIR_OUT];
adc2.ioDir = [Ads1256.IO_DIR_OUT, Ads1256.IO_DIR_OUT, Ads1256.IO_DIR_OUT, Ads1256.IO_DIR_OUT];
print('adc = ${adc1.analogRead(0).toVolt()}');
}
void test(){
print('adc = ${adc1.analogRead(0).toVolt()}');
int readAnalog(int no){
var adc = switch (no) {
1 || 2 || 3 || 4 || 9 || 10 || 11 || 12 =>adc2,
5 || 6 || 7 || 8 || 13 || 14 || 15 || 16 || _ =>adc1,
};
var ain = switch (no) {
1 || 15=>Ads1256.MUXP_AIN0,
2 || 14=>Ads1256.MUXP_AIN1,
13=>Ads1256.MUXP_AIN2,
8=>Ads1256.MUXP_AIN3,
12=>Ads1256.MUXP_AIN4,
4 || 6 || 11=>Ads1256.MUXP_AIN5,
3 || 5 || 10=>Ads1256.MUXP_AIN6,
7 || 9 || 16=>Ads1256.MUXP_AIN7,
_=>Ads1256.MUXP_AINCOM
};
log.info('readAnalog() <$no>');
log.info('> adc : <${adc.log.name}> | ain : <${ain.toRadixString(16)}> ');
var r = adc.analogRead(ain, Ads1256.MUXN_AINCOM);
log.info('> $r');
return r;
}
void dispose(){
void dispose(){
adc1.dispose();
adc2.dispose();
pot.dispose();
}
}

View File

@ -1,14 +1,17 @@
import 'package:dashboard/hal/ads1256.dart';
import 'package:dashboard/hardware/heartbeatmice.dart';
//import 'package:flutter/cupertino.dart';
import 'ui/plot.dart';
import 'package:flutter/material.dart';
import 'util/mouse_cursor.dart';
import 'package:logging/logging.dart';
import 'ui/plot.dart';
void main() {
Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((record){
print('[${record.level.name}:${record.loggerName}][${record.time.hour}:${record.time.minute}:${record.time.second}] ${record.message}');
print('[${record.time.hour}:${record.time.minute}:${record.time.second}][${record.level.name}][${record.loggerName}] ${record.message}');
});
runApp(const MyApp());
}
@ -19,16 +22,16 @@ class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
//return SoftwareMouseCursor(
/*child :*/ return MaterialApp(
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'),
)
);
//);
}
}
@ -42,28 +45,21 @@ class MyHomePage extends StatefulWidget {
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
HeartBeatMice drive = HeartBeatMice();
late HeartBeatMice device;
Logger log = Logger("_MyHomePageState");
@override
void initState(){
void initState() {
super.initState();
drive.init();
device = HeartBeatMice();
device.init();
}
@override
void dispose(){
void dispose() {
super.dispose();
drive.dispose();
device.dispose();
}
void _incrementCounter() {
setState(() {
_counter++;
});
drive.test();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -71,26 +67,38 @@ class _MyHomePageState extends State<MyHomePage> {
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column (
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
Container ( width: 350, child : const LineChartSample10())
],
)
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
body: ListView.builder(
itemCount: 10,
itemBuilder: (BuildContext context, int index){
log.info("build ListView index : $index");
return Center(
child: Column (
children: <Widget>[
const SizedBox(height: 10,),
SizedBox (
height: 100,
width: MediaQuery.of(context).size.width-100,
child : LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
double height = constraints.maxHeight;
double width = constraints.maxWidth;
var i = index;
return Plot(
title: "analog $i",
aspectRatio: (height/width),
maxTimeSeconds: 10,
sampleTimeMillis: 2,
readAnalog: () async {
return await device.readAnalog(i).toVolt();
},
);
})
),
const SizedBox(height: 10,),
],
)
);
})
);
}
}

View File

@ -1,171 +1,127 @@
import 'dart:async';
import 'dart:core';
import 'dart:math' as math;
import 'package:fl_chart/fl_chart.dart';
//import 'package:fl_chart_app/presentation/resources/app_resources.dart';
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
class AppColors {
static const Color primary = contentColorCyan;
static const Color menuBackground = Color(0xFF090912);
static const Color itemsBackground = Color(0xFF1B2339);
static const Color pageBackground = Color(0xFF282E45);
static const Color mainTextColor1 = Colors.white;
static const Color mainTextColor2 = Colors.white70;
static const Color mainTextColor3 = Colors.white38;
static const Color mainGridLineColor = Colors.white10;
static const Color borderColor = Colors.white54;
static const Color gridLinesColor = Color(0x11FFFFFF);
static const Color contentColorBlack = Colors.black;
static const Color contentColorWhite = Colors.white;
static const Color contentColorBlue = Color(0xFF2196F3);
static const Color contentColorYellow = Color(0xFFFFC300);
static const Color contentColorOrange = Color(0xFFFF683B);
static const Color contentColorGreen = Color(0xFF3BFF49);
static const Color contentColorPurple = Color(0xFF6E1BFF);
static const Color contentColorPink = Color(0xFFFF3AF2);
static const Color contentColorRed = Color(0xFFE80054);
static const Color contentColorCyan = Color(0xFF50E4FF);
class Plot extends StatefulWidget {
const Plot({
super.key,
required this.title,
required this.aspectRatio,
required this.maxTimeSeconds,
required this.readAnalog,
required this.sampleTimeMillis});
final String title;
final double aspectRatio;
final int maxTimeSeconds;
final Future<double> Function() readAnalog;
final int sampleTimeMillis;
@override
State<StatefulWidget> createState() => _Plot();
}
class LineChartSample10 extends StatefulWidget {
const LineChartSample10({super.key});
class _Plot extends State<Plot> {
late Timer timer;
late int limit= ((widget.maxTimeSeconds)/(widget.sampleTimeMillis/1000)).toInt();
late List<FlSpot> adc = <FlSpot>[];
int index = 0;
double el = 0.0;
final Color sinColor = AppColors.contentColorBlue;
final Color cosColor = AppColors.contentColorPink;
late Logger log;
@override
State<LineChartSample10> createState() => _LineChartSample10State();
void dispose() {
super.dispose();
timer.cancel();
}
@override
void initState() {
super.initState();
log = Logger("Plot : ${widget.title}");
log.info('limit : $limit');
timer = Timer.periodic(Duration(milliseconds: widget.sampleTimeMillis), (timer) {
widget.readAnalog().then((val){
if (index>=limit) {
log.info('================================================================ reset $index : $el : ${index != 0 ? adc[index-1] : 0}');
index = 0;
el = 0.0;
adc.clear();
}
setState(() {
el = (index * widget.sampleTimeMillis)/1000;
adc.add(FlSpot( el, val));
log.info('================================================================ $index : $el : ${adc[index]}');
index +=1;
});
});
});
}
@override
Widget build(BuildContext context) {
return AspectRatio(
aspectRatio: widget.aspectRatio,
child : LineChart(
LineChartData(
minY: -5,
maxY: 5,
minX: 0,
maxX: widget.maxTimeSeconds.toDouble(),
lineBarsData: [LineChartBarData(
spots: adc,
dotData: const FlDotData(
show: false,
),
barWidth: 2,
isCurved: false,
)],
titlesData: const FlTitlesData(show: true,
rightTitles: AxisTitles(sideTitles: SideTitles(reservedSize: 40, showTitles: false)),
topTitles: AxisTitles(sideTitles: SideTitles(reservedSize: 40, showTitles: false)),
),
gridData: const FlGridData(show: true, drawVerticalLine: false),
)
)
);
}
}
class _LineChartSample10State extends State<LineChartSample10> {
final limitCount = 100;
final sinPoints = <FlSpot>[];
final cosPoints = <FlSpot>[];
class DummyData {
late int limitCount;
late List<FlSpot> sinPoints;
double xValue = 0;
double step = 0.05;
int index = 0;
late Timer timer;
late void Function() stateChange;
@override
void initState() {
super.initState();
timer = Timer.periodic(const Duration(milliseconds: 40), (timer) {
while (sinPoints.length > limitCount) {
sinPoints.removeAt(0);
cosPoints.removeAt(0);
}
setState(() {
sinPoints.add(FlSpot(xValue, math.sin(xValue)));
cosPoints.add(FlSpot(xValue, math.cos(xValue)));
});
xValue += step;
});
DummyData(){
limitCount = (20/step).toInt();
sinPoints = List<FlSpot>.generate(limitCount+1, (index) => FlSpot(index+step,0));
}
@override
Widget build(BuildContext context) {
return cosPoints.isNotEmpty
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 12),
Text(
'x: ${xValue.toStringAsFixed(1)}',
style: const TextStyle(
color: AppColors.mainTextColor2,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
Text(
'sin: ${sinPoints.last.y.toStringAsFixed(1)}',
style: TextStyle(
color: widget.sinColor,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
Text(
'cos: ${cosPoints.last.y.toStringAsFixed(1)}',
style: TextStyle(
color: widget.cosColor,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
const SizedBox(
height: 12,
),
AspectRatio(
aspectRatio: 1.5,
child: Padding(
padding: const EdgeInsets.only(bottom: 24.0),
child: LineChart(
LineChartData(
minY: -1,
maxY: 1,
minX: sinPoints.first.x,
maxX: sinPoints.last.x,
lineTouchData: const LineTouchData(enabled: false),
clipData: const FlClipData.all(),
gridData: const FlGridData(
show: true,
drawVerticalLine: false,
),
borderData: FlBorderData(show: false),
lineBarsData: [
sinLine(sinPoints),
cosLine(cosPoints),
],
titlesData: const FlTitlesData(
show: false,
),
),
),
),
)
],
)
: Container();
void begin(Function() sc) {
stateChange = sc;
timer = Timer.periodic(const Duration(milliseconds: 2), (timer) {
stateChange.call();
if (xValue >= 20) {
xValue = 0;
index = 0;
sinPoints.clear();
} else {
xValue += step;
index += 1;
}
// print("$index : $xValue");
});
}
LineChartBarData sinLine(List<FlSpot> points) {
return LineChartBarData(
spots: points,
dotData: const FlDotData(
show: false,
),
gradient: LinearGradient(
colors: [widget.sinColor.withOpacity(0), widget.sinColor],
stops: const [0.1, 1.0],
),
barWidth: 4,
isCurved: false,
);
}
LineChartBarData cosLine(List<FlSpot> points) {
return LineChartBarData(
spots: points,
dotData: const FlDotData(
show: false,
),
gradient: LinearGradient(
colors: [widget.cosColor.withOpacity(0), widget.cosColor],
stops: const [0.1, 1.0],
),
barWidth: 4,
isCurved: false,
);
}
@override
void dispose() {
timer.cancel();
super.dispose();
void update(){
sinPoints.insert(index, FlSpot(xValue, 1 - (math.Random(xValue.toInt()).nextDouble()*2)));
}
}

View File

@ -0,0 +1,189 @@
[General]
decode_signals=3
meta_objs=0
views=1
[D0]
color=4279638298
conv_options=0
conversion_type=0
enabled=true
name=CS1
[D1]
color=4287582722
conv_options=0
conversion_type=0
enabled=true
name=MISO
[D2]
color=4291559424
conv_options=0
conversion_type=0
enabled=true
name=MOSI
[D3]
color=4294277376
conv_options=0
conversion_type=0
enabled=true
name=CLK
[D4]
color=4293776384
conv_options=0
conversion_type=0
enabled=true
name=DRDY1
[D5]
color=4285780502
conv_options=0
conversion_type=0
enabled=true
name=DRDY2
[D6]
color=4281623972
conv_options=0
conversion_type=0
enabled=true
name=CS2
[D7]
color=4287045754
conv_options=0
conversion_type=0
enabled=false
name=PROBE
[decode_signal0]
channel0\assigned_signal_name=CLK
channel0\initial_pin_state=2
channel0\name=CLK
channel1\assigned_signal_name=MISO
channel1\initial_pin_state=2
channel1\name=MISO
channel2\assigned_signal_name=MOSI
channel2\initial_pin_state=2
channel2\name=MOSI
channel3\assigned_signal_name=CS2
channel3\initial_pin_state=2
channel3\name=CS#
channels=4
color=4286722730
conv_options=0
conversion_type=0
decoder0\ann_class0\visible=true
decoder0\ann_class1\visible=true
decoder0\ann_class2\visible=true
decoder0\ann_class3\visible=true
decoder0\ann_class4\visible=true
decoder0\ann_class5\visible=true
decoder0\ann_class6\visible=true
decoder0\id=spi
decoder0\options=0
decoder0\row0\visible=false
decoder0\row1\visible=false
decoder0\row2\visible=true
decoder0\row3\visible=false
decoder0\row4\visible=false
decoder0\row5\visible=true
decoder0\row6\visible=true
decoder0\visible=true
decoders=1
enabled=true
name=ADC2
[decode_signal1]
channel0\assigned_signal_name=CLK
channel0\initial_pin_state=2
channel0\name=CLK
channel1\assigned_signal_name=MISO
channel1\initial_pin_state=2
channel1\name=MISO
channel2\assigned_signal_name=MOSI
channel2\initial_pin_state=2
channel2\name=MOSI
channel3\assigned_signal_name=CS1
channel3\initial_pin_state=2
channel3\name=CS#
channels=4
color=4294277376
conv_options=0
conversion_type=0
decoder0\ann_class0\visible=true
decoder0\ann_class1\visible=true
decoder0\ann_class2\visible=true
decoder0\ann_class3\visible=true
decoder0\ann_class4\visible=true
decoder0\ann_class5\visible=true
decoder0\ann_class6\visible=true
decoder0\id=spi
decoder0\options=0
decoder0\row0\visible=false
decoder0\row1\visible=false
decoder0\row2\visible=true
decoder0\row3\visible=false
decoder0\row4\visible=false
decoder0\row5\visible=true
decoder0\row6\visible=true
decoder0\visible=true
decoders=1
enabled=true
name=ADC1
[decode_signal2]
channel0\assigned_signal_name=CLK
channel0\initial_pin_state=2
channel0\name=CLK
channel1\assigned_signal_name=MISO
channel1\initial_pin_state=2
channel1\name=MISO
channel2\assigned_signal_name=MOSI
channel2\initial_pin_state=2
channel2\name=MOSI
channel3\initial_pin_state=2
channel3\name=CS#
channels=4
color=4288937984
conv_options=0
conversion_type=0
decoder0\ann_class0\visible=true
decoder0\ann_class1\visible=true
decoder0\ann_class2\visible=true
decoder0\ann_class3\visible=true
decoder0\ann_class4\visible=true
decoder0\ann_class5\visible=true
decoder0\ann_class6\visible=true
decoder0\id=spi
decoder0\options=0
decoder0\row0\visible=false
decoder0\row1\visible=true
decoder0\row2\visible=true
decoder0\row3\visible=false
decoder0\row4\visible=true
decoder0\row5\visible=true
decoder0\row6\visible=true
decoder0\visible=true
decoders=1
enabled=true
name=DBG
[view0]
D0\trace_height=34
D1\trace_height=34
D2\trace_height=34
D3\trace_height=34
D4\trace_height=34
D5\trace_height=34
D6\trace_height=34
D7\trace_height=34
offset=22 serialization::archive 19 0 0 0 0 288246 67324217 57335168 31063910 15766034 0 -8 1 0 6
scale=2.0767525574050047e-05
segment_display_mode=1
splitter_state="@ByteArray(\0\0\0\xff\0\0\0\x1\0\0\0\x2\0\0\0^\0\0\x5=\x1\0\0\0\x1\x1\0\0\0\x1\0)"
v_offset=-77
zero_offset=22 serialization::archive 19 0 0 0 0 0 0 0 0 0 0 0 0 0 6