Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions Script/doubleSwitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
ResetTrigger = False
isConfigReadNeed = True
cycleIndexPosMiddle = False
countComplete = False

lastButtonState = HIGH
debounceDelay = 5000
Expand Down Expand Up @@ -186,6 +187,7 @@ def doubleSwitchLoop(model: str):
global buttonState
global ResetTrigger
global lastDebounceTime
global countComplete

rtn = LOOP_RTN_TYPE_ERROR
switchModel = None
Expand All @@ -205,18 +207,21 @@ def doubleSwitchLoop(model: str):
# Reading the gpio pin for the switchs
if gpio.digitalRead(MICRO_SWITCH_S1_NC_PIN) and gpio.digitalRead(MICRO_SWITCH_S2_NO_PIN):
currentPosition = POSITION_LEFT
lcd.write("Position Left ", row = ROW_NO_2)
print("Position Left")
if not countComplete:
lcd.write("Position Left ", row = ROW_NO_2)

if gpio.digitalRead(MICRO_SWITCH_S1_NO_PIN) and gpio.digitalRead(MICRO_SWITCH_S2_NO_PIN):
currentPosition = POSITION_MIDDLE
lcd.write("Position Middle", row = ROW_NO_2)
print("Position Middle")
if not countComplete:
lcd.write("Position Middle", row = ROW_NO_2)

if gpio.digitalRead(MICRO_SWITCH_S1_NO_PIN) and gpio.digitalRead(MICRO_SWITCH_S2_NC_PIN):
currentPosition = POSITION_RIGHT
lcd.write("Position Right ", row = ROW_NO_2)
print("Position Right")
if not countComplete:
lcd.write("Position Right ", row = ROW_NO_2)

print("S1_NO:", gpio.digitalRead(MICRO_SWITCH_S1_NO_PIN), end="\t")
print("S1_NC:", gpio.digitalRead(MICRO_SWITCH_S1_NC_PIN), end="\t")
Expand Down Expand Up @@ -270,9 +275,10 @@ def doubleSwitchLoop(model: str):
gpio.digitalWrite(ON_BOARD_LED_PIN, HIGH)
gpio.digitalWrite(MOTOR_ON_OFF_PIN, LOW)
setMotorControlStatus(LOW)
lcd.write("Count Finished!", row = ROW_NO_3, padding = True)
lcd.write("Count Finished!", row = ROW_NO_2, padding = True)
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'Count Finished!' message is now displayed on ROW_NO_2, which conflicts with position status messages that are also displayed on ROW_NO_2. This will overwrite position information and could confuse users about the current state.

Suggested change
lcd.write("Count Finished!", row = ROW_NO_2, padding = True)
lcd.write("Count Finished!", row = ROW_NO_4, padding = True)

Copilot uses AI. Check for mistakes.
print("Count Finished!")
cycleCounter = 0
countComplete = True

# Reset button debounce logic
ResetBtnReading = gpio.digitalRead(RESET_PUSH_SWITCH_PIN)
Expand All @@ -298,10 +304,13 @@ def doubleSwitchLoop(model: str):
gpio.digitalWrite(ON_BOARD_LED_PIN, LOW)
setCycleCount(cycleCounter)
ResetTrigger = False
countComplete = False
time.sleep(2)
lcd.write(" "*LCD_MODULE_NO_OF_COLUMN, row = ROW_NO_3)
time.sleep(1)
printCountValue(row = ROW_NO_3, currentCount = cycleCounter, totalCount = TotalCounter)
gpio.digitalWrite(MOTOR_ON_OFF_PIN, HIGH)
setMotorControlStatus(HIGH)

# Return the loop status
return rtn, switchModel
Expand Down
14 changes: 7 additions & 7 deletions Script/pinDescription.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
MICRO_SWITCH_S2_NO_PIN = 33
MICRO_SWITCH_S2_NC_PIN = 35

