Skip to content

Commit

Permalink
Minor checks
Browse files Browse the repository at this point in the history
  • Loading branch information
rinon13 committed Mar 13, 2023
1 parent 45dda22 commit 419b351
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions ArduinoFrontend/src/app/Libs/inputs/Potentiometer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class Potentiometer extends CircuitElement {

if (!this.areNodesConnectedProperly()) {
console.log("Nodes not connected properly");
window.toast("Potentiometer not connected properly.");
window.showToast("Potentiometer not connected properly.");
return;
}
const attr = this.elements[1].attr();
Expand Down Expand Up @@ -320,10 +320,20 @@ export class Potentiometer extends CircuitElement {
*/
areNodesConnectedProperly() {
if (this.nodes[0].isConnected() && this.nodes[1].isConnected() && this.nodes[2].isConnected()) {
this.isRheostat = false;
return true;
const leftNode = this.getRecArduinov2(this.nodes[0], 'Terminal 1');
const rightNode = this.getRecArduinov2(this.nodes[2], 'Terminal 2');
if (leftNode && rightNode) {
if (leftNode.label === 'GND' && rightNode.value > 0) {
this.isRheostat = false;
return true;
} else if (rightNode.label === 'GND' && leftNode.value > 0) {
this.isRheostat = false;
return true;
}
}
}
else if (this.nodes[0].isConnected() && this.nodes[1].isConnected()) {

if (this.nodes[0].isConnected() && this.nodes[1].isConnected()) {
this.isRheostat = true;
return true;
}
Expand All @@ -338,10 +348,9 @@ export class Potentiometer extends CircuitElement {
* ToDo: Function is hardcoded
* ToDo: Make it work for other components
*/
sendResistance(resistance : number) {
for (const led of this.connectedLEDs) {
console.log(led);
led.setVariableResistance(resistance);
sendResistance(resistance: number) {
for (const led of this.connectedLEDs) {
led.setVariableResistance(resistance);
}
}
/**
Expand Down

0 comments on commit 419b351

Please sign in to comment.