mirror of
https://github.com/brendanhaines/RasPi.git
synced 2024-11-09 16:44:40 -07: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.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();
|
out.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,9 @@ class GroundStation implements ActionListener {
|
||||||
/** connection options section of window */
|
/** connection options section of window */
|
||||||
private ConnectionPanel connectPanel;
|
private ConnectionPanel connectPanel;
|
||||||
|
|
||||||
|
/** flight controller arm/disarm button*/
|
||||||
|
private ArmButton arm;
|
||||||
|
|
||||||
/** tabbed pane to hold stuff */
|
/** tabbed pane to hold stuff */
|
||||||
private JTabbedPane tabbedPane;
|
private JTabbedPane tabbedPane;
|
||||||
/** motor testing panel */
|
/** motor testing panel */
|
||||||
|
@ -40,8 +43,9 @@ class GroundStation implements ActionListener {
|
||||||
connectPanel.setEnabled( true );
|
connectPanel.setEnabled( true );
|
||||||
mainWindow.getContentPane().add( connectPanel );
|
mainWindow.getContentPane().add( connectPanel );
|
||||||
|
|
||||||
JButton fcButton = new JButton( "arm" );
|
arm = new ArmButton( sendContent );
|
||||||
mainWindow.getContentPane().add( fcButton );
|
arm.setEnabled( false );
|
||||||
|
mainWindow.getContentPane().add( arm );
|
||||||
|
|
||||||
tabbedPane = new JTabbedPane();
|
tabbedPane = new JTabbedPane();
|
||||||
mainWindow.getContentPane().add( tabbedPane );
|
mainWindow.getContentPane().add( tabbedPane );
|
||||||
|
@ -67,11 +71,23 @@ class GroundStation implements ActionListener {
|
||||||
|
|
||||||
public void disableMotors() {
|
public void disableMotors() {
|
||||||
connectPanel.setEnabled( true );
|
connectPanel.setEnabled( true );
|
||||||
|
|
||||||
|
arm.setEnabled( true );
|
||||||
|
motorTestPanel.setEnabled( true );
|
||||||
|
|
||||||
eStopWindow.dispose();
|
eStopWindow.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableMotors() {
|
public void enableMotors() {
|
||||||
connectPanel.setEnabled( false );
|
connectPanel.setEnabled( false );
|
||||||
|
|
||||||
|
if( motorTestPanel.getTestStatus() ) {
|
||||||
|
arm.setEnabled( false );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
motorTestPanel.setEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
eStopWindow = new EStopWindow();
|
eStopWindow = new EStopWindow();
|
||||||
eStopWindow.addActionListener( this );
|
eStopWindow.addActionListener( this );
|
||||||
}
|
}
|
||||||
|
@ -79,15 +95,18 @@ class GroundStation implements ActionListener {
|
||||||
public void actionPerformed( ActionEvent evt ) {
|
public void actionPerformed( ActionEvent evt ) {
|
||||||
if( evt.getSource() == eStopWindow ) {
|
if( evt.getSource() == eStopWindow ) {
|
||||||
sendContent.setMotorsEnabled( false );
|
sendContent.setMotorsEnabled( false );
|
||||||
|
arm.setText( "Arm Flight Controller" );
|
||||||
}
|
}
|
||||||
if( evt.getSource() == connectPanel ) {
|
if( evt.getSource() == connectPanel ) {
|
||||||
if( evt.getActionCommand().equals( "CONNECT" ) ) {
|
if( evt.getActionCommand().equals( "CONNECT" ) ) {
|
||||||
mainWindow.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE );
|
mainWindow.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE );
|
||||||
motorTestPanel.setEnabled( true );
|
motorTestPanel.setEnabled( true );
|
||||||
|
arm.setEnabled( true );
|
||||||
}
|
}
|
||||||
else if( evt.getActionCommand().equals( "DISCONNECT" ) ) {
|
else if( evt.getActionCommand().equals( "DISCONNECT" ) ) {
|
||||||
mainWindow.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
|
mainWindow.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
|
||||||
motorTestPanel.setEnabled( false );
|
motorTestPanel.setEnabled( false );
|
||||||
|
arm.setEnabled( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( evt.getActionCommand().equals( "ENABLE_MOTORS" ) ) {
|
else if( evt.getActionCommand().equals( "ENABLE_MOTORS" ) ) {
|
||||||
|
|
|
@ -79,10 +79,10 @@ class MotorTestPanel extends JPanel implements ActionListener {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void setEnabled( boolean state ) {
|
public void setEnabled( boolean state ) {
|
||||||
|
checkBox.setEnabled( state );
|
||||||
if( !state ) {
|
if( !state ) {
|
||||||
setTestStatus( false );
|
setTestStatus( false );
|
||||||
}
|
}
|
||||||
checkBox.setEnabled( state );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +90,7 @@ class MotorTestPanel extends JPanel implements ActionListener {
|
||||||
*/
|
*/
|
||||||
public void setTestStatus( boolean enable ) {
|
public void setTestStatus( boolean enable ) {
|
||||||
checkBox.setSelected( enable );
|
checkBox.setSelected( enable );
|
||||||
controlOutput.setMotorsEnabled( enable );
|
if( checkBox.isEnabled() ) controlOutput.setMotorsEnabled( enable );
|
||||||
controlOutput.motorTesting = enable;
|
controlOutput.motorTesting = enable;
|
||||||
if( !enable ) {
|
if( !enable ) {
|
||||||
masterSlider.setValue( 0 );
|
masterSlider.setValue( 0 );
|
||||||
|
@ -132,17 +132,18 @@ class MotorTestPanel extends JPanel implements ActionListener {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if( evt.getSource() == checkBox ) {
|
else if( evt.getSource() == checkBox ) {
|
||||||
setTestStatus( checkBox.isSelected() );
|
setTestStatus( checkBox.isSelected() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if( evt.getSource() == masterSlider ) {
|
else if( evt.getSource() == masterSlider ) {
|
||||||
slider0.setValue( Integer.parseInt( evt.getActionCommand() ) );
|
slider0.setValue( Integer.parseInt( evt.getActionCommand() ) );
|
||||||
slider1.setValue( Integer.parseInt( evt.getActionCommand() ) );
|
slider1.setValue( Integer.parseInt( evt.getActionCommand() ) );
|
||||||
slider2.setValue( Integer.parseInt( evt.getActionCommand() ) );
|
slider2.setValue( Integer.parseInt( evt.getActionCommand() ) );
|
||||||
slider3.setValue( Integer.parseInt( evt.getActionCommand() ) );
|
slider3.setValue( Integer.parseInt( evt.getActionCommand() ) );
|
||||||
}
|
}
|
||||||
fireActionPerformed();
|
|
||||||
|
if( evt.getSource() != controlOutput ) fireActionPerformed();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue
Block a user