<led>.toggle as a timer callback broken?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
salimfadhley
Posts: 22
Joined: Thu Jun 19, 2014 10:18 pm

<led>.toggle as a timer callback broken?

Post by salimfadhley » Sat Jun 21, 2014 10:23 pm

Code: Select all

>>> tim4 = pyb.Timer(4)            
>>> tim4.init(freq=5)        
>>> led = pyb.LED(3)
>>> led
<LED 3>
>>> tim4
Timer(4, prescaler=511, period=32811, mode=0, div=0)
>>> tim4.callback(led.toggle)
Uncaught exception in Timer(4) interrupt handler
TypeError: 
>>>
Can anybody spot what might be going wrong here?

salimfadhley
Posts: 22
Joined: Thu Jun 19, 2014 10:18 pm

Re: <led>.toggle as a timer callback broken?

Post by salimfadhley » Sun Jun 22, 2014 10:39 pm

Actually this was my bug:

The callback requires a function which accepts a single argument. The callback function accepts none.

This really is a valid TypeError!

Post Reply