fixes some display components that don't handled high-z inputs correctly

This commit is contained in:
hneemann 2020-11-17 21:15:53 +01:00
parent 8ee40a3d49
commit e7dd999e3d
2 changed files with 12 additions and 4 deletions

View File

@ -71,7 +71,7 @@ public class ButtonLEDShape extends ButtonShape {
public void drawTo(Graphic graphic, Style heighLight) {
super.drawTo(graphic, heighLight);
boolean ledOn = ledValue == null || ledValue.getBool();
boolean ledOn = ledValue == null || (ledValue.getBool() & !ledValue.isHighZ());
boolean pressed = button != null && button.isPressed();
Vector center;

View File

@ -6,6 +6,7 @@
package de.neemann.digital.draw.shapes;
import de.neemann.digital.core.Bits;
import de.neemann.digital.core.ObservableValue;
import de.neemann.digital.core.element.ElementAttributes;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.core.element.PinDescriptions;
@ -67,13 +68,20 @@ public class RGBLEDShape implements Shape {
@Override
public void readObservableValues() {
if (ioState != null) {
long r = ioState.getInput(0).getValue() * 255 / max;
long g = ioState.getInput(1).getValue() * 255 / max;
long b = ioState.getInput(2).getValue() * 255 / max;
long r = getCol(ioState.getInput(0));
long g = getCol(ioState.getInput(1));
long b = getCol(ioState.getInput(2));
color = new Color((int) r, (int) g, (int) b);
}
}
long getCol(ObservableValue c) {
if (c.isHighZ())
return 0;
else
return c.getValue() * 255 / max;
}
@Override
public void drawTo(Graphic graphic, Style heighLight) {
if (color == null)