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
19 changes: 14 additions & 5 deletions Script/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def startIntroPrint():
time.sleep(1)


# This is the gpio initlization
def gpioInilitization():
# This is the gpio initialization
def gpioInitialization():
gpio.pinMode(ON_BOARD_LED_PIN, OUTPUT)
gpio.pinMode(GPIO_3V3_1_PIN, OUTPUT)
gpio.pinMode(GPIO_3V3_2_PIN, OUTPUT)
Expand All @@ -65,6 +65,8 @@ def gpioInilitization():
gpio.pinMode(POSITION_MIDDLE_LED_PIN, OUTPUT)
gpio.pinMode(POSITION_LEFT_LED_PIN, OUTPUT)

gpio.pinMode(MOTOR_ON_OFF_PIN, OUTPUT)

gpio.pinMode(RESET_PUSH_SWITCH_PIN, INPUT)

gpio.digitalWrite(GPIO_3V3_1_PIN, HIGH)
Expand All @@ -74,6 +76,8 @@ def gpioInilitization():
gpio.digitalWrite(POSITION_MIDDLE_LED_PIN, LOW)
gpio.digitalWrite(POSITION_LEFT_LED_PIN, LOW)

gpio.digitalWrite(MOTOR_ON_OFF_PIN, LOW)


# Time print function
def printCurrentTime(row: int):
Expand Down Expand Up @@ -118,10 +122,10 @@ def setup():

startIntroPrint()
print("Intro print done!")
gpioInilitization()
print("GPIO initilization done!")
gpioInitialization()
print("GPIO initialization done!")
createRtDbFile()
print("Dabase creation done!")
print("Database creation done!")

lcd.write("Model: Type-D", row = ROW_NO_1, center = True)

Expand Down Expand Up @@ -187,6 +191,7 @@ def loop():
global lastDebounceTime

while True:
gpio.digitalWrite(MOTOR_ON_OFF_PIN, HIGH)
Comment on lines 193 to +194
Copy link

Copilot AI Aug 10, 2025

Choose a reason for hiding this comment

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

The motor is being turned on every iteration of the main loop. This could cause unnecessary GPIO writes and potential motor wear. Consider moving this outside the loop or adding a state check to only turn on the motor when needed.

Suggested change
while True:
gpio.digitalWrite(MOTOR_ON_OFF_PIN, HIGH)
motor_is_on = False
while True:
if not motor_is_on:
gpio.digitalWrite(MOTOR_ON_OFF_PIN, HIGH)
motor_is_on = True

Copilot uses AI. Check for mistakes.
printCurrentTime(ROW_NO_0)

#################################################
Expand Down Expand Up @@ -253,6 +258,9 @@ def loop():
# If reach the full count number then turn on the Finish LED
if cycleCounter >= TotalCounter:
gpio.digitalWrite(ON_BOARD_LED_PIN, HIGH)
gpio.digitalWrite(MOTOR_ON_OFF_PIN, LOW)
lcd.write("Count Finished!", row = ROW_NO_3, padding = True)
print("Count Finished!")
cycleCounter = 0

# Reset button debounce logic
Expand All @@ -273,6 +281,7 @@ def loop():

# If reset button pressed then clean the old stuffs
if ResetTrigger:
gpio.digitalWrite(MOTOR_ON_OFF_PIN, LOW)
cycleCounter = 0
gpio.digitalWrite(ON_BOARD_LED_PIN, LOW)
setCycleCount(cycleCounter)
Expand Down
4 changes: 3 additions & 1 deletion Script/pinDescription.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

RESET_PUSH_SWITCH_PIN = 37

MOTOR_ON_OFF_PIN = 32

ON_BOARD_LED_PIN = 36

GPIO_3V3_1_PIN = 38
GPIO_3V3_2_PIN = 40

LCD_MODULE_ADDRESS = 0x27
LCD_MODULE_ADDRESS = 0x27
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
appVersion: 1.7.4.1014
appVersion: 1.8.0.1015
maxCount : 7500000