-->
Page 1 of 2

Why doesn't SMING have a loop() like Arduino IDE?

PostPosted: Wed Aug 26, 2015 1:54 am
by helpme
I understand one of SMING's goal is to be as friendly and similar as Arduino. Why doesn't SMING use a loop() like Arduino IDE? What is the best replacement for loop() in SMING?

Re: Why doesn't SMING have a loop() like Arduino IDE?

PostPosted: Wed Aug 26, 2015 1:24 pm
by hreintke
LS,
Sming is, contrary to Arduino code, based on a "callback paradigma". This means that the code is executed based on events which occur. If you want execution at regular intervals you can use the Timer class.

Re: Why doesn't SMING have a loop() like Arduino IDE?

PostPosted: Wed Aug 26, 2015 1:44 pm
by tavalin
Whilst I don't suggest it, you could probably implement your own Arduino style loop() yourself with a while loop and a function called loop. One of the issues with this, though, is that the watchdog timer isn't keen on these type of things and you may experience reboots if not done properly.

Re: Why doesn't SMING have a loop() like Arduino IDE?

PostPosted: Thu Aug 27, 2015 2:28 am
by GigAHerZ
When stuff works on callbacks, then from JS coding there was a way to call a function with timer and timer amount was 0 or 1. That resulted usually instant execution, but in case anything else was on hold in callback stack, then my function was in the end of callback stack.

Is there a one-liner in C/C++ & Sming to set timer for 0 time for any function to call? That would create "as fast as possible" loop cycle without killing all the wifi management and watchdog.