mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-18 09:24:42 -04:00
allows an input shape to avoid the active low state; see #177
This commit is contained in:
parent
aaa5050e20
commit
2af7b15180
@ -395,6 +395,15 @@ public final class Keys {
|
||||
public static final Key<Boolean> IS_HIGH_Z
|
||||
= new Key<>("isHighZ", false).allowGroupEdit().setSecondary();
|
||||
|
||||
/**
|
||||
* flag to avoid active low at an input
|
||||
*/
|
||||
public static final Key<Boolean> AVOID_ACTIVE_LOW
|
||||
= new Key<>("avoidActiveLow", false)
|
||||
.setDependsOn(IS_HIGH_Z)
|
||||
.allowGroupEdit()
|
||||
.setSecondary();
|
||||
|
||||
/**
|
||||
* the description of an element
|
||||
*/
|
||||
|
@ -35,6 +35,7 @@ public class In implements Element {
|
||||
.addAttribute(Keys.LABEL)
|
||||
.addAttribute(Keys.INPUT_DEFAULT)
|
||||
.addAttribute(Keys.IS_HIGH_Z)
|
||||
.addAttribute(Keys.AVOID_ACTIVE_LOW)
|
||||
.addAttribute(Keys.DESCRIPTION)
|
||||
.addAttribute(Keys.INT_FORMAT)
|
||||
.addAttribute(Keys.PINNUMBER);
|
||||
|
@ -32,11 +32,12 @@ public class InputShape implements Shape {
|
||||
private final String label;
|
||||
private final PinDescriptions outputs;
|
||||
private final IntFormat format;
|
||||
private final boolean isHighZ;
|
||||
private final boolean avoidLow;
|
||||
private IOState ioState;
|
||||
private SingleValueDialog dialog;
|
||||
private Value value;
|
||||
private Value inValue;
|
||||
private final boolean isHighZ;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
@ -56,6 +57,8 @@ public class InputShape implements Shape {
|
||||
format = attr.get(Keys.INT_FORMAT);
|
||||
|
||||
isHighZ = attr.get(Keys.INPUT_DEFAULT).isHighZ() || attr.get(Keys.IS_HIGH_Z);
|
||||
|
||||
avoidLow = isHighZ && attr.get(Keys.AVOID_ACTIVE_LOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,8 +77,12 @@ public class InputShape implements Shape {
|
||||
if (value.getBits() == 1) {
|
||||
modelSync.access(() -> {
|
||||
if (isHighZ) {
|
||||
if (value.isHighZ()) value.setValue(0);
|
||||
else if (value.getValue() == 0) value.setValue(1);
|
||||
if (value.isHighZ()) {
|
||||
if (avoidLow)
|
||||
value.setValue(1);
|
||||
else
|
||||
value.setValue(0);
|
||||
} else if (value.getValue() == 0) value.setValue(1);
|
||||
else value.setToHighZ();
|
||||
} else
|
||||
value.setValue(1 - value.getValue());
|
||||
|
@ -993,6 +993,9 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
||||
<string name="key_isHighZ">Eingang kann hochohmig sein</string><!-- In, Splitter -->
|
||||
<string name="key_isHighZ_tt">Wenn gesetzt, ist ein hochohmiger Eingang erlaubt. Bei einem Eingangselement ist ein
|
||||
hochohmiger Eingang auch erlaubt, wenn der Vorgabewert auf hochohmig ("Z") gesetzt wird.</string>
|
||||
<string name="key_avoidActiveLow">Keine Ausgabe von Null.</string>
|
||||
<string name="key_avoidActiveLow_tt">Vermeidet die Ausgabe von Null. Ist vor allem beim Aufbau von Relaisschaltungen
|
||||
hilfreich. Kann nur aktiviert werden, wenn ein hochohmiger Ausgang erlaubt ist.</string>
|
||||
<string name="key_Description">Beschreibung</string><!-- Out, In, Text -->
|
||||
<string name="key_Description_tt">Eine kurze Beschreibung des Elementes.</string>
|
||||
<string name="key_Frequency">Frequenz/Hz</string><!-- Clock -->
|
||||
|
@ -988,6 +988,9 @@
|
||||
<string name="key_isHighZ">Is three-state input</string><!-- In, Splitter -->
|
||||
<string name="key_isHighZ_tt">If set the input is allowed to be in high-z state. At the input component this is
|
||||
also allowed if high-z ("Z") is set as the default value.</string>
|
||||
<string name="key_avoidActiveLow">No zero output.</string>
|
||||
<string name="key_avoidActiveLow_tt">Avoids zero output. This is especially helpful when setting up relay circuits.
|
||||
Can only be activated if a high-z output is allowed.</string>
|
||||
<string name="key_Description">Description</string><!-- Out, In, Text -->
|
||||
<string name="key_Description_tt">A short description of this element and its usage.</string>
|
||||
<string name="key_Frequency">Frequency/Hz</string><!-- Clock -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user