Import of variables from boot.py
-
I'm not sure of the scope of boot.py from within main.py.
Can variables set up in boot.py be accessed from main.py?
Can for e.g. boot.py be used to connect to a wi-fi and set up bluetooth, and then those services used from within main.py to check connectivity, etc.
-
@PeterB I'm not using the pymakr plug-in, but form the discussion i recall, that there is an option to run safe boot before upload. Safe boot bypasses boot.py and main.py. In that case the objects defined in boot.py to not exist.
-
We found indeed the behaviour that instances created in boot.py also work in main.py without recreating the instances. That works e.g. if you use it standalone witout atom connected, but as soon as as atom is connected it starts to complain an instance which was created in boot.py does not exist in main.py when called.
Any idea why?
-
-
@robert-hh Hi .. I was woundering if you know how that would work? I want to have the bluetooth to run when i reset the lopy decive....
-
@robert-hh Brilliant. Thank you for that information.
-
@robert-hh About your question about WiFI and Bluetooth:
yes, you can set up wifi and bluetooth in Boot.py or main.py and use it then in other scripts. Boot.py and main.py are started by the firmware in the same context one after the other. Besides their names, there is no real difference in what you can do in the scripts. Only you can name in boot.py a different script which will be started instead of main.py.
-
That's how I would normally, but I've got to the stage where I've written quite a bit and the process of carving it up is a bit fraught.
I'm new to Python but there seems to be some rigour in the way things are done, with terms like 'Pythonic'. I guess I'm trying to adapt to external principals rather than just go about things my normal, hacky way.
I'll create a few small tests and go about discovering.
Thanks.
But in the meantime, I would appreciate knowing if there are any advanced uses of boot.py that anyone has tried.
-
@alidaf Why don't you just give it a try. Create a global symbol in boot.py and try to access it in main.py. Then you know.