Cosmik42

Control all your Powered Up & Power Function (SBrick) devices with a single software

Recommended Posts

If I unstand it correct, we can write small c# code which is executed as a result of different sensor messages. Does the C# interpreter (?) allow loops like for oder do while and branches like if else or case and local variables?

Share this post


Link to post
Share on other sites
Posted (edited)

Hi Cosmik42 ,

thanks for your quick answer!

But: where can I find the "new" version?

And, I'm very sorry, more questions:

What does  a syntax for RampMotorSpeed(Port, 1000,1000) mean? (I assume Port,v,time)

And what about others motor types, which can be moved by a specific angle, like Boost or WeDo?

(but perhaps they pop up when I attach one)

 

 

Edited by Lok24

Share this post


Link to post
Share on other sites
Posted (edited)
44 minutes ago, Giottist said:

If I unstand it correct, we can write small c# code which is executed as a result of different sensor messages. Does the C# interpreter (?) allow loops like for oder do while and branches like if else or case and local variables?

Yes, I just tried (part of your question):

untitled2er.png

Edited by Lok24

Share this post


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

Yes, I just tried (part of your question):

Thank you, Lok24 for this info! (sorry, the "@Lok24" thingy does currently not work on my laptop)

 

I need to catch my breath. My goodness - this is so incredibly cool. I have never seen such a nice piece of software for original LEGO stuff control before.

For free.

With free and swift support from an extremely skilled C# programmer.

With the chance of asking for additional features.

And now this: Building your own chunks of code … 

Unbelievable. TLG should give Cosmik42 all the LEGO BLE devices currently available for free …

Again: Thanks a million Cosmik42, for doing all this for us!!!

All the best,
Thorsten 

Share this post


Link to post
Share on other sites
19 hours ago, Cosmik42 said:

@TheLarry98, insteresting. I just made a debug version for you:

Can you download it, run it and let me know if the hub shows up?

It now works. Thank you very much!

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, Lok24 said:

But: where can I find the "new" version?

The V0.3 link at the top of this thread.
Here it is again: https://www.dropbox.com/sh/g32wsw502jwv6oj/AAC0EycS7kgCIluhtVmKt1k3a?dl=1

1 hour ago, Lok24 said:

RampMotorSpeed(Port, 1000,1000)

It should be RampMotorSpeed(Port, Speed, Time), so it will look like this: RampMotorSpeed("A", 70, 1000) where 1000 is in millisecond and is the total time of acceleration/decelaration.

Edited by Cosmik42

Share this post


Link to post
Share on other sites

@Cosmik42 pardon if it's been asked/answered somewhere in this thread - is the source available /is it going to be open sourced?

Share this post


Link to post
Share on other sites
44 minutes ago, Lok24 said:

Yes, I just tried (part of your question):

untitled2er.png

BTW - You can write "MainBoard.WriteLine("...."); to log in the program's console.

9 minutes ago, Bartosz said:

@Cosmik42 pardon if it's been asked/answered somewhere in this thread - is the source available /is it going to be open sourced?

For now there's no clear plan on releasing the source officially, mostly because it is a side project and the code is really ugly :D

41 minutes ago, Toastie said:

Again: Thanks a million Cosmik42, for doing all this for us!!!

Thank you @Toastie!

Share this post


Link to post
Share on other sites
12 minutes ago, Cosmik42 said:

For now there's no clear plan on releasing the source officially, mostly because it is a side project and the code is really ugly :D

Some people would agonize over making it pretty/portable and never get to anything, whereas others would "just do it" :)

I guess just take care of releasing it before you get bored/go MIA (as it, unfortunately, often happens ;) ). My myself I do not own any PU hub yet, so I don't have any real interest in this software, but - just in case (and since I'm programmer as well:) )

Share this post


Link to post
Share on other sites
5 minutes ago, Bartosz said:

I guess just take care of releasing it before you get bored/go MIA (as it, unfortunately, often happens ;)

Oh yes. This is probably how it is - everywhere. I am not a programmer, I do sort of independent research - in ion chemistry. Sometimes people get very excited about what my group does … I am/we are getting excited about that reaction as well … and then … after weeks, months … maybe even years … something else catches your attention … and you are carried away … without publishing anything.

