Fixed listening for device setup changes

Former-commit-id: c1580486bb123fe6c457610225ca46f3063b94c4
This commit is contained in:
johan 2013-11-02 20:06:47 +01:00
parent e5395951a5
commit 8d8c4bdfad
5 changed files with 23 additions and 9 deletions

View File

@ -1 +1 @@
6f2aab422e3d1b03080de92c3e3aea9b270a3e9b 56543287f8f9c84993d0578339da66f81efe6bdb

View File

@ -21,6 +21,7 @@ public class LedString {
/** THe configuration of the 'physical' led frame */ /** THe configuration of the 'physical' led frame */
public LedFrameConstruction mLedFrameConfig = new LedFrameConstruction(); public LedFrameConstruction mLedFrameConfig = new LedFrameConstruction();
/** The configuration of the image processing */ /** The configuration of the image processing */
public ImageProcessConfig mProcessConfig = new ImageProcessConfig(); public ImageProcessConfig mProcessConfig = new ImageProcessConfig();

View File

@ -121,7 +121,7 @@ public class ConfigPanel extends JPanel {
mSpecificationPanel = new JPanel(); mSpecificationPanel = new JPanel();
mSpecificationPanel.setLayout(new BoxLayout(mSpecificationPanel, BoxLayout.Y_AXIS)); mSpecificationPanel.setLayout(new BoxLayout(mSpecificationPanel, BoxLayout.Y_AXIS));
mConstructionPanel = new LedFramePanel(ledString.mLedFrameConfig); mConstructionPanel = new LedFramePanel(ledString.mLedFrameConfig, ledString.mDeviceConfig);
mConstructionPanel.setBorder(BorderFactory.createTitledBorder("Construction")); mConstructionPanel.setBorder(BorderFactory.createTitledBorder("Construction"));
mSpecificationPanel.add(mConstructionPanel); mSpecificationPanel.add(mConstructionPanel);

View File

@ -12,12 +12,14 @@ import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import org.hyperion.hypercon.spec.DeviceConfig;
import org.hyperion.hypercon.spec.DeviceType; import org.hyperion.hypercon.spec.DeviceType;
import org.hyperion.hypercon.spec.LedFrameConstruction; import org.hyperion.hypercon.spec.LedFrameConstruction;
public class LedFramePanel extends JPanel { public class LedFramePanel extends JPanel {
private final LedFrameConstruction mLedFrameSpec; private final LedFrameConstruction mLedFrameSpec;
private final DeviceConfig mDeviceConfig;
private JLabel mTypeLabel; private JLabel mTypeLabel;
private JComboBox<DeviceType> mTypeCombo; private JComboBox<DeviceType> mTypeCombo;
@ -41,10 +43,11 @@ public class LedFramePanel extends JPanel {
private JLabel mOffsetLabel; private JLabel mOffsetLabel;
private JSpinner mOffsetSpinner; private JSpinner mOffsetSpinner;
public LedFramePanel(LedFrameConstruction ledFrameSpec) { public LedFramePanel(LedFrameConstruction ledFrameSpec, DeviceConfig deviceConfig) {
super(); super();
mLedFrameSpec = ledFrameSpec; mLedFrameSpec = ledFrameSpec;
mDeviceConfig = deviceConfig;
initialise(); initialise();
} }
@ -151,6 +154,10 @@ public class LedFramePanel extends JPanel {
} }
void updateLedConstruction() { void updateLedConstruction() {
mDeviceConfig.mType = (DeviceType) mTypeCombo.getSelectedItem();
mDeviceConfig.setChanged();
mDeviceConfig.notifyObservers();
mLedFrameSpec.topLeftCorner = (Boolean)mTopCornerCombo.getSelectedItem(); mLedFrameSpec.topLeftCorner = (Boolean)mTopCornerCombo.getSelectedItem();
mLedFrameSpec.topRightCorner = (Boolean)mTopCornerCombo.getSelectedItem(); mLedFrameSpec.topRightCorner = (Boolean)mTopCornerCombo.getSelectedItem();
mLedFrameSpec.bottomLeftCorner = (Boolean)mBottomCornerCombo.getSelectedItem(); mLedFrameSpec.bottomLeftCorner = (Boolean)mBottomCornerCombo.getSelectedItem();

View File

@ -1,20 +1,22 @@
package org.hyperion.hypercon.spec; package org.hyperion.hypercon.spec;
import java.util.Observable;
/** /**
* The device specific configuration * The device specific configuration
*/ */
public class DeviceConfig { public class DeviceConfig extends Observable {
/** The name of the device */ /** The name of the device */
String mName = "MyPi"; public String mName = "MyPi";
/** The type specification of the device */ /** The type specification of the device */
DeviceType mType = DeviceType.ws2801; public DeviceType mType = DeviceType.ws2801;
/** The device 'file' name */ /** The device 'file' name */
String mOutput = "/dev/spidev0.0"; public String mOutput = "/dev/spidev0.0";
/** The baudrate of the device */ /** The baudrate of the device */
int mBaudrate = 1000000; public int mBaudrate = 1000000;
/** Flag indicating if the red and blue should be reversed */ /** Flag indicating if the red and blue should be reversed */
boolean mBgrOutput = false; public boolean mBgrOutput = false;
/** /**
* Creates the JSON string of the configuration as used in the Hyperion daemon configfile * Creates the JSON string of the configuration as used in the Hyperion daemon configfile
@ -47,4 +49,8 @@ public class DeviceConfig {
return strBuf.toString(); return strBuf.toString();
} }
@Override
public void setChanged() {
super.setChanged();
}
} }