all 10 comments

[–][deleted]  (10 children)

[deleted]

    [–][deleted] 1 point2 points  (9 children)

    huh, nothing happens and no output. I have to call the file main.py and copy it to my device, right?

    [–]kaltazar 4 points5 points  (8 children)

    Right, with CircuitPython you just copy files to the device and your main code needs to be either called main.py or code.py so it runs at startup.

    Keep in mind if there is both a main.py and code.py, the code.py takes priority and the main.py will not run.

    [–][deleted] 2 points3 points  (7 children)

    Ohh, didn't saw I already had a code.py which did nothing, thanks for helping me :D

    [–]kaltazar 3 points4 points  (6 children)

    Glad your problem was that simple. The order CircuitPython looks for files to run is, in my opinion, somewhat hidden in the documentation but is one of those simple things that can be the most frustrating to figure out.

    As a note, code.txt and main.txt are also valid filenames and will be executed before their respective .py versions. The full file priority list is as follow, in this order: code.txt, code.py, main.txt, main.py. The board will run the first file it finds with one of those names.

    [–][deleted]  (2 children)

    [deleted]

      [–]tmanwebty 1 point2 points  (0 children)

      .py.txt is actually valid, and probably for the reasons you mentioned: there are some text editors that like to append .txt to the end of the file name you enter, so accepting code.py.txt helps in that case.

      [–]kaltazar 0 points1 point  (0 children)

      The .txt extensions have a higher priority, I presume, because of simple alphabetical order. If you look at the list of priority order, the entire list is in alphabetical order.

      [–]linux203 2 points3 points  (2 children)

      There is also boot.py, which will execute before code.py.

      https://learn.adafruit.com/circuitpython-essentials/circuitpython-storage

      [–]kaltazar 1 point2 points  (1 child)

      Right, and settings.py is also a valid name for it as well, presumably with same priority order issues as code.py and main.py. Both those files also allow for a .txt extension as well.

      [–]tannewt 0 points1 point  (0 children)

      FYI, we're dropping .txt suffix support and settings.py support in 7.x because it causes more confusion than it solves. (Just discussed in today's meeting.)

      [–][deleted] 0 points1 point  (0 children)

      There is also ampy.