X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=micropeak%2FMicroDownload.java;h=a9095f9c6bc9ed5da1c5d21b9d9d5a4486f982d0;hp=e04d6790f048909385fbaaaae6c17c07e62dabe0;hb=5b976a6651f4eb05d30afc08b9e1f27c7e52ae00;hpb=4dae5b876b089c17c87c72df2ad2fa5ec4f1657c diff --git a/micropeak/MicroDownload.java b/micropeak/MicroDownload.java index e04d6790..a9095f9c 100644 --- a/micropeak/MicroDownload.java +++ b/micropeak/MicroDownload.java @@ -23,8 +23,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.AltosLib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_2.*; +import org.altusmetrum.altosuilib_1.*; public class MicroDownload extends AltosUIDialog implements Runnable, ActionListener { MicroPeak owner; @@ -37,10 +37,17 @@ public class MicroDownload extends AltosUIDialog implements Runnable, ActionList private void done_internal() { setVisible(false); if (data != null) { - owner = owner.SetData(data); - MicroSave save = new MicroSave(owner, data); - if (save.runDialog()) - owner.SetName(data.name); + if (data.crc_valid) { + owner = owner.SetData(data); + MicroSave save = new MicroSave(owner, data); + if (save.runDialog()) + owner.SetName(data.name); + } else { + JOptionPane.showMessageDialog(owner, + "Flight data corrupted", + "Download Failed", + JOptionPane.ERROR_MESSAGE); + } } dispose(); } @@ -85,11 +92,14 @@ public class MicroDownload extends AltosUIDialog implements Runnable, ActionList serial.close(); serial_thread.interrupt(); } + setVisible(false); } public MicroDownload(MicroPeak owner, AltosDevice device) { super (owner, "Download MicroPeak Data", false); + int y = 0; + GridBagConstraints c; Insets il = new Insets(4,4,4,4); Insets ir = new Insets(4,4,4,4); @@ -101,7 +111,7 @@ public class MicroDownload extends AltosUIDialog implements Runnable, ActionList pane.setLayout(new GridBagLayout()); c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 0; + c.gridx = 0; c.gridy = y; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -109,29 +119,66 @@ public class MicroDownload extends AltosUIDialog implements Runnable, ActionList pane.add(device_label, c); c = new GridBagConstraints(); - c.gridx = 1; c.gridy = 0; + c.gridx = 1; c.gridy = y; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; c.insets = ir; JLabel device_value = new JLabel(device.toString()); pane.add(device_value, c); + y++; + + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = y; + c.gridwidth = GridBagConstraints.REMAINDER; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + JTextArea help_text = new JTextArea( + + "Locate the photo transistor on the MicroPeak USB adapter\n" + + "and place the LED on the MicroPeak directly in contact\n" + + "with it.\n" + + "\n" + + "The MicroPeak LED and the MicroPeak USB adapter\n" + + "photo need to be touching—even a millimeters of space\n" + + "between them will reduce the light intensity from the LED\n" + + "enough that the phototransistor will not sense it.\n" + + "\n" + + "Turn on the MicroPeak board and adjust the position until\n" + + "the blue LED on the MicroPeak USB adapter blinks in time\n" + + "with the orange LED on the MicroPeak board."); + + pane.add(help_text, c); + y++; + + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = y; + c.gridwidth = 1; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + JLabel waiting_value = new JLabel("Waiting for MicroPeak data..."); + pane.add(waiting_value, c); cancel = new JButton("Cancel"); c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; - c.gridx = 0; c.gridy = 1; + c.gridx = 1; c.gridy = y; c.gridwidth = GridBagConstraints.REMAINDER; Insets ic = new Insets(4,4,4,4); c.insets = ic; pane.add(cancel, c); + y++; cancel.addActionListener(this); pack(); setLocationRelativeTo(owner); setVisible(true); - this.start(); + start(); } }