Browse Source

GUI fixes

Rounding errors and degree sign fixed.
Tankernn 8 years ago
parent
commit
3d7767a934

+ 3 - 6
src/eu/tankernn/grid/Fan.java

@@ -35,8 +35,7 @@ public class Fan {
 	 * data is then converted to a double
 	 */
 	private void pollAMP() {
-		// 0x85 = -123
-		current = pollValue((byte) 0x85, (a, b) -> (double) a + b / 100);
+		current = pollValue((byte) 0x85, (a, b) -> a + (double) b / 100);
 	}
 
 	/**
@@ -45,7 +44,6 @@ public class Fan {
 	 * then converted to an int
 	 */
 	private void pollRPM() {
-		// 0x8A = -118
 		rpm = pollValue((byte) 0x8A, (a, b) -> (double) ((a << 8) | b)).intValue();
 	}
 
@@ -55,8 +53,7 @@ public class Fan {
 	 * converted to a double
 	 */
 	private void pollVoltage() {
-		// 0x84 = -124
-		voltage = pollValue((byte) 0x84, (a, b) -> (double) a + b / 100);
+		voltage = pollValue((byte) 0x84, (a, b) -> a + (double) b / 100);
 	}
 
 	private Double pollValue(byte commandByte, BiFunction<Integer, Integer, Double> resultConsumer) {
@@ -85,7 +82,7 @@ public class Fan {
 		if (newSpeed == speed)
 			return;
 		// Spin up to 100 during first tick after being turned off
-		if (speed == 0)
+		else if (speed == 0)
 			newSpeed = 100;
 		if (grid.getCommunicator().isConnected()) {
 			int firstByte, lastByte, wantedVoltage = 0;

+ 2 - 2
src/eu/tankernn/grid/frame/FanPanel.java

@@ -27,12 +27,12 @@ public class FanPanel extends JPanel {
 	private JComboBox<FanSpeedProfile> profileBox = new JComboBox<>();
 
 	public FanPanel(Fan fan, List<FanSpeedProfile> profiles) {
+		this.fan = fan;
 		for (FanSpeedProfile p : profiles)
 			profileBox.addItem(p);
-		this.fan = fan;
+		profileBox.setSelectedItem(fan.getProfile());
 
 		this.setBorder(new TitledBorder("Fan " + (fan.getIndex() + 1)));
-
 		this.setLayout(new GridLayout(4, 1));
 
 		this.add(voltageLabel);

+ 9 - 6
src/eu/tankernn/grid/frame/GridControlPanel.java

@@ -98,8 +98,11 @@ public class GridControlPanel extends JFrame {
 			gridPanel.add(p);
 
 		this.add(gridPanel, BorderLayout.CENTER);
-
+		
+		minSpeed.setValue(model.getMinSpeed());
 		minSpeed.addChangeListener(this::setMinRPM);
+		
+		pollingSpeed.setValue(control.getPollingSpeed());
 		pollingSpeed.addChangeListener(e -> {
 			control.setPollingSpeed((int) pollingSpeed.getValue());
 		});
@@ -156,12 +159,12 @@ public class GridControlPanel extends JFrame {
 	 */
 	public void updateProperties() {
 		DecimalFormat df = new DecimalFormat("#.##");
-
-		CPULabel.setText("CPU: " + df.format(getModel().getSensor().getCPUTemp()) + " C");
+		// \u00B0 = "Degree sign"
+		CPULabel.setText("CPU: " + df.format(getModel().getSensor().getCPUTemp()) + " \u00B0C");
 		PowerLabel.setText("Total power: " + df.format(getModel().getGrid().getTotalWattage()) + " W");
-		CPULabelMax.setText("CPU: " + df.format(getModel().getSensor().getCpuMax()) + " C Max");
-		GPULabel.setText("GPU: " + df.format(getModel().getSensor().getGPUTemp()) + " C");
-		GPULabelMax.setText("GPU: " + df.format(getModel().getSensor().getGpuMax()) + " C Max");
+		CPULabelMax.setText("CPU: " + df.format(getModel().getSensor().getCpuMax()) + " \u00B0C Max");
+		GPULabel.setText("GPU: " + df.format(getModel().getSensor().getGPUTemp()) + " \u00B0C");
+		GPULabelMax.setText("GPU: " + df.format(getModel().getSensor().getGpuMax()) + " \u00B0C Max");
 
 		for (FanPanel p : fanPanels)
 			p.update();