Skip to content

Commit 05aeee6

Browse files
committed
Adding offset-able start position.
- Useful for jittery distance measurement (when stationary)
1 parent f565cc2 commit 05aeee6

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

fcv/KiibohdForce.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,19 @@ def processCommandLineArgs( varContainer ):
131131
pArgs.add_argument( 'switch_name', help=argparse.SUPPRESS ) # Suppressed help output, because Python output is verbosely ugly
132132

133133
# Optional Arguments
134+
pArgs.add_argument( '-o', '--start-offset', type=int, default=0,
135+
help="Specify a start offset, useful if measurement sensor is being jittery for whatever reason.\n Use base sensor units." )
134136
pArgs.add_argument( '-h', '--help', action="help",
135137
help="This message." )
136138

137139
# Process Arguments
138140
args = pArgs.parse_args()
139141

140142
# Parameters
141-
varContainer['SwitchName'] = args.switch_name
142-
varContainer['SerialPort'] = args.serial_port
143-
varContainer['Filename'] = "{0}.raw".format( varContainer['SwitchName'] )
143+
varContainer['StartOffset'] = args.start_offset
144+
varContainer['SwitchName'] = args.switch_name
145+
varContainer['SerialPort'] = args.serial_port
146+
varContainer['Filename'] = "{0}.raw".format( varContainer['SwitchName'] )
144147

145148
# Check file existance, and rename if necessary
146149
counter = 1
@@ -169,8 +172,8 @@ def recordData( varContainer, forceData ):
169172
# Initialize serial port, USB serial port is used, speed does not have to be negotiated
170173
ser = serial.Serial( varContainer['SerialPort'], timeout=2 )
171174

172-
# Mark the start/end position of the reading
173-
cmdOut = sendCmd( ser, "start" )
175+
# Mark the start/end position of the reading give, with a given offset
176+
cmdOut = sendCmd( ser, "start {0}".format( varContainer['StartOffset'] ) )
174177

175178
# Start the free recording
176179
print "Initiating force curve reading..."

main.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ CLIDictItem forceGaugeCLIDict[] = {
7575
{ "gaugeHelp", "Description on how to use the force gauge firmware.", cliFunc_gaugeHelp },
7676
{ "imadaComm", "Send specific commands to the Imada force gauge. See \033[35mgaugeHelp\033[0m for more details.", cliFunc_imadaComm },
7777
{ "read", "Query a force/distance measurement. See \033[35mgaugeHelp\033[0m for more details.", cliFunc_read },
78-
{ "start", "Mark the current distance as the start/end position.", cliFunc_start },
78+
{ "start", "Mark the current distance as the start/end position, offset is optional.", cliFunc_start },
7979
{ "stop", "Stop free reporting or read loop.", cliFunc_stop },
8080
{ "zeroForce", "Zero out the force gauge.", cliFunc_zeroForce },
8181
{ "zeroPosition", "Mark the minimum distance for this measurement (bottom).", cliFunc_zeroPosition },
@@ -589,6 +589,7 @@ void cliFunc_gaugeHelp( char* args )
589589
" Distance marker \033[35m[start]\033[0m for the start/end of a force curve measurement." NL
590590
" While in free running mode, a special message is displayed when reaching the \033[35m[start]\033[0m point." NL
591591
" \033[35m[start]\033[0m is defined by positioning the distance sensor at the position to start and running this command." NL
592+
" The argument is an offset integer." NL
592593
);
593594
}
594595

@@ -617,8 +618,17 @@ void cliFunc_read( char* args )
617618

618619
void cliFunc_start( char* args )
619620
{
621+
// Parse number from argument
622+
// NOTE: Only first argument is used
623+
char* arg1Ptr;
624+
char* arg2Ptr;
625+
argumentIsolation_cli( args, &arg1Ptr, &arg2Ptr );
626+
627+
// Convert the argument into an int
628+
int offset = decToInt( arg1Ptr ) + 1;
629+
620630
// Read the current distance and set the new start/end position
621-
distanceStart = readDistanceGauge();
631+
distanceStart = readDistanceGauge() + offset;
622632

623633
print( NL );
624634
info_msg("New start/end position: ");

0 commit comments

Comments
 (0)