From d8141ca9d093391ccc6f5d9aab5937bb7b8670ab Mon Sep 17 00:00:00 2001 From: a838557765 <838557765@qq.com> Date: Mon, 4 Jan 2021 15:56:32 +0800 Subject: [PATCH] Update Fixed the problem of rpi_ws281x library and starting the server without interface --- Code/Server/servo.py | 13 +++++++++++-- Code/setup.py | 8 ++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Code/Server/servo.py b/Code/Server/servo.py index 8f16e6b..4990953 100644 --- a/Code/Server/servo.py +++ b/Code/Server/servo.py @@ -27,9 +27,18 @@ class Servo: # Main program logic follows: if __name__ == '__main__': + print("Now servos will rotate to 90°.") + print("If they have already been at 90°, nothing will be observed.") + print("Please keep the program running when installing the servos.") + print("After that, you can press ctrl-C to end the program.") pwm=Servo() - pwm.setServoPwm('0',90) - pwm.setServoPwm('1',90) + while True: + try : + pwm.setServoPwm('0',90) + pwm.setServoPwm('1',90) + except KeyboardInterrupt: + print ("\nEnd of program") + break diff --git a/Code/setup.py b/Code/setup.py index 7978f39..5f8d52a 100644 --- a/Code/setup.py +++ b/Code/setup.py @@ -9,14 +9,10 @@ for x in range(1,4): flag=flag | 0x01 break for x in range(1,4): - if os.system("sudo pip3 install rpi_ws281x") == 0: + if os.system("sudo apt-get install -y python3-dev python3-pyqt5 ") == 0: flag=flag | 0x02 break -for x in range(1,4): - if os.system("sudo apt-get install -y python3-dev python3-pyqt5 ") == 0: - flag=flag | 0x04 - break -if flag==0x07: +if flag==0x03: print("\nNow the installation is successful.") else: print ("\nSome libraries have not been installed yet. Please run 'sudo python setup.py' again")