It is currently Sun Nov 18, 2018 3:18 pm



Reply to topic  [ 3 posts ] 
 Input sequence macro 
Author Message
One Eyed Hopeful
User avatar

Joined: Sat Dec 21, 2013 12:43 pm
Posts: 24
Reply with quote
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:
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


Fri Jun 08, 2018 11:30 pm
Profile
Cross Eyed!

Joined: Mon Mar 02, 2015 3:58 pm
Posts: 119
Reply with quote
You have to import time library to use sleep, like that:

Code:
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


Sat Jun 09, 2018 9:09 am
Profile
One Eyed Hopeful
User avatar

Joined: Sat Dec 21, 2013 12:43 pm
Posts: 24
Reply with quote
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.


Sat Jun 09, 2018 4:31 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by STSoftware.