目前我有一个使用Raspberry Pi Python语言的项目使用传感器打开和关闭显示器。
如何在python语言的初始状态下将显示器设置为睡眠模式?
# Calculate pulse length
elapsed = stop-start
# Distance pulse travelled in that time is time
# multiplied by the speed of sound (cm/s)
distance = elapsed * 34000
# That was the distance there and back so halve the value
distance = distance / 2
print "Distance : %.1f" % distance
if(distance > 30):
time.sleep(3)
subprocess.call("sudo /opt/vc/bin/tvservice -o",shell=True)
os.system('clear')
if(distance <= 30):
subprocess.call("sudo /opt/vc/bin/tvservice -p",shell=True)
# Reset GPIO settings
GPIO.cleanup()
这是我的代码的一部分,但我想将屏幕设置为初始状态。