kbalage

Custom controls for up to 4 trains in the Powered Up app

Recommended Posts

I'm not a regular visitor of the train section here on Eurobricks but I think this might be interesting for you :) The Powered Up 3.0 app allows now to have multiple hubs connected, but it does not offer a convenient interface to control the connected trains the same time. I created two code variations in the Powered Up app with the following abilities using the slider control interface:

Simple interface

  • Control 2 trains with the 2 sliders
  • Control the lights of the 2 trains separately with 2 buttons
  • Stop button to stop all trains
  • Code can be customized to control more trains/motors with one slider, e.g. coupled trains

Advanced interface

  • Control 4 trains with the left slider
  • Switch between the trains with the right button (speed and light status of the trains is stored in the app)
  • Left number shows the speed of the current train, right number shows the train selected
  • Left button toggles the light of the currently selected train
  • Middle button stops the currently selected train

The code can be tweaked to control trains with multiple motors and it can be also used to control trains equipped with other type of Powered Up motors as well, or trains using the 4 port hub. 

Here's a video demonstration:

The pdf guide can be downloaded here.

Share this post


Link to post
Share on other sites

Nice.  I had modified that same controller screen to control one locomotive with 2 motors installed.  App 3.0 opens up  a lot of possibilities.   :classic:

 

Share this post


Link to post
Share on other sites

This is my approach as well, where each loco may have different profiles to be configured.

You could offer a zip file with the programm as download.

 

Edited by Lok24

Share this post


Link to post
Share on other sites
On 2/23/2020 at 10:12 AM, Lok24 said:

This is my approach as well, where each loco may have different profiles to be configured.

You could offer a zip file with the programm as download.

I usually create the Powered Up programs on my iPad as it is easier to navigate compared to my Android phone. I'd need to recreate the apps on the phone to share the files, and not many people are comfortable to tinker with app files on their devices. I think the pdf version for now is pretty straightforward to use and to recreate on any device. Hopefully LEGO will add a sharing function in the future to the app.

Share this post


Link to post
Share on other sites
9 hours ago, kbalage said:

 I think the pdf version for now is pretty straightforward to use and to recreate on any device.

I copuld not download because there are strange windows asking for eMail-Adress and buying something.

Each "program" is just some json-fiiles in one folder .

9 hours ago, kbalage said:

 Hopefully LEGO will add a sharing function in the future to the app.

Sharing is possible via LEGO LIFE.

 

Share this post


Link to post
Share on other sites
Just now, Lok24 said:

I copuld not download because there are strange windows asking for eMail-Adress and buying something.

Each "program" is just some json-fiiles in one folder .

Sharing is possible via LEGO LIFE.

 

That strange window is required as the download link is e-mailed to you, you don't need to buy anything. Unfortunately LEGO life sharing does not work yet in the Powered Up app, it is only available in the Boost app.

Share this post


Link to post
Share on other sites
Just now, kbalage said:

That strange window is required as the download link is e-mailed to you, you don't need to buy anything. Unfortunately LEGO life sharing does not work yet in the Powered Up app, it is only available in the Boost app.

That's why it is much easier to zip the folder ;-)

Share this post


Link to post
Share on other sites
Just now, Lok24 said:

That's why it is much easier to zip the folder ;-)

And you will have it blocked by a lot of systems (e.g. Gmail, some virus scanners) because it contains json files.. 

Share this post


Link to post
Share on other sites

How did you solve the problem of reconnecting to a hub?

This is what i'm urgently looking for, perhaps you have an idea?

Share this post


Link to post
Share on other sites

The program in this form relies on active connections, since the app can connect to 4 hubs simultaneously. When you switch between the hubs it stores the speed value in a variable and reads the value stored for the next one, same goes for the light status. 

 

Share this post


Link to post
Share on other sites

Thanks.

On exhibitions it is quite normal that you lose connetion to the engines because you are to far away.

That is why I use some python solutions there which automatically reconnect.

But I'm looking for a solution with my App-Prog, which is obviously very similar to yours, driving 1to 4 locos with multiple profiles each.  

Share this post


Link to post
Share on other sites

At the moment unfortunately there's no in-app solution to control the connections automatically. I just did a quick test, if one hub disconnects because it goes too far then you need to push the button on the hub and tap on the hub's name on the connection screen as well. The good news is that it does not affect the order of the hubs, so if number 1 disconnects then number 2-3-etc stays in the same slot. Once you reconnect number 1 it can pick up the speed stored for it previously.

