How to read_timed (loboris library)

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
ckoever
Posts: 2
Joined: Wed Jul 08, 2020 5:53 pm

How to read_timed (loboris library)

Post by ckoever » Wed Jul 08, 2020 6:28 pm

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!

User avatar
jimmo
Posts: 1769
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: How to read_timed (loboris library)

Post by jimmo » Mon Jul 27, 2020 5:32 am

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

Post Reply