This code works just fine:
import time
from pymata4 import pymata4
num_steps = 512
angular_velocity = 42
pins = [8,9,10,11]
board = pymata4.Pymata4()
board.set_pin_mode_stepper(num_steps, pins)
while True:
board.stepper_write(angular_velocity, num_steps)
time.sleep(1)
board.stepper_write(angular_velocity, -num_steps)
time.sleep(1)
So, I want a GUI in Tkinter to ask those numbers (512 and 42) to the user. They press submit and that info gets storaged and then, after pressing another button to start, the stepper starts its job.
This is my code so far:
https://pastebin.pl/view/5db5aa92
It's huge and I feel like I'm going in circles. The more I change the code, the more it gets broken. It's giving headaches already and I have no clue what I'm doing wrong. Please, help guys! I'd really appreciate it!
PS: I think I should erase the code and start from the beginning. If that's the case, can some give me a hint or something? Please!
Related
I would like to know if someone has found a solution to counter this horrible calculation from tradingview:
when Calc on every tick is selected only, the numbers of trades in backtesting seems correct, BUT because it doesn't calculate a supplementary intra-bar it really often misses the correct stop loss price. It closes at the close of the next bar after entry. so it destroys the backtest results calc on everytick intrabar stoploss problem example image
when "calc after orders filled" is enabled, it solves the problem of the stop loss BUT it is starting to make completely WTF entries, sometimes on Wick or Open bars which is increasing the number of trades in an unrealistic way. entry on wick example image
if calc after order filled is enabled + Bar magnifier = LITERALLY THE HELL
It's starting to add an infinite number of trades on the same bar sometimes Calc after order filled + Bar Magnifier example image
So please if someone found a solution to these problems it would be incredible.
Same over here brother. I was just looking for help with limit entry orders getting activated on a signal and they seem to enter on bar close. I tried every combination of those settings too, sometimes they work sometimes they dont i guess. I dont know how to help you but if there's a solution would benice. Maybe place a support ticket to trading view.
This is the code of the game I'm working on. I want to know how to make the button go away when I press it. I have already tried putting hide.button in a few places but don't know if they were the right spots. I'm just learning how to code. Please help me figure this out. I also tried looking it up but couldn't find the problem
https://i.stack.imgur.com/V9Gji.png
Here is a reference from p5 itself that shows how to hide items, you can make the button a function by:
let button = createButton(**button settings**);
button.hide();
I see you tried to put button.hide() , but most likely did not make "button" a function, therefore p5 did not know what "button" was.
Hope that helped! Happy coding!
EDIT: Before you put
button.hide();
Try putting it in an if statement as below:
let button = createButton(**button settings**);
if(button.mousePressed){
button.hide();
}
Then put that in your sketches setup function
I'm building an automatic timer system as a fun silly project for some office chums. It's end user goal is to allow end users to be away from keyboard while still simulating activity to prevent timed applications from changing their statuses to away.
I have the front end of a windows form with two buttons. ON and OFF. When I press on, I want it to begin moving the mouse in 1 minute intervals for a moment. (or click maybe.) and when I select off it stops the action.
I've never really coded much before (I've done basic python stuff so I know what an if statement is, a function, how to declare a variable etc but I've never done anything with a GUI or in c# so this is all new.)
Lastly, I would want to save/export it as an exe for distribution for slackers I mean end users to run and use.
Thanks so much for the help!
Looks like someone is trying to hack their way out to keep their PC active when away from desk :D
//programmatically move the mouse example
PointConverter pc = new PointConverter();
Point pt = new Point();
pt = (Point)pc.ConvertFromString("0, 768");
Cursor.Position = pt;
Ref
all. I'm new to Matlab and I'm a bit stuck. The last piece of the puzzle to run my experiment is to get some human input (expert supervised system). As easy as this may sound, I just can't seem to figure this one out.
I need to display four images to the user, plus an additional fifth figure (button, or could even be another image, doesn't matter). The code should wait until the user clicks any one of those images/figures and should continue afterwards (closing the figures, too). Obviously, I'd need to know which figure was clicked.
GUI programming in Matlab doesn't seem to be documented clearly to me. Or perhaps it's just in a realm that I'm not talented with. It's definitely a lot more confusing than Visual Studio, that's for sure.
Thanks in advance for your time; I greatly appreciate it! :)
Could you make all five of the images into buttons? The 'CData' property of a button can be used to display an image on a MATLAB button. See the following links for an example and an explanation (that hopefully makes sense!).
http://www.mathworks.com/matlabcentral/fileexchange/2378-buttons/content/buttons.m
http://www.mathworks.com/support/solutions/en/data/1-16V03/
Use menu:
figure(1)
plot...
figure(2)
plot...
figure(3)
plot...
figure(4)
plot...
% this will create a menu of labeled buttons where the user can click
m = menu('Choose a figure','Figure 1','Figure 2','Figure 3','Figure 4','None');
% close all 4 figures
close(1:4) %will close figures 1 to 4
% --------- your program from here on ---------
if m == 5
display('You chose no Figure');
else
display(['You chose Figure:' num2str(m)]);
end
%---------
menu will return a number which corresponds to the option that the user clicked on.
I am making an application to control the mouse using an analog stick from a gamepad for Mac OS X (10.7.3).
Currently it is working pretty well, I can control the cursor in desktop and most games. But in Team Fortress 2, I cant control the aim, but can control the cursor in the menu. Mouse wheel and clicks works everywhere.
Another strange thing is that when I move the real mouse, the aim "jumps" the traveled distance from my "virtual mouse" before aiming normally, so it somewhat is receiving the events.
The game option "Raw mouse input" is disabled (I think it is not even supported in osx). And a similar application can controle the aim successfully.
I suspect the game is looking for "delta movement" or "relative movement" events or anything similar, but my code sets the position of the cursor using absolute positions. Not sute how to change this.
Here is the snippet of code used to send mouseMoved events:
EDIT: Crappy code removed!
.
EDIT:
Also, because I did this way, I need to check the screen bounds manually to prevent the cursor going Crazy. So in multi-screen setups, and when the user change the resolution, it gets worst. Would be so much better if I can just send the amount of movement and let the OS take care of constraining the cursor.
.
The question is:
I am doing the mouse move events the wrong way?
How can I fix this?
EDIT2:
So, that was just a stupid bug, sorry =P
I just forgot to call CGSetIntegerValueField(kCGEventMouseDeltaX, ...) (and Y) with the delta values... =P
Finally got this working, after just a few short hours of Googling and experimenting :) Looks like Rodrigo was trying to say that you have to call CGEventSetIntegerValueField on kCGMouseEventDeltaX and kCGMouseEventDeltaY on the mouse event after constructing it.
My code, using PyObjC:
from Quartz.CoreGraphics import (
CGEventCreate,
CGEventCreateMouseEvent,
CGEventGetLocation,
CGEventPost,
CGEventSetIntegerValueField,
kCGEventMouseMoved,
kCGHIDEventTap,
kCGMouseEventDeltaX,
kCGMouseEventDeltaY,
)
def mouse_delta(delta_x, delta_y):
"""
Send a MouseMoved event with the given deltaX and deltaY attributes,
but without changing the cursor location.
"""
# Might be a better way to get the current mouse location
x, y = CGEventGetLocation(CGEventCreate(None))
# The `mouseButton` parameter to CGEventCreateMouseEvent is ignored
# unless `mouseType` is kCGEventOtherMouse{Down,Dragged,Up},
# so let's just pass the value 0
event = CGEventCreateMouseEvent(None, kCGEventMouseMoved, (x, y), 0)
CGEventSetIntegerValueField(event, kCGMouseEventDeltaX, delta_x)
CGEventSetIntegerValueField(event, kCGMouseEventDeltaY, delta_y)
return CGEventPost(kCGHIDEventTap, event)