setelah testing dengan tikus

software
a2nr 2024-10-16 20:47:07 +07:00
parent fa93c3b75e
commit 39cb305fe8
6 changed files with 137 additions and 110 deletions

View File

@ -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

View File

@ -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();

View File

@ -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<bool> 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);

View File

@ -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<bool> io = adc2.dIO;
var adc = adc1;
List<bool> 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,

View File

@ -63,8 +63,8 @@ class _MyHomePageState extends State<MyHomePage> {
@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,90 +74,35 @@ class _MyHomePageState extends State<MyHomePage> {
SizedBox(
width: width,
child: ListView.builder(
itemCount: 4,
itemCount: 1,
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;
var index = i+1;
return Column(
children: <Widget>[
Text("Analog $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)),
]),
],),
],
),
SizedBox (
height: height.toDouble(),
width: width,
@ -175,6 +120,84 @@ class _MyHomePageState extends State<MyHomePage> {
);
},
)),
// 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); }
// ),
// ),
// ],
// );
// },
// )),
])
);
}

View File

@ -31,7 +31,7 @@ class Plot extends StatefulWidget {
class _Plot extends State<Plot> {
late Timer timer;
late int limit= ((widget.maxTimeSeconds)/(widget.sampleTimeMicross/1000)).toInt();
late List<FlSpot> adc = <FlSpot>[];
late List<FlSpot> adc = <FlSpot>[const FlSpot( 0, 0)];
int index = 0;
double el = 0.0;
double valPrev = 0;