From 426bacbbd6e0573b143e7c48d71db977e53181fc Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 7 Feb 2015 20:22:19 -0800 Subject: altosuilib: Get the Eeprom download progress bar working again The eeprom download code wasn't computing the start of each state transition correctly, so the progress bar was snapping to the end of the chunk for each state. Invalid state values would snap the bar to the right side. Landed state wasn't ever seen, so the bar would not ever fill. Signed-off-by: Keith Packard --- altosuilib/AltosEepromMonitorUI.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'altosuilib/AltosEepromMonitorUI.java') diff --git a/altosuilib/AltosEepromMonitorUI.java b/altosuilib/AltosEepromMonitorUI.java index b72dfdf4..d2d95678 100644 --- a/altosuilib/AltosEepromMonitorUI.java +++ b/altosuilib/AltosEepromMonitorUI.java @@ -167,15 +167,21 @@ public class AltosEepromMonitorUI extends AltosUIDialog implements AltosEepromMo pos = lblock / 1000.0; s = String.format("block %d", block); } else { + if (state == AltosLib.ao_flight_invalid) + state = 0; if (state_block > 100) state_block = 100; if (state < min_state) state = min_state; - if (state >= max_state) state = max_state - 1; + if (state > max_state) state = max_state; + + if (state == max_state) + state_block = 0; + state -= min_state; int nstate = max_state - min_state; - double spos = (double) (state - min_state) / (double) nstate; + double spos = (double) state / (double) nstate; double bpos = state_block / 100.0; pos = spos + bpos / nstate; -- cgit v1.2.3