Sample code for intelino-trainlib - the synchronous intelino train library.
Download this repository as a zip file through the github download link, or you can clone it with:
git clone https://github.com/intelino-code/intelino-trainlib-py-examples.git
cd intelino-trainlib-py-examplesCheck the installed Python version. The intelino trainlib requires Python 3.7 or higher.
python --versionIf the python executable version is 2.7 (common on macOS), you might try
running python3 --version to see if you have Python 3 installed.
If that works, we suggest either setting up a local environment
(which would link python to python3 once activated) or just use
python3 instead of python in all commands related to trainlib.
[optional] To create and activate a local environment, use:
python -m venv .envor alternatively
python3 -m venv .envActivate the local python environment
-
Linux and macOS
source .env/bin/activate -
Windows Command Prompt (
cmd).env\Scripts\activate.bat
To install the intelino train library, run:
python -m pip install intelino-trainlibFor a more detailed installation guide, see our quick start guide.
To verify that everything is installed correctly and works, you can turn on Bluetooth on your device, turn on your intelino smart train and scan for it with Python.
python -m intelino.scanIf you don't see your train in the list or you run into some issues, more details can be found in our documentation.
Open the intelino-trainlib-py-examples directory in your favorite editor.
You will find all examples under the examples directory. You can read them
and run as:
- Linux and macOS
python ./examples/01_get_train_info.py
- Windows
python .\examples\01_get_train_info.py
They always have some descriptive name and at the beginning of each example you will find more description in three sections: topics, required setup (track layout) and notes about the program.
Happy coding...