#!/usr/bin/perl


# this should be a module, and be called from make_conf.pl, since that
# knows config. (or make_conf be a module too...)

# foreach VBatt, kPA, msp.. # only a few values from each, we don't want gigaoutput
# print (VBatt, kPa, msp.., RPM, dwelllen, ignout_DC)


# I used mst08 and trigger=FE (even trigger, 8 cyl)
my @ignout=qw(4.58 4.03 3.57 2.72 2.04 1.11 0.8 1.05 1.25);
#this dwelled-dwell was with lower measured VBatt (not populated, maybe 0V?).
#my @ignout=qw(4.25, 3.43 2.87 1.68 0.74 0.77 0.8 1.05 1.23);
# some test cases I run on Chris' config:
my $msp; my $i=0;
foreach $msp (qw(88 34 23 15 10 0C 08 06 05)){

	my $period=hex($msp) * 256 + 40;	# usec (trigger signal); +40 is correction since msp is a bit delayed
	my $crank_period = 4*$period;	# 8cyl even fire
	my $rpm = int( 60000000 / $crank_period);
	my $out_duty=(5.0 - $ignout[$i])/5.0;
	my $meas_dwell = int($out_duty * $period);

	print "$msp\t$period\t$rpm\t$meas_dwell\n";
	$i++;
}
