Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Re-using variables from boot in main.

    Scheduled Pinned Locked Moved Comments & Feedback
    2 Posts 2 Posters 86 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N Offline
      NickBoots
      last edited by NickBoots

      Small question, if making a variable in boot, it seems they still exist when boot ends and main starts, in this case I want to check the battery voltage with pytrack (using a PyTrack daughter board) in boot to check if the voltage is high enough to start, and then when main runs, it'll also be checked. But, do I need to import pytrack and construct it in both, or indeed best to construct it once in boot, and then just call that variable in main again?

      Does this matter, are their up- and downsides to either way?

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @NickBoots
        last edited by

        @NickBoots boot.py and main.py share the same namespace. If you import pytrack in boot.py, you do not have to do that in main.py again. Actually that would be ignored.
        So either way is fine, but in your case does not matter much anyhow. boot.py and main.py are executed one after the other, with just a few ms time in between. So it is more a matter of software design than a difference in energy consumption.

        1 Reply Last reply Reply Quote 1

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • 1 / 1
        • First post
          Last post

        Pycom on Twitter

        Pycom