From f982248573c1b646ac53fde980a60ada5404f6aa Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 27 May 2016 20:30:18 -0700 Subject: [PATCH] altosuilib: Fill preload map on site or lat/lon change This loads the map view with the selected area when the site entry is changed or the user hits return in the lat/lon fields. This lets you see the target launch site without having to load the whole preload set. Signed-off-by: Keith Packard --- altosuilib/AltosUIMapPreload.java | 40 ++++++++++++++++++++++++------- src/drivers/ao_trng_send.c | 10 +++++++- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/altosuilib/AltosUIMapPreload.java b/altosuilib/AltosUIMapPreload.java index 42fdd301..32690037 100644 --- a/altosuilib/AltosUIMapPreload.java +++ b/altosuilib/AltosUIMapPreload.java @@ -28,7 +28,8 @@ import java.net.URL; import java.net.URLConnection; import org.altusmetrum.altoslib_11.*; -class AltosUIMapPos extends Box { +class AltosUIMapPos extends Box implements ActionListener { + AltosUIMapPreload preload; AltosUIFrame owner; JLabel label; JComboBox hemi; @@ -37,6 +38,11 @@ class AltosUIMapPos extends Box { JTextField min; JLabel min_label; + /* ActionListener interface */ + public void actionPerformed(ActionEvent e) { + preload.center_map(); + } + public void set_value(double new_value) { double d, m; int h; @@ -88,19 +94,23 @@ class AltosUIMapPos extends Box { } public AltosUIMapPos(AltosUIFrame in_owner, - String label_value, - String[] hemi_names, - double default_value) { + AltosUIMapPreload preload, + String label_value, + String[] hemi_names, + double default_value) { super(BoxLayout.X_AXIS); owner = in_owner; + this.preload = preload; label = new JLabel(label_value); hemi = new JComboBox(hemi_names); hemi.setEditable(false); deg = new JTextField(5); + deg.addActionListener(this); deg.setMinimumSize(deg.getPreferredSize()); deg.setHorizontalAlignment(JTextField.RIGHT); deg_label = new JLabel("°"); min = new JTextField(9); + min.addActionListener(this); min.setMinimumSize(min.getPreferredSize()); min_label = new JLabel("'"); set_value(default_value); @@ -166,8 +176,6 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I pbar.setMaximum(max); pbar.setValue(0); pbar.setString(""); - map.clear_marks(); - map.add_mark(latitude, longitude, AltosLib.ao_flight_boost); } }); } @@ -213,6 +221,19 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I return all_types; } + void center_map(double latitude, double longitude) { + map.map.centre(new AltosLatLon(latitude, longitude)); + map.clear_marks(); + map.add_mark(latitude, longitude, AltosLib.ao_flight_boost); + } + + void center_map() { + try { + center_map(lat.get_value(), lon.get_value()); + } catch (ParseException pe) { + } + } + public void itemStateChanged(ItemEvent e) { int state = e.getStateChange(); @@ -222,6 +243,7 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I AltosLaunchSite site = (AltosLaunchSite) o; lat.set_value(site.latitude); lon.set_value(site.longitude); + center_map(site.latitude, site.longitude); } } } @@ -251,7 +273,7 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I else r = r * 1000; - map.map.centre(new AltosLatLon(latitude, longitude)); + center_map(latitude, longitude); loader = new AltosMapLoader(this, latitude, longitude, @@ -393,7 +415,7 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I pane.add(site_list, c); - lat = new AltosUIMapPos(owner, + lat = new AltosUIMapPos(owner, this, "Latitude:", lat_hemi_names, 37.167833333); @@ -410,7 +432,7 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I pane.add(lat, c); - lon = new AltosUIMapPos(owner, + lon = new AltosUIMapPos(owner, this, "Longitude:", lon_hemi_names, -97.73975); diff --git a/src/drivers/ao_trng_send.c b/src/drivers/ao_trng_send.c index 171a345f..4ac6ee5e 100644 --- a/src/drivers/ao_trng_send.c +++ b/src/drivers/ao_trng_send.c @@ -22,7 +22,7 @@ #include #include -static struct ao_task ao_trng_send_task, ao_trng_send_raw_task; +static struct ao_task ao_trng_send_task; static uint8_t trng_running; static AO_TICK_TYPE trng_power_time; @@ -30,6 +30,10 @@ static AO_TICK_TYPE trng_power_time; static uint8_t random_mutex; +#if AO_USB_HAS_IN2 + +static struct ao_task ao_trng_send_raw_task; + static void ao_trng_get_raw(uint16_t *buf) { @@ -90,6 +94,8 @@ ao_trng_send_raw(void) } } +#endif + /* Make sure there's at least 8 bits of variance in the samples */ #define MIN_VARIANCE (128 * 128) @@ -181,7 +187,9 @@ ao_trng_send(void) if (failed > AO_TRNG_START_CHECK / 4) ao_panic(AO_PANIC_DMA); +#if AO_USB_HAS_IN2 ao_add_task(&ao_trng_send_raw_task, ao_trng_send_raw, "trng_send_raw"); +#endif #ifdef AO_USB_START_DISABLED ao_usb_enable(); -- 2.30.2