summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-10-12 13:59:50 -0700
committerKeith Packard <keithp@keithp.com>2012-10-12 13:59:50 -0700
commit68308908afbd1f04b17056d2be408c89b3578c86 (patch)
treeafeb849572b1b4c22e56a9fa282de124951aa69f /src/util
parent175380a436efa35bbfae2ee5e29e12e9ef86fbde (diff)
altos: Parameterize altitude table access and initialization
This allows projects to store the altitude data in different representations or with different access modes. By default, altitude data is stored in meters, but the initializers include decimeter values so those can be used instead if desired. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/make-altitude-pa10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/util/make-altitude-pa b/src/util/make-altitude-pa
index eae5ebe9..22831d50 100644
--- a/src/util/make-altitude-pa
+++ b/src/util/make-altitude-pa
@@ -239,8 +239,8 @@ real sample_to_fit_altitude(int sample) {
real i_v;
r_v = sample * l.m + l.b;
- i_v = (round(alt_part[sub]) * (seg_len - off) + round(alt_part[sub+1]) * off) / seg_len;
- return i_v;
+ i_v = (round(alt_part[sub]*10) * (seg_len - off) + round(alt_part[sub+1]*10) * off) / seg_len;
+ return i_v/10;
}
real max_error = 0;
@@ -279,11 +279,11 @@ printf ("/*max error %f at %7.3f kPa. Average error %f*/\n",
printf ("#define NALT %d\n", dim(alt_part));
printf ("#define ALT_SHIFT %d\n", pa_part_shift + pa_sample_shift);
-printf ("#ifndef SATURATE\n#define SATURATE(x) (x)\n#endif\n");
+printf ("#ifndef AO_ALT_VALUE\n#define AO_ALT_VALUE(x) (alt_t) (x)\n#endif\n");
for (int part = 0; part < dim(alt_part); part++) {
real kPa = sample_to_Pa(part_to_sample(part)) / 1000;
- printf ("SATURATE(%9d), /* %6.2f kPa error %6.2fm */\n",
- round (alt_part[part]), kPa,
+ printf ("AO_ALT_VALUE(%10.1f), /* %6.2f kPa error %6.2fm */\n",
+ round (alt_part[part]*10) / 10, kPa,
alt_error[part]);
}