I guess it is what you meant, isn't it?

All the very best,
Thorsten 

Share this post


Link to post
Share on other sites

Hi ,

thats's great.

I now spend some time with your program, and there are some small issues that are not quite clear to me, would you discussed it here or via private message ?

Share this post


Link to post
Share on other sites
8 minutes ago, Lok24 said:

I now spend some time with your program, and there are some small issues that are not quite clear to me, would you discussed it here or via private message ?

Absolutely!

I just created a separate post with a clear example and a link to the very latest version:

 

Share this post


Link to post
Share on other sites

So, happy to report we officially support PU lights. Just received a set today and plugged it up for a short test!

 

Share this post


Link to post
Share on other sites

Wow. I have a working prototype of controlling motor and lights on a SBrick! 

The only thing weird is that SBrick abruptly disconnect with me randomly. Did anyone here implement the SBrick protocol?

Edited by Cosmik42

Share this post


Link to post
Share on other sites

SBrick has long history of abrupt "disconnections". The developers struggle to develop a Android App capable to sustain a stable a connection with SBrick. When you try to use three of them it is virtually impossible to maintain a connection with all simultaneously.

Share this post


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

SBrick has long history of abrupt "disconnections". The developers struggle to develop a Android App capable to sustain a stable a connection with SBrick. When you try to use three of them it is virtually impossible to maintain a connection with all simultaneously.

Do I need to update the firmware of the SBrick itself?

Share this post


Link to post
Share on other sites

Yes, should use the latest firmware! Not guaranteed it will improve your experience though...

Share this post


Link to post
Share on other sites

I confirm. Firmware update fixed the issue! We are just few hours away from officially supporting SBrick!

 

Share this post


Link to post
Share on other sites

I love this project.
I have some SBricks and a couple of Powered Up's. Now I can use them all together and don't have to update all my trains.

I also have a tilt sensor and a distance sensor compatible with the SBrick. Let's see if this works :)

Where can I donate?

Share this post


Link to post
Share on other sites

Hi Mawe! Thanks for the kind words. I still need to release this SBrick support. Hopefully tonight, if not tomorrow.

I don't own an SBrick Plus yet. So I don't support sensor from SBrick just yet. But as soon as I can find a device it will be done!

Thanks for following my work. Hope it is helpful to you!

Share this post


Link to post
Share on other sites
On 1/8/2019 at 7:06 PM, Giottist said:

Does the C# interpreter (?) allow loops like for oder do while and branches like if else or case and local variables?

Sorry @Giottist, I totally missed your post. Yes indeed! You can in fact use everything C# has to offer since the code is fully compiled and executed on demand. This a powerful tool to write complex behaviors and scripts!

Share this post


Link to post
Share on other sites

Cosmik42, love this software.  I’ve got a couple of trains running successfully, now just need more PUPs.....

i noticed the software picks up the remotes, any plans to be able to use inputs from these to trigger events?

i.e. press a button on the remote and it executes the code, or just be able to control the trains with the remote.

 

Share this post


Link to post
Share on other sites

 

1 hour ago, Cosmik42 said:

@GiottistYou can in fact use everything C# has to offer since the code is fully compiled and executed on demand. This a powerful tool to write complex behaviors and scripts!

Cool. My idea is to introduce the SerialPort class into my C# code enabling the communication with the Arduino world. It can be useful to save limited BT channels for the moving trains and let Arduino controllers serve the switch motors and readout fixed sensors besides the rails. Hmm, promising :grin:

At the moment I am somewhat busy but this is real motivation to get experience with C# code in the train software. Let me a little time.

 

Share this post


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

 

Cool. My idea is to introduce the SerialPort class into my C# code enabling the communication with the Arduino world. It can be useful to save limited BT channels for the moving trains and let Arduino controllers serve the switch motors and readout fixed sensors besides the rails. Hmm, promising :grin:

At the moment I am somewhat busy but this is real motivation to get experience with C# code in the train software. Let me a little time.

 

That would be amazing!

45 minutes ago, Tlego said:

i noticed the software picks up the remotes, any plans to be able to use inputs from these to trigger events?

i.e. press a button on the remote and it executes the code, or just be able to control the trains with the remote.

It's a great idea! I add this to the TODO :)

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   1 member