protected JMenuBar createMenuBar() { JMenuBar bar = new JMenuBar(); JMenu homeMenu = new JMenu("Homing"); bar.add(homeMenu); // adding the appropriate homing options for your endstop configuration for (AxisId axis : AxisId.values()) { Endstops endstops = machine.getDriver().getMachine().getEndstops(axis); if (endstops != null) { if (endstops.hasMin == true) homeMenu.add( makeHomeItem("Home " + axis.name() + " to minimum", EnumSet.of(axis), false)); if (endstops.hasMax == true) homeMenu.add(makeHomeItem("Home " + axis.name() + " to maximum", EnumSet.of(axis), true)); } } /* homeMenu.add(new JSeparator()); homeMenu.add(makeHomeItem("Home XY+",EnumSet.of(Axis.X,Axis.Y),true)); homeMenu.add(makeHomeItem("Home XY-",EnumSet.of(Axis.X,Axis.Y),false)); homeMenu.add(makeHomeItem("Home all+",EnumSet.allOf(Axis.class),true)); homeMenu.add(makeHomeItem("Home all-",EnumSet.allOf(Axis.class),false)); */ return bar; }
public RealtimePanel(MachineInterface machine2) { super("Real time control and tuning"); Image icon = Base.getImage("images/icon.gif", this); setIconImage(icon); machine = machine2; driver = machine.getDriver(); ((RealtimeControl) driver).enableRealtimeControl(true); // create all our GUI interfaces JPanel speedPanel = new JPanel(); JPanel extrusionPanel = new JPanel(); add(new JLabel("Build speed (during extrusion)")); // Speed feedrateControl = new ControlSlider("Feedrate", "%", 5, 800, 100, speedPanel); // feedrateControl.getSlider().setMajorTickSpacing(10); Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>(); labelTable.put(new Integer(10), new JLabel("Slow")); labelTable.put(new Integer(100), new JLabel("")); labelTable.put(new Integer(300), new JLabel("Fast")); labelTable.put(new Integer(500), new JLabel("Insane!")); feedrateControl.slider.setLabelTable(labelTable); // add(new JLabel("Travel feedrate (no extrusion"),"growx,wrap"); travelFeedrateControl = new ControlSlider("Travel feedrate", "%", 5, 800, 100, speedPanel); travelFeedrateControl.slider.setLabelTable(labelTable); // Extrusion extrusionPanel.add(new JLabel("Extrusion"), "growx,wrap"); extrusionControl = new ControlSlider("Material muliplier", "%", 5, 500, 100, extrusionPanel); // TODO: extrusion scaling is not implemented in the driver yet. extrusionControl.slider.setEnabled(false); extrusionControl.field.setEnabled(false); mainPanel = new JPanel(); mainPanel.setLayout(new MigLayout()); mainPanel.add(speedPanel, "flowy,wrap"); mainPanel.add(extrusionPanel, "flowy,wrap"); new SpeedLimit(mainPanel); // Show comms debug checkbox JCheckBox showCommsDebug = new JCheckBox("Show communications"); if (((RealtimeControl) driver).getDebugLevel() >= 2) showCommsDebug.setSelected(true); showCommsDebug.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (((JCheckBox) e.getSource()).isSelected()) { ((RealtimeControl) driver).setDebugLevel(2); } else { ((RealtimeControl) driver).setDebugLevel(1); } } }); mainPanel.add(showCommsDebug, "flowy,wrap"); add(mainPanel); }
public void run() { // we'll break on interrupts try { while (true) { machine.runCommand(new replicatorg.drivers.commands.UpdateManualControl()); // driver.readTemperature(); Thread.sleep(700); // update every .7 s } } catch (InterruptedException e) { } }
private ControlPanelWindow(MachineInterface newMachine) { super("Control Panel"); Image icon = Base.getImage("images/icon.gif", this); setIconImage(icon); // save our machine! machine = newMachine; machine.runCommand(new InvalidatePosition()); // Listen to it-- stop and close if we're in build mode. Base.getMachineLoader().addMachineListener(this); // default behavior setDefaultCloseOperation(DISPOSE_ON_CLOSE); // no menu bar. setJMenuBar(createMenuBar()); chooser = new JColorChooser(Color.BLACK); ActionListener okListener = new ActionListener() { public void actionPerformed(ActionEvent e) { Color ledColor = chooser.getColor(); Base.logger.severe("running setLedStrip"); try { machine.getDriver().setLedStrip(ledColor, 0); } catch (replicatorg.drivers.RetryException f) { Base.logger.severe("foo" + f.toString()); } // machine.runCommand(new SetLedStrip(ledColor, 0)); ledStripButton.setText(ShowColorChooserAction.buttonStringFromColor(ledColor)); } }; ledStripButton = new JButton(new ShowColorChooserAction(this, chooser, okListener, null, Color.BLACK)); // create all our GUI interfaces mainPanel = new JPanel(); mainPanel.setLayout(new MigLayout("gap 5, ins 5, flowy")); jogPanel = new JogPanel(machine); mainPanel.add(jogPanel, "split 4, growx, growy"); mainPanel.add(createActivationPanel(), "split, growx"); if (newMachine.getMachineType() == MachineType.THE_REPLICATOR) { mainPanel.add(ledStripButton, "growx"); // mainPanel.add(createBeepPanel(), "growx"); } mainPanel.add(alternateToolsPanel(), "newline, growy"); this.setResizable(false); add(mainPanel); // add our listener hooks. addWindowListener(this); // addWindowFocusListener(this); // addWindowStateListener(this); // start our various threads. updateThread = new UpdateThread(this); updateThread.start(); pollThread = new PollThread(machine); pollThread.start(); }