Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Feather M0 Express!
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Feather M0 Express!

by KyleMohr on Sat Jul 15, 2017 8:58 am

Thanks tannewt2.

I tried erasing the SPI flash per dhalbert's instructions twice with no success. Still doing the same after I flash and reload everything, still no response or output.

Using the built in Mac Terminal.

KyleMohr
 
Posts: 17
Joined: Wed Jul 29, 2015 11:49 am

Re: Feather M0 Express!

by dhalbert on Sat Jul 15, 2017 9:53 am

Doing this on the Mac will avoid any Eject issues, so keep doing that.

1. What command are you using to connect to the board via the Terminal?
2. Rename main.py to mainx.py so it doesn't run on startup.Then go into the REPL (>>>) and start typing in the program by hand, one line at a time, to see if you get any errors.
3. What editor are you using to edit main.py? Are you editing it directly on CIRCUITPY, or are you copying it?
4. Do:
Code: Select all | TOGGLE FULL SIZE
>>> import uos
>>> uos.stat("mainx.py")

The seventh number will be the size of the file. It should be about 1640 bytes (based on the code you pasted above).

dhalbert
 
Posts: 401
Joined: Tue Feb 17, 2015 6:18 pm

Re: Feather M0 Express!

by KyleMohr on Sun Jul 16, 2017 12:27 am

Thanks dhalbert.

1. What command are you using to connect to the board via the Terminal?
ls /dev/tty.*
then
screen /dev/tty.usbmodem*


2. Rename main.py to mainx.py so it doesn't run on startup.Then go into the REPL (>>>) and start typing in the program by hand, one line at a time, to see if you get any errors.
once I put in the following it caused the board to crash and reset (see screenshot below).
Code: Select all | TOGGLE FULL SIZE
            # turn off the LED


Screen Shot 2017-07-16 at 12.20.14 AM.png
Screen Shot 2017-07-16 at 12.20.14 AM.png (45.5 KiB) Viewed 456 times


3. What editor are you using to edit main.py? Are you editing it directly on CIRCUITPY, or are you copying it?
Mac app "TextEditor". Done both, edit and save to desktop then copy, and edit directly on CIRCUITPY, neither seem to make any difference.

4. Do:
CODE: SELECT ALL | TOGGLE FULL SIZE
>>> import uos
>>> uos.stat("mainx.py")

The seventh number will be the size of the file. It should be about 1640 bytes (based on the code you pasted above).

Did this and received the following:
Code: Select all | TOGGLE FULL SIZE
Adafruit CircuitPython 1.0.0-rc.4 on 2017-07-07; Adafruit Feather M0 Express with samd21g18
>>> import uos
>>> uos.stat("mainx.py")
(32768, 0, 0, 0, 0, 0, 1967, 553393086, 553393086, 553393086)
>>>

KyleMohr
 
Posts: 17
Joined: Wed Jul 29, 2015 11:49 am

Re: Feather M0 Express!

by dhalbert on Sun Jul 16, 2017 12:38 pm

Thanks for all the information. A few more questions:

1. The size you give for mainx.py is 1967 bytes. This is larger by a couple of hundred bytes than either the original tutorial code or your modified version posted above. And the difference is too much to be explained by differences in line endings (\n vs \r\n). Did you add any extra code that's not posted here?

2. Do you have any other M0 boards, even a non-Express board like a Feather M0 basic or Adalogger? You can load CircuitPython on one of those using bossac. A tiny CIRCUITPY drive is available, big enough for adafruit_hid. I tried this myself and got the tutorial example to run.

I'm thinking there's a hardware problem on the M0 Express board, maybe with the microcontroller, given the odd errors you've seen. If you can test the code on another board and it works, then that would point further to hardware. If it has problems in the same way, then there's something wrong with the setup.

