Page 1 of 1

Input sequence macro

Posted: Fri Jun 08, 2018 11:30 pm
by NopeU
I'm trying to program a specific input sequence to be played when I run the python script however I couldn't figure out how to not get errors no matter what I tried. I don't really have a base in python syntax maybe that's why.
Anyway what I'm trying to achieve is something like this

Code: Select all

axis = 0
wait 100 ms
axis = 0.25
wait 100 ms
axis = 0.5
wait 100 ms
axis = 0.75
wait 100 ms
axis = 1
I am trying to figure how to put the cpu thread to sleep for exactly 100 ms before it executes the next instruction, after some research I found sleep(time), however I'm still getting error messages in FreePIE. I'm certain that this kind of script is not complex to make...

Can the experts here help me by providing me a sort of template for that kind of script so I can use it for my needs?

Thank you guys

Re: Input sequence macro

Posted: Sat Jun 09, 2018 9:09 am
by Jabberwock
You have to import time library to use sleep, like that:

Code: Select all

import time

axis = 0
time.sleep(100)
axis = 0.25
time.sleep(100)
axis = 0.5
time.sleep(100)
axis = 0.75
time.sleep(100)
axis = 1
However, if I understand it correctly, this is not optimal way to time things. You might have a look here:

https://github.com/AndersMalmgren/FreePIE/issues/69

Re: Input sequence macro

Posted: Sat Jun 09, 2018 4:31 pm
by NopeU
Thank you that was very helpful.
I made huge progress thanks to you.
I needed a template because I had to accurately execute around 10,000 instructions and the delay between instructions is between 0 ms to 1,5 seconds. I don't think I need more precision than 0,01 seconds. Therefore I can accept an error of 10 ms ideally. I think time.sleep() is perfect for my needs. Thanks again.