Skip to content

Commit

Permalink
Added two DPDT ON/ON/ON variations to 'Mini Toggle Switch' component
Browse files Browse the repository at this point in the history
  • Loading branch information
bancika committed Aug 27, 2022
1 parent f549871 commit f2dc63e
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 6 deletions.
8 changes: 8 additions & 0 deletions diylc/diylc-core/src/org/diylc/presenter/update.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3894,6 +3894,14 @@
<releaseDate>2022-07-09 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added 'Voltage Source' symbol. Thank you, JD!</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added two DPDT ON/ON/ON variations to 'Mini Toggle Switch' component</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>The app crashes if there's a component that is reduced to 0 pixels with 'Cache Boost' enabled</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ private void updateControlPoints() {
new Point2D.Double(firstPoint.getX(), firstPoint.getY() + 2 * spacing)};
break;
case DPDT:
case DPDT_off:
case DPDT_off:
case DPDT_ononon_1:
case DPDT_ononon_2:
controlPoints =
new Point2D[] {firstPoint, new Point2D.Double(firstPoint.getX(), firstPoint.getY() + spacing),
new Point2D.Double(firstPoint.getX(), firstPoint.getY() + 2 * spacing),
Expand Down Expand Up @@ -336,7 +338,9 @@ public Shape getBody() {
* spacing, margin, margin);
break;
case DPDT:
case DPDT_off:
case DPDT_off:
case DPDT_ononon_1:
case DPDT_ononon_2:
body =
new RoundRectangle2D.Double(firstPoint.getX() - margin, firstPoint.getY() - margin, 2 * margin + spacing, 2
* margin + 2 * spacing, margin, margin);
Expand Down Expand Up @@ -441,13 +445,15 @@ public int getPositionCount() {
case _3PDT_off:
case _4PDT_off:
case _5PDT_off:
case DPDT_ononon_1:
case DPDT_ononon_2:
return 3;
}
return 2;
}

@Override
public String getPositionName(int position) {
public String getPositionName(int position) {
if (switchType.name().endsWith("_off") && position == 2)
return "OFF";
return "ON" + Integer.toString(position + 1);
Expand All @@ -463,15 +469,35 @@ public boolean arePointsConnected(int index1, int index2, int position) {
case _3PDT:
case _4PDT:
case _5PDT:
return (index2 - index1) < 3 && index1 % 3 == position && index2 % 3 == position + 1;
return (index2 - index1) < 3 && index1 % 3 == position && index2 % 3 == position + 1;
case SPDT_off:
case DPDT_off:
case _3PDT_off:
case _4PDT_off:
case _5PDT_off:
return position != 2 && (index2 - index1) < 3 && index1 % 3 == position && index2 % 3 == position + 1;
case _DP3T_mustang:
return (index2 - index1) < 3 && index1 % 3 == 0 && index2 % 3 == position + 1;
return (index2 - index1) < 3 && index1 % 3 == 0 && index2 % 3 == position + 1;
case DPDT_ononon_1:
switch (position) {
case 0:
return (index1 == 0 && index2 == 1) || (index1 == 3 && index2 == 4);
case 1:
return (index1 == 0 && index2 == 1) || (index1 == 4 && index2 == 5);
case 2:
return (index1 == 1 && index2 == 2) || (index1 == 4 && index2 == 5);
default: return false;
}
case DPDT_ononon_2:
switch (position) {
case 0:
return (index1 == 0 && index2 == 1) || (index1 == 3 && index2 == 4);
case 1:
return (index1 == 1 && index2 == 2) || (index1 == 3 && index2 == 4);
case 2:
return (index1 == 1 && index2 == 2) || (index1 == 4 && index2 == 5);
default: return false;
}
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ DIY Layout Creator (DIYLC).

public enum ToggleSwitchType {

SPST, SPDT, DPDT, _DP3T_mustang, _3PDT, _4PDT, _5PDT, SPDT_off, DPDT_off, _3PDT_off, _4PDT_off, _5PDT_off;
SPST, SPDT, DPDT, _DP3T_mustang, _3PDT, _4PDT, _5PDT, SPDT_off, DPDT_off, _3PDT_off, _4PDT_off, _5PDT_off, DPDT_ononon_1, DPDT_ononon_2;

@Override
public String toString() {
Expand All @@ -33,6 +33,8 @@ public String toString() {
name = name.replace("_", " ");
name = name.replace("mustang", "");
name = name.replace("off", " (Center OFF)");
name = name.replace("ononon_1", " On/On/On (Type 1)");
name = name.replace("ononon_2", " On/On/On (Type 2)");
return name;
}
}
18 changes: 18 additions & 0 deletions diylc/diylc-library/test/org/diylc/netlist/SwitchTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.Arrays;
import org.diylc.components.electromechanical.MiniToggleSwitch;
import org.diylc.components.electromechanical.SlideSwitch;
import org.diylc.components.electromechanical.SlideSwitchType;
import org.diylc.components.electromechanical.ToggleSwitchType;
import org.diylc.components.guitar.LPSwitch;
import org.diylc.components.guitar.LeverSwitch;
import org.diylc.components.guitar.LeverSwitch.LeverSwitchType;
Expand Down Expand Up @@ -66,6 +68,22 @@ public void testSlideSwitchDP3T() {
String[] validCombinations = new String[] {"0,0,2", "0,1,3", "1,2,4", "1,3,5", "2,4,6", "2,5,7"};
testSwitch(slideSwitch, validCombinations);
}

@Test
public void testMiniToggleSwitchDPDTononon1() {
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
toggleSwitch.setValue(ToggleSwitchType.DPDT_ononon_1);
String[] validCombinations = new String[] {"0,0,1", "0,3,4", "1,0,1", "1,4,5", "2,1,2", "2,4,5"};
testSwitch(toggleSwitch, validCombinations);
}

@Test
public void testMiniToggleSwitchDPDTononon2() {
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
toggleSwitch.setValue(ToggleSwitchType.DPDT_ononon_2);
String[] validCombinations = new String[] {"0,0,1", "0,3,4", "1,1,2", "1,3,4", "2,1,2", "2,4,5"};
testSwitch(toggleSwitch, validCombinations);
}

private void testSwitch(ISwitch sw, String[] validCombinations) {
Arrays.sort(validCombinations);
Expand Down
3 changes: 3 additions & 0 deletions diylc/diylc-swing/dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
5PDT
5PDT (Center OFF)
A-O-I REGULATOR
AC
AWG
And
B-C-E BJT
Expand All @@ -31,6 +32,7 @@ D-G-S JFET
D-G-S MOSFET
D-S-G JFET
D-S-G MOSFET
DC
DFM A
DFM B
DIP
Expand Down Expand Up @@ -81,6 +83,7 @@ SMD
SPDT
SPDT (Center OFF)
SPST
SourceType
Srpski
Xnor
Xor
Expand Down

0 comments on commit f2dc63e

Please sign in to comment.