From 39cb305fe88e62c78c2af99d2aed7dffc740c318 Mon Sep 17 00:00:00 2001 From: a2nr Date: Wed, 16 Oct 2024 20:47:07 +0700 Subject: [PATCH] setelah testing dengan tikus --- Software/dashboard/Makefile | 6 +- Software/dashboard/lib/hal/X9C10X.dart | 2 +- Software/dashboard/lib/hal/ads1256.dart | 15 +- .../dashboard/lib/hardware/heartbeatmice.dart | 29 +-- Software/dashboard/lib/main.dart | 193 ++++++++++-------- Software/dashboard/lib/ui/plot.dart | 2 +- 6 files changed, 137 insertions(+), 110 deletions(-) diff --git a/Software/dashboard/Makefile b/Software/dashboard/Makefile index 9839a58..83569b6 100644 --- a/Software/dashboard/Makefile +++ b/Software/dashboard/Makefile @@ -4,7 +4,7 @@ TARGET_PATH := /home/$(TARGET_USER)/heartbeatmice/dashboard TARGET_PATH_STR := \/home\/$(TARGET_USER)\/heartbeatmice\/dashboard TARGET_PASS := 'a2nr' PROBE_USER := a2nr -PROBE_HOST := 10.4.106.249 +PROBE_HOST := mekatronika PROBE_PATH := /home/$(PROBE_USER)/ PROBE_PASS := 'Bismillah...' @@ -26,7 +26,7 @@ copy_target: sshpass -p $(TARGET_PASS) ssh -t $(TARGET_USER)@$(TARGET_HOST) 'mkdir -p $(TARGET_PATH)' \ && 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_app: @@ -43,7 +43,7 @@ install_dep: 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' probe: - 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) 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=1M --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 diff --git a/Software/dashboard/lib/hal/X9C10X.dart b/Software/dashboard/lib/hal/X9C10X.dart index a293c05..7371f1f 100644 --- a/Software/dashboard/lib/hal/X9C10X.dart +++ b/Software/dashboard/lib/hal/X9C10X.dart @@ -39,7 +39,7 @@ class X9c10x { _ud.write(true); _skip(); _inc.write(false); - //while(true){} //TODO: DEAD CODE; + while(true){} //TODO: DEAD CODE; _skip(); _inc.write(true); _releaseChip(); diff --git a/Software/dashboard/lib/hal/ads1256.dart b/Software/dashboard/lib/hal/ads1256.dart index 0d39c27..776eee5 100644 --- a/Software/dashboard/lib/hal/ads1256.dart +++ b/Software/dashboard/lib/hal/ads1256.dart @@ -36,7 +36,7 @@ class Ads1256 { String? tag, int? pinReset, int? pinCS }){ - spi = SPI(spiBus, spiChip, SPImode.mode1, 50000); + spi = SPI(spiBus, spiChip, SPImode.mode1, 500000); drdy = GPIO(pinDrdy, GPIOdirection.gpioDirIn, gpioChip); cs = pinCS != null ? GPIO(pinCS, GPIOdirection.gpioDirOutHigh, gpioChip): null; rst = pinReset != null ? GPIO(pinReset, GPIOdirection.gpioDirOutHigh, gpioChip): null; @@ -108,16 +108,16 @@ class Ads1256 { void csOn(){ cs?.write(isCSActiveHigh?true:false); - skipClk(); - skipClk(); + //skipClk(); + //skipClk(); skipClk(); log.info(" > Start transfer"); } void csOff(){ log.info(" > End transfer"); cs?.write(isCSActiveHigh?false:true); - skipClk(); - skipClk(); + //skipClk(); + //skipClk(); skipClk(); } @@ -187,14 +187,15 @@ class Ads1256 { csOn(); int dio = readRegister(RADD_IO); csOff(); - log.info(" get ioDir <${dio.toRadixString(16)}>"); + log.info(" get dIO <${dio.toRadixString(16)}>"); return dio.toListBoolbit(); } set dIO(List io){ - log.info(" set ioDir <$io -- ${io.toNibble()}>"); + log.info(" set dIO <$io -- ${io.toNibble().toRadixString(16)}>"); csOn(); writeRegister(RADD_IO, io.toNibble() ); csOff(); + log.info(" confirm <$dIO>"); } set channelNCS(int c) => writeRegister(RADD_MUX, c); diff --git a/Software/dashboard/lib/hardware/heartbeatmice.dart b/Software/dashboard/lib/hardware/heartbeatmice.dart index 81e6e45..1221e60 100644 --- a/Software/dashboard/lib/hardware/heartbeatmice.dart +++ b/Software/dashboard/lib/hardware/heartbeatmice.dart @@ -55,8 +55,8 @@ class HeartBeatMice { 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]; - adc1.dIO = [false, false, false, false]; - adc2.dIO = [false, false, false, false]; + adc1.dIO = [true, true, true, false]; // SIG2 SIG1 EN2 EN1 + adc2.dIO = [false, false, false, false]; // S0 S1 S2 S3 } @@ -89,26 +89,29 @@ class HeartBeatMice { void _signalMux(int n, bool val) { log.info('_signalMux() <$n> <$val>'); int i = switch (n) { - 1 => 0, - 2 => 1, + 1 => 1, + 2 => 0, _ => -1 }; log.info(' >mux : $i'); if (i == -1){ return; } - List io = adc2.dIO; + var adc = adc1; + List io = adc.dIO; log.info(' >current <$io>'); - io[i] = val; - io[i+2] = val; - adc2.dIO = io; - log.info(' >confirm <${adc2.dIO}>'); + io[i] = val; //SIG + io[i+2] = !val; //EN + adc.dIO = io; + log.info(' >confirm <${adc.dIO}>'); } - void _channelMux(int val) { + void _channelMux(int v) { + int val = v-1; + var adc = adc2; log.info('_channelMux() <${val.toRadixString(16)}>'); - log.info(' >current <${adc1.dIO}>'); - adc1.dIO = val.toListBoolbit(); - log.info(' >confirm <${adc1.dIO}>'); + log.info(' >current <${adc.dIO}>'); + adc.dIO = val.toListBoolbit(); + log.info(' >confirm <${adc.dIO}>'); } int _routeMux(an) => switch(an){ 1 ||2 || 3|| 4|| 5|| 6|| 7|| 8 =>1, diff --git a/Software/dashboard/lib/main.dart b/Software/dashboard/lib/main.dart index a96132f..f1f974f 100644 --- a/Software/dashboard/lib/main.dart +++ b/Software/dashboard/lib/main.dart @@ -63,8 +63,8 @@ class _MyHomePageState extends State { @override Widget build(BuildContext context) { - double height = 300/4; - double width = (MediaQuery.of(context).size.width-30)/4; + double height = 300; + double width = (MediaQuery.of(context).size.width-30); return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, @@ -74,13 +74,36 @@ class _MyHomePageState extends State { SizedBox( width: width, child: ListView.builder( - itemCount: 4, + itemCount: 1, itemBuilder: (context, i){ - var index = i+12; + var index = i+1; return Column( children: [ Text("Analog $index"), - SizedBox ( + 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)), + ]), + ],), + ], + ), + SizedBox ( height: height.toDouble(), width: width, child : Plot( @@ -93,88 +116,88 @@ class _MyHomePageState extends State { readAnalog: () async { return device.readAnalog(index); } ), ), - ], - ); - }, - )), - SizedBox( - width: width, - child: ListView.builder( - itemCount: 4, - itemBuilder: (context, i){ - var index = i+8; - return Column( - children: [ - 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: [ - 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: [ - 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: [ +// 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: [ +// 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: [ +// 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); } +// ), +// ), +// ], +// ); +// }, +// )), ]) ); } diff --git a/Software/dashboard/lib/ui/plot.dart b/Software/dashboard/lib/ui/plot.dart index 38b8688..4a498a0 100644 --- a/Software/dashboard/lib/ui/plot.dart +++ b/Software/dashboard/lib/ui/plot.dart @@ -31,7 +31,7 @@ class Plot extends StatefulWidget { class _Plot extends State { late Timer timer; late int limit= ((widget.maxTimeSeconds)/(widget.sampleTimeMicross/1000)).toInt(); - late List adc = []; + late List adc = [const FlSpot( 0, 0)]; int index = 0; double el = 0.0; double valPrev = 0;