mirror of
https://github.com/brendanhaines/RasPi.git
synced 2025-04-11 19:24:51 -06:00
adds 'arm motor' button
This commit is contained in:
parent
3ca4c787c6
commit
6d76979ea4
@ -143,10 +143,6 @@ class ConnectionPanel extends JPanel implements ActionListener {
|
||||
if( contentOut.getMotorsEnabled() ) out.print( "E " ); // enable motors (redundant)
|
||||
}
|
||||
}
|
||||
/*if( contentOut.orientation ) {
|
||||
for( int i = 0; i < contentOut.orientValues.length; i++ )
|
||||
out.print( "O" + i + "_" + contentOut.orientValues[i] + " " );
|
||||
}*/
|
||||
out.println();
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,9 @@ class GroundStation implements ActionListener {
|
||||
/** connection options section of window */
|
||||
private ConnectionPanel connectPanel;
|
||||
|
||||
/** flight controller arm/disarm button*/
|
||||
private ArmButton arm;
|
||||
|
||||
/** tabbed pane to hold stuff */
|
||||
private JTabbedPane tabbedPane;
|
||||
/** motor testing panel */
|
||||
@ -40,8 +43,9 @@ class GroundStation implements ActionListener {
|
||||
connectPanel.setEnabled( true );
|
||||
mainWindow.getContentPane().add( connectPanel );
|
||||
|
||||
JButton fcButton = new JButton( "arm" );
|
||||
mainWindow.getContentPane().add( fcButton );
|
||||
arm = new ArmButton( sendContent );
|
||||
arm.setEnabled( false );
|
||||
mainWindow.getContentPane().add( arm );
|
||||
|
||||
tabbedPane = new JTabbedPane();
|
||||
mainWindow.getContentPane().add( tabbedPane );
|
||||
@ -67,11 +71,23 @@ class GroundStation implements ActionListener {
|
||||
|
||||
public void disableMotors() {
|
||||
connectPanel.setEnabled( true );
|
||||
|
||||
arm.setEnabled( true );
|
||||
motorTestPanel.setEnabled( true );
|
||||
|
||||
eStopWindow.dispose();
|
||||
}
|
||||
|
||||
public void enableMotors() {
|
||||
connectPanel.setEnabled( false );
|
||||
|
||||
if( motorTestPanel.getTestStatus() ) {
|
||||
arm.setEnabled( false );
|
||||
}
|
||||
else {
|
||||
motorTestPanel.setEnabled( false );
|
||||
}
|
||||
|
||||
eStopWindow = new EStopWindow();
|
||||
eStopWindow.addActionListener( this );
|
||||
}
|
||||
@ -79,15 +95,18 @@ class GroundStation implements ActionListener {
|
||||
public void actionPerformed( ActionEvent evt ) {
|
||||
if( evt.getSource() == eStopWindow ) {
|
||||
sendContent.setMotorsEnabled( false );
|
||||
arm.setText( "Arm Flight Controller" );
|
||||
}
|
||||
if( evt.getSource() == connectPanel ) {
|
||||
if( evt.getActionCommand().equals( "CONNECT" ) ) {
|
||||
mainWindow.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE );
|
||||
motorTestPanel.setEnabled( true );
|
||||
arm.setEnabled( true );
|
||||
}
|
||||
else if( evt.getActionCommand().equals( "DISCONNECT" ) ) {
|
||||
mainWindow.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
|
||||
motorTestPanel.setEnabled( false );
|
||||
arm.setEnabled( false );
|
||||
}
|
||||
}
|
||||
else if( evt.getActionCommand().equals( "ENABLE_MOTORS" ) ) {
|
||||
|
@ -79,10 +79,10 @@ class MotorTestPanel extends JPanel implements ActionListener {
|
||||
*
|
||||
*/
|
||||
public void setEnabled( boolean state ) {
|
||||
checkBox.setEnabled( state );
|
||||
if( !state ) {
|
||||
setTestStatus( false );
|
||||
}
|
||||
checkBox.setEnabled( state );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,7 +90,7 @@ class MotorTestPanel extends JPanel implements ActionListener {
|
||||
*/
|
||||
public void setTestStatus( boolean enable ) {
|
||||
checkBox.setSelected( enable );
|
||||
controlOutput.setMotorsEnabled( enable );
|
||||
if( checkBox.isEnabled() ) controlOutput.setMotorsEnabled( enable );
|
||||
controlOutput.motorTesting = enable;
|
||||
if( !enable ) {
|
||||
masterSlider.setValue( 0 );
|
||||
@ -132,17 +132,18 @@ class MotorTestPanel extends JPanel implements ActionListener {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if( evt.getSource() == checkBox ) {
|
||||
else if( evt.getSource() == checkBox ) {
|
||||
setTestStatus( checkBox.isSelected() );
|
||||
return;
|
||||
}
|
||||
if( evt.getSource() == masterSlider ) {
|
||||
else if( evt.getSource() == masterSlider ) {
|
||||
slider0.setValue( Integer.parseInt( evt.getActionCommand() ) );
|
||||
slider1.setValue( Integer.parseInt( evt.getActionCommand() ) );
|
||||
slider2.setValue( Integer.parseInt( evt.getActionCommand() ) );
|
||||
slider3.setValue( Integer.parseInt( evt.getActionCommand() ) );
|
||||
}
|
||||
fireActionPerformed();
|
||||
|
||||
if( evt.getSource() != controlOutput ) fireActionPerformed();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user