Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GPIOzero Newbe Question
#1
If I may be so bold to ask is the following code is proper GIOzero code?

import RPi.GPIO as GPIO
from tkinter import *
from tkinter import _setit
from time import sleep
from functools import partial
from threading import Thread
from GPIOzero import InputDevice, OutputDevice, LED, LEDBoard



#=== Set GPIO Pins ===

run_pin                = OutputDevice(23)
busy_pin              = InputDevice(17)
push_button_pin    = InputDevice(37)
buzzer_pin            = OutputDevice(16)
abort_pin              = OutputDevice(18)
dir_pin                  = OutputDevice(24)
pwr_led_pin           = LED(20)
ready_led_pin        = LED(21)
intensitySelect_pins = LEDBoard(1, 7, 8, 25)
toy_sel_pins          = LEDBoard(14,15)

def Run_Task():
	
# First start the LED flashing thread
#	Stop_LED_Flashing = False
#	Ready_LED_Flashing = Thread(Set_Ready_LED_Flashing)
#	Ready_LED_Flashing.daemon = True
#	Ready_LED_Flashing.start()

# Debug Statement
	print("Run_Task Telling controller to excute task")

# Tell controler to excute the task
	run_pin.on()

#Debug Statement
	print(" Run Pin >> " , run_pin.value())
	print(" Busy_Pin True", Busy_Pin,value())

# Wait until stepper controler has started the task
#	while(GPIO,input(not Busy_Pin) :
	while( not Busy_Pin.value()):

#Debug Statement
		print("Waiting Busy Pin >> false")		
		sleep(1) #Wait 1 mS to allow logic controler time to respond 
		
# Now wait until stepper controler has finish the task

#Debug Statment
	print(" Waiting for Busy_Pin to return to false", GPIO,input(Busy_Pin) )	
#	while(GPIO,input(Busy_Pin) == True):
	while(Busy_Pin.value()):
#Debug Statement
		print("Waiting Busy Pin >> True")	
		sleep(1)
		
# Control has finshed so return Run pin to false to telling the controller the PI has 	
#	GPIO.output(Run_Pin, False)	
#	GPIO.output(Abort_Pin, False)
#	Stop_LED_Flashing = True

# Debug Statement
	print("Controller comleted task >> Retuning")
	
#**********************************************
Any an all suggestions are welcome. Big Grin Big Grin
Thank you for sharing your wisdom
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  gpiozero button turn off LED that is already on duckredbeard 3 882 Dec-11-2024, 06:23 PM
Last Post: duckredbeard

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020