Re-using variables from boot in main.
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-hh 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.