1

I have this code and it runs two times fine, while on third call I get an error, as if I would have passed Timestamp. I only ever pass Tuple or None.

from pprint import pprint
from gpiozero import RGBLED
def signal(pri, newcolor):
  signal.priority[pri] = newcolor
  pprint(signal.priority)
  try: signal.led.color = next(color for color in signal.priority if color is not None)
  except StopIteration: signal.led.color = (0,0,0)
signal.led = RGBLED(red=11, green=9, blue=10)
signal.priority = 2*[None]

Output is following

[None, (0, 1, 0)] 
[None, (0, 0, 1)]
[None, (1, 1, 0)]

Traceback (most recent call last):

File "/home/pi/zrcrasp.py", line 137, in <module>
    signal(1, (1,1,0))
File "/home/pi/zrcrasp.py", line 10, in signal
    try: signal.led.color = next(color for color in signal.priority if color is not None)
TypeError: 'Timestamp' object is not callable

Background

Function is used by various part of program to signal any kind of error, but if high priority short red blink ends, the lower priority green should continue. If there is no lower priority - None , then led will be turned off (this is the except statement for)

Lowest index is the highest priority.

Jakub M.
  • 321
  • 2
  • 7

0 Answers0