Page 1 of 1

How to read_timed (loboris library)

Posted: Wed Jul 08, 2020 6:28 pm
by ckoever
I would like to read a joystick using the read_timed method. (https://github.com/loboris/MicroPython_ ... o/wiki/adc)

If I do the following ...

Code: Select all

>>> a = []
>>> x = machine.ADC (machine.Pin (36))
>>> x.read_timed (data = a, freq = 5000)
... I get this error:

Code: Select all

Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
ValueError: array or file name argument expected
Unfortunately I have no idea how to change the "type" of a list. It should be "H" / "h" or "B".
(I tried "bytearray" but it didn't work.)

I would like to do this to save a timer on the ESP32 (I think I can do it like this or not?).

If there is a better method, please.
Thanks in advance!

Re: How to read_timed (loboris library)

Posted: Mon Jul 27, 2020 5:32 am
by jimmo
ckoever wrote:
Wed Jul 08, 2020 6:28 pm
Unfortunately I have no idea how to change the "type" of a list. It should be "H" / "h" or "B".
(I tried "bytearray" but it didn't work.)

I would like to do this to save a timer on the ESP32 (I think I can do it like this or not?).
I don't know much about the loboris port, but this suggests that maybe you need to use an array rather than a list -- see http://docs.micropython.org/en/latest/l ... array.html