Threads in LC

JeeJeeStudio jeejeestudio at gmail.com
Fri Jan 1 11:20:21 EST 2021


Hi Rick,

thanks fo responding.

It's a Pi 3 model B+, should be fast enough for this simple task.

on clockWise
     -------------------------steps between pos and wait----------------
       repeat for sStp times --clockwise
                      Pi_gpio_output 20, 0 --dir
           Pi_gpio_output 21, 1 --step
           wait sSpd milliseconds with messages
           Pi_gpio_output 21, 0
           wait sSpd milliseconds with messages
     if the mouse is down
           then
              Pi_gpio_output 21, 0 --step
              set the label of me to "Start"
           exit repeat
        end if
     end repeat
end clockWise

The time between a 1 and a 0 on the output is 1ms. I can lower the speed 
and thus increase time, but that does not matter.

I think I tried it once with send in time, not a succes. So maybe i have 
to rewrite that with a different mindsetting. I don't have all stack 
with me at the moment.

The above piece is from an older stack, but the last is similar.

Also the wait shall not be the most convenient wait to handle this.

It also has of course an counterClockwise handler which is similar, but 
then output 20 is a 1.

it should run for so many steps, then wait a few seconds and then 
return. If there is one position. If there are more positions, it should 
go to those positions too with eqaul steps, then wait on each position, 
then return those same positions to the start.

It all works, but due to the single thread, moving the mouse, it 
interferes. So in fact LC is to heavy for a single thread. Guess we 
would win speed if we got multi-thread. Not just for Raspberry.

Then there is still max LC7.0 for Rasp, so a port to that should also be 
made.

Thanks.

Jerry

Op 31-12-2020 om 17:53 schreef Rick Harrison via use-livecode:
> Hi Jerry,
>
> What version of Raspberry PI are you using?
>
> If you are using an older version of Raspberry PI just replacing it
> with a newer version might be your best work around.  The older
> PI’s are pretty slow.  Have you looked into Banana PI for instance?
>
> While LC isn’t multi-threaded there may be a work around which
> could make it behave as though it was.  Have you tried Send in Time?
>
> How often are you telling your stepper motor to run?  Once in every
> 10 milliseconds or once in every 20 milliseconds etc?
>
> Good luck!
>
> Rick
>
>> On Dec 31, 2020, at 7:20 AM, JeeJeeStudio via use-livecode <use-livecode at lists.runrev.com> wrote:
>>
>> Hi,
>>
>>
>> is it possible to assign threads in LC and why not?
>>
>> In python you can assign threads, not that i needed that with python, but it is possible.
>>
>> I'm playing with a stepper motor (for a while now) on a raspberry and with python it runs so smooth, with lc it's a different story.
>>
>> It runs, but when moving the mouse, the motor is responding to that. This should not happen, but probably because LC is a bit more heavy in use and use only one thread for graphics and other things.
>>
>> If more threads could be use then most probably it would run smooth too.
>>
>>
>> Now working with simplGui to have a GUI, which is quite easy, and now trying to solve that gui actions also do what needs to be done. More work, less easy than lc, but slowly we are getting there.
>>
>> I'm not a fan of python.
>>
>> Long story short, are multiple threads possible in LC and/or when will that be implemented?
>>
>>
>> Thanks and Happy 2021!
>>
>> Jerry
>>
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list