rotaryio not included with Trinket M0?

Adafruit's tiny microcontroller platform. Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
mike3d0g
 
Posts: 17
Joined: Mon Mar 30, 2015 3:33 pm

rotaryio not included with Trinket M0?

Post by mike3d0g »

How do I read a rotary encoder on with the Trinket M0? The docs make it look easy, but they use the rotaryio module as a built-in, and it's not loading for me.

Sample code:

Code: Select all

import rotaryio
import board

encoder = rotaryio.IncrementalEncoder(board.D10, board.D9)
last_position = None
while True:
    position = encoder.position
    if last_position is None or position != last_position:
        print(position)
    last_position = position
The Adafruit tutorial page says "CircuitPython 4.x and later come with rotaryio built in". https://learn.adafruit.com/rotary-encoder/circuitpython

And the CircuitPython docs page says it's supported on the Trinket MO.
https://docs.circuitpython.org/en/lates ... index.html

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: rotaryio not included with Trinket M0?

Post by dastels »

It should be included.
Adafruit Trinket M0

analogio, array, board, builtins, busio, collections, digitalio, math, microcontroller, neopixel_write, nvm, os, pwmio, rainbowio, random, rotaryio, rtc, storage, struct, supervisor, sys, time, touchio, usb_cdc, usb_hid, usb_midi
What exactly do you see in the REPL?

Dave

User avatar
mike3d0g
 
Posts: 17
Joined: Mon Mar 30, 2015 3:33 pm

Re: rotaryio not included with Trinket M0?

Post by mike3d0g »

Ooops, I should have included that.

Code: Select all

Adafruit CircuitPython 3.1.1 on 2018-11-02; Adafruit Trinket M0 with samd21e18
>>> import rotaryio
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'rotaryio'
I found this page of libraries, I think I need to install one. None are labeled for version 3, should I use the bundle named adafruit-circuitpython-bundle-py-20221014.zip?

https://github.com/adafruit/Adafruit_Ci ... e/releases

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: rotaryio not included with Trinket M0?

Post by dastels »

Oh.. that's an OLD version of CircuitPython... pre-rotario as I recall.

Get updated to CircuitPython 7.3.3.

Dave

User avatar
mike3d0g
 
Posts: 17
Joined: Mon Mar 30, 2015 3:33 pm

Re: rotaryio not included with Trinket M0?

Post by mike3d0g »

Ha! It's a new Trinket and it didn't even occur to me. I've been missing some of the newer Python language features. Thanks for the help!

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: rotaryio not included with Trinket M0?

Post by dastels »

No worries. The Trinket M0 was added to the shop some time ago. It's always a good idea to update things when you get them. You should update the bootloader while you're at it.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Trinket ATTiny, Trinket M0”