Share this post


Link to post
Share on other sites

I think this is only because the option "connect automatically" ist buggy, especially if you have more than one hub.

Having only one sometimes it connects when turning on, in most cases yot have to tap on "connect" in the BT dialog , sometimes you only have to invke the BT dialog without tapping on "connect"

Share this post


Link to post
Share on other sites
10 hours ago, kbalage said:

And you will have it blocked by a lot of systems (e.g. Gmail, some virus scanners) because it contains json files.. 

Gmail isn't blocking json files (which are a plain text database) ... perhaps you're thinking of js (JavaScript) files?

BTW, thanks for including the pages with the popup explanations in the file, Balasz! Very very helpful!

Share this post


Link to post
Share on other sites
1 hour ago, izx said:

Gmail isn't blocking json files (which are a plain text database) ... perhaps you're thinking of js (JavaScript) files?

BTW, thanks for including the pages with the popup explanations in the file, Balasz! Very very helpful!

I'm not sure what is exactly blocked and what not, but when I tried to zip the folder on one Android device and e-mail it to the other one it did not work. That's the reason why I choose the pdf file with the comments, I think it is easier to use than trying to troubleshoot the file-copy paste on different Android devices and everyone can recreate the program on iOS devices as well. 

Share this post


Link to post
Share on other sites
2 hours ago, kbalage said:

I'm not sure what is exactly blocked and what not, but when I tried to zip the folder on one Android device and e-mail it to the other one it did not work. That's the reason why I choose the pdf file with the comments, I think it is easier to use than trying to troubleshoot the file-copy paste on different Android devices and everyone can recreate the program on iOS devices as well. 

Oh, of course! The PDF is the main thing. Hopefully LEGO introduces easier cross-platform sharing in a future update.

Share this post


Link to post
Share on other sites
On 2/25/2020 at 9:32 AM, kbalage said:

At the moment unfortunately there's no in-app solution to control the connections automatically. I just did a quick test, if one hub disconnects because it goes too far then you need to push the button on the hub and tap on the hub's name on the connection screen as well. The good news is that it does not affect the order of the hubs, so if number 1 disconnects then number 2-3-etc stays in the same slot. Once you reconnect number 1 it can pick up the speed stored for it previously.

Hi, i was trying to decipher your guide but i seem to be missing some of the Options in the App (The custom Controllers like sliders etc,) was there any change between the versions ? All manuals i find Refer to a lot of Custom Controllers and i am at a loss if i it wrong ?

Share this post


Link to post
Share on other sites
Just now, Jasseji said:

Hi, i was trying to decipher your guide but i seem to be missing some of the Options in the App (The custom Controllers like sliders etc,) was there any change between the versions ? All manuals i find Refer to a lot of Custom Controllers and i am at a loss if i it wrong ?

I created that guide before the custom controllers were introduced, it is using the stock 2-slider interface. With the customization it is much easier to create controls for multiple trains. I don't have the possibility to update the guide at the moment but I will do it when I'll have a chance.

Share this post


Link to post
Share on other sites
2 hours ago, kbalage said:

I created that guide before the custom controllers were introduced, it is using the stock 2-slider interface. With the customization it is much easier to create controls for multiple trains. I don't have the possibility to update the guide at the moment but I will do it when I'll have a chance.

i am sorry, it is my fault, i chose the "program" option when creating the project and there those blocks are not visible - my fault

Share this post


Link to post
Share on other sites
22 hours ago, kbalage said:

I created that guide before the custom controllers were introduced, it is using the stock 2-slider interface. With the customization it is much easier to create controls for multiple trains. I don't have the possibility to update the guide at the moment but I will do it when I'll have a chance.

i go the program to work correctly, i am trying to figure out now how to add the PU Controller, so i can control the trains via App AND controller at the same time - did you try this ever ? The dosumentation is not very clear from Lego side unfortunately...

Share this post


Link to post
Share on other sites

@Jasseji I don't think it is a wise choice to assign multiple controllers to the same motors the same time, what shall be the expected output if both are used? You can make a code to switch between them, although that one is not that simple either. A solution like this requires more knowledge about coding in general, it's not really specific to LEGO's implementation.

Share this post


Link to post
Share on other sites

The motor speed is in a variable.

You can change the value of that variable either via poweredUpApp  Controller  or via remote control.
I know some who use this or asked for.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.