Skip to content
This repository has been archived by the owner on Dec 31, 2018. It is now read-only.

Commit

Permalink
Bug fixing, Debian package update
Browse files Browse the repository at this point in the history
Also added CLI desktop launcher
  • Loading branch information
marcocipriani01 committed Apr 1, 2018
1 parent a54f03a commit 84bc6a9
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 44 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/marco.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified deb-builder/AstroAllInOne.deb
Binary file not shown.
7 changes: 0 additions & 7 deletions deb-builder/AstroAllInOne/usr/bin/astroallinone
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
#!/bin/bash
close() {
echo "Bye!"
exit 0
}
trap close INT

if [ -z "$(which java)" ]; then
echo "Java not found!"
exit 3
fi

dataDir="$HOME/.config/AstroAllInOne"
mkdir -p "$dataDir"
java -jar "/usr/share/AstroAllInOne/AstroAllInOne.jar" "--data-dir=$dataDir" "$@"
Binary file modified deb-builder/AstroAllInOne/usr/share/AstroAllInOne/AstroAllInOne.jar
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
Encoding=UTF-8
Name=AstroAllInOne console
Comment=AstroAllInOne by SquareBoot (terminal version)
Exec=/usr/bin/astroallinone --no-gui
Icon=/usr/share/AstroAllInOne/logo-terminal.png
Terminal=true
Type=Application
Categories=Application;Science;Astronomy;
StartupNotify=false
8 changes: 6 additions & 2 deletions src/squareboot/astro/allinone/ControlPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,12 @@ private ArduinoPin askNewPin() {
int value = 13;
do {
try {
value = Integer.valueOf(JOptionPane.showInputDialog(this, "New pin",
"Control panel", JOptionPane.QUESTION_MESSAGE));
String input = JOptionPane.showInputDialog(this, "New pin",
"Control panel", JOptionPane.QUESTION_MESSAGE);
if (input == null) {
return null;
}
value = Integer.valueOf(input);
check = false;

} catch (NumberFormatException e) {
Expand Down
61 changes: 32 additions & 29 deletions src/squareboot/astro/allinone/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @author SquareBoot
* @version 0.1
*/
@SuppressWarnings({"unused", "WeakerAccess"})
@SuppressWarnings("WeakerAccess")
public class Main {

/**
Expand Down Expand Up @@ -53,25 +53,11 @@ public class Main {
*/
private static SplashScreen splash;

static {
try {
logo = Toolkit.getDefaultToolkit().getImage(Main.class.
getResource("/squareboot/astro/allinone/res/logo.png"));

} catch (Exception e) {
System.err.println("Unable to load app image.");
e.printStackTrace();
}
}

/**
* Main. Configures the L&F and starts the application.
*/
public static void main(String[] args) {
splash = new SplashScreen(0);

CommandLineParser parser = new DefaultParser();

Options options = new Options();
options.addOption("d", "data-dir", true,
"The directory where AstroAllInOne will retrieve its settings.");
Expand All @@ -87,14 +73,25 @@ public static void main(String[] args) {
try {
CommandLine line = parser.parse(options, args);

if (!line.hasOption('g')) {
showGui = !line.hasOption('n');
if (showGui) {
splash = new SplashScreen(500);
try {
System.out.println("Loading GTK...");
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
logo = Toolkit.getDefaultToolkit().getImage(Main.class.
getResource("/squareboot/astro/allinone/res/logo.png"));

} catch (Exception e) {
System.err.println("Unable to set up GTK: " + e.getMessage());
e.printStackTrace();
System.err.println("Unable to load app image.");
}
if (!line.hasOption('g')) {
try {
System.out.println("Loading GTK...");
UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");

} catch (Exception e) {
System.err.println("Unable to set up GTK: " + e.getMessage());
e.printStackTrace();
}
}
}

Expand All @@ -121,8 +118,6 @@ public static void main(String[] args) {
settings.setUsbPort(line.getOptionValue('s'));
}

showGui = !line.hasOption('n');

} catch (ParseException e) {
System.err.println("The given arguments are not valid!");
exit(ExitCodes.PARSE_ERROR);
Expand Down Expand Up @@ -171,7 +166,9 @@ private static void start() {
server.loadJava(INDIArduinoDriver.class);
SimpleSerialPort realArduino;
try {
realArduino = new SimpleSerialPort(settings.getUsbPort());
String usbPort = settings.getUsbPort();
System.out.println("Connecting to serial port \"" + usbPort + "\"...");
realArduino = new SimpleSerialPort(usbPort);

} catch (ConnectionError e) {
System.err.println("Unable to connect to the given serial port!");
Expand Down Expand Up @@ -218,12 +215,18 @@ private static void start() {
return;
}

System.out.println("Starting status window...");
SwingUtilities.invokeLater(() -> {
splash.dispose();
splash = null;
new ServerMiniWindow(multiplexer.getMockedPort(), arduinoDriver);
});
System.out.println("Connect MoonLite to port " + multiplexer.getMockedPort());
if (showGui) {
System.out.println("Starting status window...");
SwingUtilities.invokeLater(() -> {
splash.dispose();
splash = null;
new ServerMiniWindow(multiplexer.getMockedPort(), arduinoDriver);
});

} else {
System.out.println("Control-C to close");
}
}

/**
Expand Down
27 changes: 21 additions & 6 deletions src/squareboot/astro/allinone/indi/INDIArduinoDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,33 @@ public void init(GenericSerialPort serialPort, ArduinoPin[] switchPins, ArduinoP
digitalPinProps = new INDISwitchProperty(this, "Digital pins", "Digital pins", "Control",
PropertyStates.OK, PropertyPermissions.RW, Constants.SwitchRules.ANY_OF_MANY);
for (ArduinoPin pin : switchPins) {
printMessage("onDigitalPinCreate(" + pin + ")");
pinsMap.put(new INDISwitchElement(digitalPinProps, "Pin " + pin.getPin(),
pin.getName(), pin.getValueIndi()), pin);
int p = checkPin(pin);
if (p != -1) {
pinsMap.put(new INDISwitchElement(digitalPinProps, "Pin " + p,
pin.getName(), pin.getValueIndi()), pin);
}
}

pwmPinsProp = new INDINumberProperty(this, "PWM pins", "PWM pins", "Control",
PropertyStates.OK, PropertyPermissions.RW);
for (ArduinoPin pin : pwmPins) {
printMessage("onPwmPinCreate(" + pin + ")");
pinsMap.put(new INDINumberElement(pwmPinsProp, "PWM pin" + pin.getPin(), pin.getName(),
(double) pin.getValuePercentage(), 0.0, 100.0, 1.0, "%f"), pin);
int p = checkPin(pin);
if (p != -1) {
pinsMap.put(new INDINumberElement(pwmPinsProp, "PWM pin" + p, pin.getName(),
(double) pin.getValuePercentage(), 0.0, 100.0, 1.0, "%f"), pin);
}
}
}

private int checkPin(ArduinoPin pin) {
printMessage("Defining pin: " + pin);
int p = pin.getPin();
if ((p < 2) || (p > 99)) {
System.err.println("Ignoring pin, \"" + p + "\" is out the allowed bounds!");
return -1;
}
updatePin(pin);
return p;
}

/**
Expand Down

0 comments on commit 84bc6a9

Please sign in to comment.