Input sequence macro

Official forum for open source FreePIE discussion and development.
Post Reply
User avatar
NopeU
One Eyed Hopeful
Posts: 31
Joined: Sat Dec 21, 2013 12:43 pm

Input sequence macro

Post 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
Jabberwock
Cross Eyed!
Posts: 197
Joined: Mon Mar 02, 2015 3:58 pm

Re: Input sequence macro

Post 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
User avatar
NopeU
One Eyed Hopeful
Posts: 31
Joined: Sat Dec 21, 2013 12:43 pm

Re: Input sequence macro

Post 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.
Post Reply

Return to “FreePIE”