Calculating button press time with STM32? - c

I'm trying to calculate the time the button was pressed with the STM32F407 Discovery. Frequency can be any value for now. How do I calculate time?
What I am trying to do is; To enable the microcontroller to perform different operations according to different pressing times with two buttons (For example, changing the flashing times of the led). While doing this, I want to press one button for 1 second and the other button for 4 seconds (short - long press). Let the led continue its operation by not leaving the loop during the time I press it. Let it do whatever it takes when you release the button.
Help.

Related

Is there an action that sends an event when an object stops moving

So I have an enemy who randomly chooses between 4 destinations and I want him to play his idle animation when he stops moving, is there anyway this can be achieved.

How can I change the slider value within the while loop in each case in LabVIEW?

There are six LEDs that light up one after the other. I want to control the speed of the flashes with a slider. Unfortunately, after reaching station A, the value of the slider actually changes. I want if I change the slider while running, I can immediately notice the change in the flash of the LEDs. Anyone have any idea how this could be solved?
Block diagram
Based on your code,
plz make another while loop.
And then, put your slide(timer) in the new while loop.
And then, connect the slide to Labview timer by using local variable.
This is an example block diagram.
The corresponding front panel is this.
Solution could me more elegant.
Here is a more detailed explanation to the code of KKS:
You need a second while loop to change the time of your slider immediately. If you keep one while loop only, the new value of the slider will be active only in the next iteration.
You need to put your slider in the second while loop and this loop needs to run faster than your while loop which contains your LEDs.
In order to connect the value of the slider in the fast while loop with your slow while loop, you can use local variables.

STM32 How to turn on a LED a certain period of time

Like described in the title i want to turn on a LED for a period of time.
The time must be able to be interrupted. For example triggered by a button or touch display. I tought of using a timer with the interrupt but i have no idea how to realize it.
Does someone have example code for this problem? Would be nice.

How to detect multiple mobile inputs at the same time with Godot?

In the game I am currently making, the player will frequently need to press two buttons at the same time, for example "jump" and "left". Currently I have two buttons on the left side of the screen for left and right, and one on the right for jump. The problem is, if the player is pressing any of them, it effectively locks the other buttons, making it so you can't press them.
Is there some way, perhaps using InputEventScreenTouch, that I can detect the user's current touchscreen input every frame, and check if they are pressing one or more buttons?
Edit for more info:
Currently each button sends it's button_down() and button_up() signals to the same function in the HUD scene root, and I have simple functions to handle that:
func setLeft(val):
# This is the variable that the player
# checks each frame to see if it should move
self.get_parent().get_parent().goingLeft = val
So when the player starts pressing the left button, it sets goingLeft to true, and when they release it it sets goingLeft to false.
This should work fine, but I have discovered that if the player is touching the screen anywhere else, the buttons don't register input. For example, if I press the left button, the player starts going left, and then while I am holding that, I start pressing jump. The jump button doesn't register, because my finger is already pressing somewhere else on the screen (the left one).
It doesn't seem to matter if it is a button that I am pressing, just that Godot will only check buttons if there is exactly one input.
Is there some way to get around this?
I have found the solution, thanks to some people in the comments!
I changed the button types to TouchScreenButton nodes, and they have multitouch enabled, so I can press more than one at once, on a mobile device!

Change image source every n seconds wp7

I need to chage image on windows phone 7 app every 25ms. This animation should start after button pressed and play for 10 seconds. Is there any way to do it in wp7?
on the button click event you could create a timer object and start it, then on the timers tick event you check to see whether the current millisecond reading on the timer is divisible by exactly 25 (use the modulo operator) if it is you can then run the code that will change the image source property, and in the same tick event handler you can set a check for if the second reading is 10 seconds, and if it is stop the timer

Resources