POSITION_LEFT_LED_PIN = 11
POSITION_MIDDLE_LED_PIN = 13
POSITION_RIGHT_LED_PIN = 15
POSITION_LEFT_LED_PIN = 13
POSITION_MIDDLE_LED_PIN = 11
POSITION_RIGHT_LED_PIN = 7

RESET_PUSH_SWITCH_PIN = 37
RESET_PUSH_SWITCH_PIN = 38

MOTOR_ON_OFF_PIN = 32

ON_BOARD_LED_PIN = 36
ON_BOARD_LED_PIN = 15

GPIO_3V3_1_PIN = 38
GPIO_3V3_2_PIN = 40
GPIO_3V3_1_PIN = 36
GPIO_3V3_2_PIN = 37

LCD_MODULE_ADDRESS = 0x27
14 changes: 11 additions & 3 deletions Script/singleSwitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
ResetTrigger = False
isConfigReadNeed = True
cycleIndexPosMiddle = False
countComplete = False

lastButtonState = HIGH
debounceDelay = 5000
Expand Down Expand Up @@ -166,6 +167,7 @@ def singleSwitchLoop(model: str):
global buttonState
global ResetTrigger
global lastDebounceTime
global countComplete

rtn = LOOP_RTN_TYPE_ERROR
switchModel = None
Expand All @@ -184,13 +186,15 @@ def singleSwitchLoop(model: str):
# Reading the gpio pin for the switchs
if gpio.digitalRead(MICRO_SWITCH_S1_NC_PIN):
currentPosition = POSITION_LEFT
lcd.write("Position Left ", row = ROW_NO_2)
print("Position Left")
if not countComplete:
lcd.write("Position Left ", row = ROW_NO_2)

if gpio.digitalRead(MICRO_SWITCH_S1_NO_PIN):
currentPosition = POSITION_MIDDLE
lcd.write("Position Middle", row = ROW_NO_2)
print("Position Middle")
if not countComplete:
lcd.write("Position Middle", row = ROW_NO_2)

print("S1_NO:", gpio.digitalRead(MICRO_SWITCH_S1_NO_PIN), end="\t")
print("S1_NC:", gpio.digitalRead(MICRO_SWITCH_S1_NC_PIN))
Expand Down Expand Up @@ -236,9 +240,10 @@ def singleSwitchLoop(model: str):
gpio.digitalWrite(ON_BOARD_LED_PIN, HIGH)
gpio.digitalWrite(MOTOR_ON_OFF_PIN, LOW)
setMotorControlStatus(LOW)
lcd.write("Count Finished!", row = ROW_NO_3, padding = True)
lcd.write("Count Finished!", row = ROW_NO_2, padding = True)
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'Count Finished!' message is now displayed on ROW_NO_2, which conflicts with position status messages that are also displayed on ROW_NO_2. This will overwrite position information and could confuse users about the current state.

Suggested change
lcd.write("Count Finished!", row = ROW_NO_2, padding = True)
lcd.write("Count Finished!", row = ROW_NO_3, padding = True)

Copilot uses AI. Check for mistakes.
print("Count Finished!")
cycleCounter = 0
countComplete = True

# Reset button debounce logic
ResetBtnReading = gpio.digitalRead(RESET_PUSH_SWITCH_PIN)
Expand All @@ -264,10 +269,13 @@ def singleSwitchLoop(model: str):
gpio.digitalWrite(ON_BOARD_LED_PIN, LOW)
setCycleCount(cycleCounter)
ResetTrigger = False
countComplete = False
time.sleep(2)
lcd.write(" "*LCD_MODULE_NO_OF_COLUMN, row = ROW_NO_3)
time.sleep(1)
printCountValue(row = ROW_NO_3, currentCount = cycleCounter, totalCount = TotalCounter)
gpio.digitalWrite(MOTOR_ON_OFF_PIN, HIGH)
setMotorControlStatus(HIGH)

# Return the loop status
return rtn, switchModel
Expand Down
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
appVersion: 1.9.1.1017
appVersion: 1.9.2.1018
maxCount : 7500000