summaryrefslogtreecommitdiff
path: root/micropeak/MicroStats.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-02-09 20:24:33 -0800
committerKeith Packard <keithp@keithp.com>2013-02-10 00:30:32 -0800
commit0169e56ad030c0096b1068d00f06957990dfb31f (patch)
tree9a70b183d8170a8633cfac932a0ed8f2f17660f0 /micropeak/MicroStats.java
parent518b16f64f4be096ceff13ab31b96d6909fe3ae2 (diff)
altosuilib/micropeak: Add state markers to micropeak graph
I think this makes the micropeak graph as functional as the altosui graph Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'micropeak/MicroStats.java')
-rw-r--r--micropeak/MicroStats.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/micropeak/MicroStats.java b/micropeak/MicroStats.java
index abc1296b..99479cb4 100644
--- a/micropeak/MicroStats.java
+++ b/micropeak/MicroStats.java
@@ -150,6 +150,43 @@ public class MicroStats {
return descent_height() / descent_duration();
}
+ public static final int state_startup = -1;
+ public static final int state_pad = 0;
+ public static final int state_boost = 1;
+ public static final int state_coast = 2;
+ public static final int state_descent = 3;
+ public static final int state_landed = 4;
+
+ static final String state_names[] = {
+ "pad",
+ "boost",
+ "coast",
+ "descent",
+ "landed"
+ };
+
+ public int state(double t) {
+ if (t >= landed_time)
+ return state_landed;
+ if (t >= apogee_time)
+ return state_descent;
+ if (t >= coast_time)
+ return state_coast;
+ if (t >= 0)
+ return state_boost;
+ return state_pad;
+ }
+
+ public static String state_name(int state) {
+ if (state < 0 || state > state_landed)
+ return "unknown";
+ return state_names[state];
+ }
+
+ public String state_name(double t) {
+ return state_name(state(t));
+ }
+
public MicroStats(MicroData data) {
this.data = data;