Maybe post a picture of the board that shows it clearly along with its connections (or disconnected, if that's how it is now), just in case there's any issue with connections or damage.

dhalbert
 
Posts: 401
Joined: Tue Feb 17, 2015 6:18 pm

Re: Feather M0 Express!

by KyleMohr on Sun Jul 16, 2017 4:45 pm

Thanks again for the help!

1. The size you give for mainx.py is 1967 bytes. This is larger by a couple of hundred bytes than either the original tutorial code or your modified version posted above. And the difference is too much to be explained by differences in line endings (\n vs \r\n). Did you add any extra code that's not posted here?
No extra code added, just went line by line as suggested, when I got to that line is when it crashed.

2. Do you have any other M0 boards, even a non-Express board like a Feather M0 basic or Adalogger? You can load CircuitPython on one of those using bossac. A tiny CIRCUITPY drive is available, big enough for adafruit_hid. I tried this myself and got the tutorial example to run.
Unfortunately, no. This is my first using an adafruit board and only one I have on hand. Seemed easy enough compared to my past work with Teensy and Arduino.

I'm thinking there's a hardware problem on the M0 Express board, maybe with the microcontroller, given the odd errors you've seen. If you can test the code on another board and it works, then that would point further to hardware. If it has problems in the same way, then there's something wrong with the setup.
Agreed, I believe it has to be the board. I've used soldered and un-soldered (jumper wire test) and neither had any results, so that ruled out connection. It seems like a simple enough project and I'm copying the tutorial code so it really seems like there isn't issues there.

Maybe post a picture of the board that shows it clearly along with its connections (or disconnected, if that's how it is now), just in case there's any issue with connections or damage.
Will post pictures shortly.

KyleMohr
 
Posts: 17
Joined: Wed Jul 29, 2015 11:49 am

Re: Feather M0 Express!

by KyleMohr on Sun Jul 16, 2017 9:36 pm

Pictures of board below.

FullSizeRender.jpg
FullSizeRender.jpg (134.6 KiB) Viewed 431 times


IMG_3968.JPG
IMG_3968.JPG (128.95 KiB) Viewed 431 times


IMG_3970.JPG
IMG_3970.JPG (101.65 KiB) Viewed 431 times

KyleMohr
 
Posts: 17
Joined: Wed Jul 29, 2015 11:49 am

Re: Feather M0 Express!

by tannewt on Sun Jul 16, 2017 11:01 pm

Hi Kyle,
Thank you for all of your thorough responses on this. Tomorrow I'll look into getting you another board. I'm not sure exactly what the process is.

I have an idea on how we can improve safe mode to actually tell us where it crashed but don't have anything handy for it. I added an issue for it here: https://github.com/adafruit/circuitpython/issues/170

Thanks,
Scott

tannewt
 
Posts: 1845
Joined: Thu Oct 06, 2016 8:48 pm

Re: Feather M0 Express!

by KyleMohr on Sun Jul 16, 2017 11:20 pm

Thanks Scott! Appreciate it. I'll keep an eye out for the details and provide any extra info needed in order to get it sent out.

Thanks again,
Kyle

KyleMohr
 
Posts: 17
Joined: Wed Jul 29, 2015 11:49 am

Re: Feather M0 Express!

by tannewt on Mon Jul 17, 2017 2:17 pm

Hi Kyle,
Please email support@adafruit.com for details on getting a replacement. Link them to this thread and say Scott suggested you receive a replacement.

I'd love to give you a special debug build in the future and hopefully solve the bug. But for now, we shouldn't hold you up. So, hold onto the other one for when I have brain space to get you a debug build.
Thanks!
Scott

tannewt
 
Posts: 1845
Joined: Thu Oct 06, 2016 8:48 pm

Re: Feather M0 Express!

by KyleMohr on Mon Jul 17, 2017 3:20 pm

Thanks Scott!! Appreciate it.
I'll message them now and be sure to keep the old board on hand.

Let me know when you come up with the debug build.

Thanks,
Kyle

KyleMohr
 
Posts: 17
Joined: Wed Jul 29, 2015 11:49 am

Re: Feather M0 Express!

by tannewt on Mon Jul 17, 2017 5:53 pm

Sounds good! Thanks!

tannewt
 
Posts: 1845
Joined: Thu Oct 06, 2016 8:48 pm

Re: Feather M0 Express!

by KyleMohr on Thu Jul 20, 2017 12:56 am

Well...I just got the replacement board today.
Load the latest UF2, then the HID folder, everything working great, green led.
Then... I load the main.py and the green and blue flashing returns, with no response.
I even used the stock (unchanged) code from the tutorial, and it still flashes with no output.

I did the jumper wire test and get no response other than when you connect GND and pin 9, it makes CHD light rapidly flash.
IMG_3999.JPG
IMG_3999.JPG (99.62 KiB) Viewed 356 times


Has to be some issue with the code and this board...Has anyone else done this project with success?

At a loss here, maybe someone can offer a completely new code to try?
Code: Select all | TOGGLE FULL SIZE
import digitalio
from board import *
import time
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode

# A simple neat keyboard demo in circuitpython

# The button pins we'll use, each will have an internal pullup
buttonpins = [D12, D11, D10, D9, D6, D5]
ledpins = [A0, A1, A2, A3, A4, A5]

# The keycode sent for each button, will be paired with a control key
buttonkeys = [Keycode.A, Keycode.B, Keycode.C, Keycode.D, Keycode.E, Keycode.F]
controlkey = Keycode.LEFT_CONTROL

# the keyboard object!
kbd = Keyboard()
# our array of button objects
buttons = []
leds = []

# make all pin objects, make them inputs w/pullups
for pin in buttonpins:
    button = digitalio.DigitalInOut(pin)
    button.direction = digitalio.Direction.INPUT
    button.pull = digitalio.Pull.UP   
    buttons.append(button)
for pin in ledpins:
    led = digitalio.DigitalInOut(pin)
    led.direction = digitalio.Direction.OUTPUT
    leds.append(led)

led = digitalio.DigitalInOut(D13)
led.switch_to_output()
 
print("Waiting for button presses")

while True:
    # check each button
    for button in buttons:
        if (not button.value):   # pressed?
            i = buttons.index(button)
            leds[i].value = True
           
            print("Button #%d Pressed" % i)

            # turn on the LED
            led.value = True

            while (not button.value):
                pass  # wait for it to be released!
            # type the keycode!
            k = buttonkeys[i]    # get the corresp. keycode
            kbd.press(controlkey, k)
            kbd.release_all()

            # turn off the LED
            led.value = False
            leds[i].value = False
   
    time.sleep(0.01)


Thanks,
Kyle

KyleMohr
 
Posts: 17
Joined: Wed Jul 29, 2015 11:49 am

Re: Feather M0 Express!

by KyleMohr on Thu Jul 20, 2017 1:19 am

FIGURED IT OUT!!!

Originally pasted code into mac TextEdit and saved, then converted to main.py, some reason even though I converted it still held some .rtf values.

So when I put into MS Word, then saved as a .txt and converted to .py it showed up as a arduino icon, dragged to CIRCUITPY and now works perfectly!!

Thanks again for all the help.

-Kyle

KyleMohr
 
Posts: 17
Joined: Wed Jul 29, 2015 11:49 am

Re: Feather M0 Express!

by tannewt on Thu Jul 20, 2017 9:54 am

I'm glad you figured it out KyleMohr! Thanks for following up!

I'll see if I can reproduce it myself and perhaps add a more helpful error message in CircuitPython. I added an issue here: https://github.com/adafruit/circuitpython/issues/171

Have fun with your Feathers!

tannewt
 
Posts: 1845
Joined: Thu Oct 06, 2016 8:48 pm

Re: Feather M0 Express!

by KyleMohr on Fri Jul 21, 2017 11:55 am

Quick question to the code (now that its working!), how can I alter this to be a button push vs a button release.
Causing quite a delay when using for music software or video games, because it only triggers the key press when button released.

Please advise!!

As always thanks for the help!

Code: Select all | TOGGLE FULL SIZE
import digitalio
from board import *
import time
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode

# A simple neat keyboard demo in circuitpython

# The button pins we'll use, each will have an internal pullup
buttonpins = [D12, D11, D10, D9, D6, D5]
ledpins = [A0, A1, A2, A3, A4, A5]

# The keycode sent for each button, will be paired with a control key
buttonkeys = [Keycode.A, Keycode.B, Keycode.C, Keycode.D, Keycode.E, Keycode.F]
controlkey = Keycode.LEFT_CONTROL

# the keyboard object!
kbd = Keyboard()
# our array of button objects
buttons = []
leds = []

# make all pin objects, make them inputs w/pullups
for pin in buttonpins:
    button = digitalio.DigitalInOut(pin)
    button.direction = digitalio.Direction.INPUT
    button.pull = digitalio.Pull.UP   
    buttons.append(button)
for pin in ledpins:
    led = digitalio.DigitalInOut(pin)
    led.direction = digitalio.Direction.OUTPUT
    leds.append(led)

led = digitalio.DigitalInOut(D13)
led.switch_to_output()
 
print("Waiting for button presses")

while True:
    # check each button
    for button in buttons:
        if (not button.value):   # pressed?
            i = buttons.index(button)
            leds[i].value = True
           
            print("Button #%d Pressed" % i)

            # turn on the LED
            led.value = True

            while (not button.value):
                pass  # wait for it to be released!
            # type the keycode!
            k = buttonkeys[i]    # get the corresp. keycode
            kbd.press(controlkey, k)
            kbd.release_all()

            # turn off the LED
            led.value = False
            leds[i].value = False
   
    time.sleep(0.01)

KyleMohr
 
Posts: 17
Joined: Wed Jul 29, 2015 11:49 am

Please be positive and constructive with your questions and comments.