I didn't write this code (just made some modifications) but it was using a depreciated library so I'm trying to update to the official circuit python libraries and update everything for python3.
This is for a kiln controller that I've been using successfully for a year. It was using some deprecated libraries however, and recent updates broke things. It seems redundant import both RPi.GPIO and digitalio. Since the max31856 requires digitalio, I thought I'd convert the code to use that instead of RPi.GPIO. However, the code just doesn't seem as elegant. I'm wondering if I'm missing something or if I should just keep using Rpi.GPIO?
The HEAT = (23,24) is the the output pins to trigger the relays for the elements. This should be expandable because some kilns use more than 2 elements.
This is the original code
GPIO.setmode(GPIO.BCM)
HEAT = (23, 24)
for element in HEAT:
GPIO.setup(element, GPIO.OUT)
GPIO.output(element, GPIO.LOW)
And to turn the elements on and off
for element in HEAT:
GPIO.output(element, False)
and
for element in HEAT:
GPIO.output(element, True)
The code I'm comming up with is something like this
HEAT = (board.D23,board.D24)
for element in HEAT:
element = digitalio.DigitalInOut(element)
element.direction = digitalio.Direction.OUTPUT
element.value = False
I haven't actually tested this to make sure it's triggering both elements but it doesn't generate any errors when I run it.
Is there a better way to do this? I've tried running digitalio.DigitalInOut(element) with various combinations to avoid the board.D23 in the list but circuit python didn't like those.
Here is the entire code base. https://github.com/fayena/PILN
Suggestions?