gbz_power_monitor.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:GBZ-Power-Monitor_BG 作者: Camble 项目源码 文件源码
def powerSwitch(channel):
  #Checking for LED bounce for the duration of the Power Timeout
  for bounceSample in range(1, int(round(powerTimeout / sampleRate))):
    time.sleep(sampleRate)

    if GPIO.input(powerGPIO) is 0:
       break

  if bounceSample is int(round(powerTimeout / sampleRate)) - 1:
      #When the Power Switch is placed in the off position with no bounce for the duration of the Power Timeout, we immediately shutdown
      os.system("sudo shutdown -h now")
      try:
         sys.stdout.close()
      except:
         pass
      try:
         sys.stderr.close()
      except:
         pass

      sys.exit(0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号