aboutsummaryrefslogtreecommitdiffstats
path: root/System/system.py
diff options
context:
space:
mode:
authorRaspberry Pi <raspberrypi@umn.edu>2019-12-02 20:27:29 -0600
committerRaspberry Pi <raspberrypi@umn.edu>2019-12-02 20:27:29 -0600
commit0fe6f542246dd150b4793df18253ed6d4a443264 (patch)
tree254849abf6bb3be93bb67380d519363fbd957546 /System/system.py
parentMinor tweaks to PI.py to get working seamlessly with web server - tested and ... (diff)
downloadee4511w-0fe6f542246dd150b4793df18253ed6d4a443264.tar
ee4511w-0fe6f542246dd150b4793df18253ed6d4a443264.tar.gz
ee4511w-0fe6f542246dd150b4793df18253ed6d4a443264.tar.bz2
ee4511w-0fe6f542246dd150b4793df18253ed6d4a443264.tar.lz
ee4511w-0fe6f542246dd150b4793df18253ed6d4a443264.tar.xz
ee4511w-0fe6f542246dd150b4793df18253ed6d4a443264.tar.zst
ee4511w-0fe6f542246dd150b4793df18253ed6d4a443264.zip
Update test files to do GPIO cleanup on completion (ex: encoders don't work if GPIO.cleanup is not performed). Add system destructor and add GPIO.cleanup to that too. Everything appears to be working still.
Diffstat (limited to 'System/system.py')
-rwxr-xr-xSystem/system.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/System/system.py b/System/system.py
index 8dd9f38..7b2ffcf 100755
--- a/System/system.py
+++ b/System/system.py
@@ -20,7 +20,7 @@ encoder_data_pin = 3
### Angular encoder pins
encoder_angular_cs_pin = 4
### Linear encoder pins
-encoder_linear_cs_pin = 14
+encoder_linear_cs_pin = 14
### Limit switch pins (configured to PULLUP)
limit_negative_pin = 19
limit_positive_pin = 26
@@ -89,6 +89,13 @@ class System:
self.encoder_thread.start()
# END __init__()
+ # Destructor
+ # Brake the motor and call GPIO.cleanup as a last-chance of doing so
+ def __del__(self):
+ self.motor.brake()
+ GPIO.cleanup()
+ # END __del__()
+
def initialize(self):
# Temporarily disable the limit switch interrupts: we do not want the program to exit if the switch is triggered
GPIO.remove_event_detect(limit_negative_pin)