PeterStaev / lego-spikeprime-mindstorms-vscode

Helps you connect and work with Lego's SPIKE Prime/MINDSTORMS Robot Inventor hubs
Apache License 2.0
62 stars 22 forks source link

Support for multiple file programs #66

Open JacobenVosloo opened 5 days ago

JacobenVosloo commented 5 days ago

Based on this PR https://github.com/PeterStaev/lego-spikeprime-mindstorms-vscode/pull/58

And the read me

Screenshot 2024-09-22 at 19 54 00

I would assume that splitting code into multiple files work

But based on my simple test it does not

Screenshot 2024-09-22 at 19 49 00

Can anyone please assist as to what am I doing wrong? @GreenGitHub99

I also tried changing the settings to precompiled mpy file

Screenshot 2024-09-22 at 19 55 56
PeterStaev commented 5 days ago

@JacobenVosloo , could you please provide the contents of the main.assembled.py file (it should be in the same folder as your main.py file)?

JacobenVosloo commented 5 days ago

@PeterStaev, thank you for the quick response.

The contents are the same as the main.py file.

# LEGO type:basic slot:0 autostart

# Use wildcard import for utilities
from utilities.py import *

# Now you can call battery_check directly
battery_check()

And the file is located in the same location as main.py and utilities.py

Screenshot 2024-09-23 at 07 35 29

PeterStaev commented 5 days ago

@JacobenVosloo I see your import in the assembled file looks different than the one in the main.py file - it hast the .py extension at the end of utilities. I think this is what causing the problems as the logic automatically adds the extension when it looks up the file to be assembled. Can you check and remove the extension so the import is:

from utilities import *
JacobenVosloo commented 3 days ago

@PeterStaev

I double-checked, and import is now as you suggested. But it is still not working. Here is a screenshot showing the whole setup and the resultant main. assembled.py file.

Screenshot 2024-09-25 at 07 25 58

I am working of a Mac, could this be the problem?

Is there perhaps some example file that I can use to test the setup on my side.

Thank you again for the support and a great library