Anyway to make tasmota imitate a push button click? - tasmota

I was wondering if there is a way to use tasmota to imitate a push button click. I'am using an esp32 with tasmota and wired it to a remote with 2 buttons. There a 2 transistors for each button. It works how it is right now but the logic of the buttons on the Tasmota website toggles the output. So that I have to click and click to send a pulse. Is there a way to make the digital button click like a push button?.
Also is there a way to remember a variable for example from 1 to 6 and display it next to the button?
Thank you!

For short impulse can use : PulseTime
1..111 = set PulseTime for Relay in 0.1 second increments
112..64900 = set PulseTime for Relay, offset by 100, in 1 second increments. Add 100 to desired interval in seconds, e.g., PulseTime 113 = 13 seconds and PulseTime 460 = 6 minutes (i.e., 360 seconds)
For save to variables can use like it:
rule1
on button1#state DO var1=%value% ENDDO
on button2#state DO var2=%value% ENDDO
For use differ method of action better to use event:
When state of buttons changed then sent event:
on button1#state DO event#b1 %value% ENDDO
on button2#state DO event#b2 %value% ENDDO
Then Event that was send expanded on your commands like power1 on/off :
on event#b1 DO power1 %value% ENDDO
on event#b2 DO power2 %value% ENDDO
And remote by MQTT can sent event for button1, and should be run same commands like and for your buttons :
mosquitto_pub -h HOST -t cmnd/tasmota_NNNN/event#b1 -m 1

Related

Automatically Turn a Toggle On and Off in Max MSP

How do I automatically turn a toggle on and off in Max MSP? For instance, if I want this toggle to print out this message for 30 seconds, and then stop printing for 30 seconds, and then on and off again by itself for a set period of time without me manually adjusting it, what should I do?
To turn a toggle on or off every 30 seconds, you can connect it to the output of a [metro 30000] object.

JavaFx animation start/stop loop?

is there anyway that you can start and stop an animation, so plays for 1 sec, stops for 1 sec? I have tried to implement this with a radio button toggle with thread.sleep, however I dont think its possible this way. Are there any other ways to do this? thanks.
Given your animation:
Animation animation = ... ;
create a PauseTransition and place both in a SequentialTransition:
PauseTransition pause = new PauseTransition(Duration.seconds(1));
SequentialTransition seq = new SequentialTransition(animation, pause);
and then just play the sequential transition indefinitely (or as many times as you need):
seq.setCycleCount(Animation.INDEFINITE);
seq.play();
If you are using a Timeline as your animation, another approach is to add a key frame one second after the last key frame you have, that make no changes.

Push a button and then wait for another button

I am trying to make a Blackjack helping application in MIT App Inventor. I want the user to select the 2 cards that he has by clicking one button that maps to a card value and then click another one (could be the same button) and then take that input of 2 cards along with an input of 1 dealer card for processing. How can I click a button and then have it wait for another button to be pressed?
use a counter variable
after clicking a button, add 1 to the counter
after clicking again, add again 1 to the counter
and only if counter = 2, then continue with your logic

Autohotkey: multiple / contingent uses for one command

I'm working on a game design / UI project to redesign an existing game's control scheme (in this case, Trine) to use minimalistic input. I am trying to map lateral movement and the jump function to a Win8 tablet's volume buttons. Here is the basic code I am using:
Volume_Up::
Loop 5
{
Send {right down}
Sleep 50
}
Send {right up}
Return
Volume_Down::
Loop 5
{
Send {left down}
Sleep 50
}
Send {left up}
Return
This is working fairly well and is pretty responsive for moving left and right. However, the desired behavior that I want is to trigger jump (i.e. up) when BOTH buttons are depressed. For instance:
Player holds VolumeUp to move right.
Player comes to an obstacle.
Player continues to hold VolumeUp to queue right-bound movement and;
Player taps VolumeDown momentarily
Player jumps, movement continues up-and-over obstacle toward the right.
I have tried various permutations on using another script with the (Volume_Up & Volume_Down::) syntax to trigger this interaction, but that always seems to interfere with the movement commands. I think this may call for a nested If statement inside the move-left / move-right commands, to check if both buttons are depressed, but the Autohotkey documentation is not very clear and I'm unsure how to code that (I'm more of a game designer than I am a programmer). Any help would be really appreciated!
First of all, give attention to the comment from MCL. Pressing a button down 5 times and never releasing it in between does not seem to do much.
I think that you want multiple threads to be able to run at the same time.
Look up threads, but be aware about the following:
"Although AutoHotkey doesn't actually use multiple threads, it simulates some of that behavior: If a second thread is started -- such as by pressing another hotkey while the previous is still running -- the current thread will be interrupted (temporarily halted) to allow the new thread to become current. If a third thread is started while the second is still running, both the second and first will be in a dormant state, and so on."

Using a variable in a message - Lingo

Can anyone tell me if there is a way for me to use a variable within a lump of code, so that code can be looped to send messages to multiple objects?
For example, if I have 10 buttons and want each to send a variation of the same command 'sendCommandX', with X being the number of the button.
Right now I have 10 separate messages, and each button calls its own, like
on mouseUp
sendCommand1
end
on mouseUp
sendCommand2
end
Each of these 10 sendCommand# messages do the same thing, just with a different number in them.
It would be great if I could use a variable within the call, so I could have one reusable message. Like:
on mouseUp
sendCommandX (X being the number of the button clicked)
end
and then the sendCommandX could use the same variable within, like
on sendCommandX
echo "you clicked button X:
end
send the number as a parameter:
-- on Button 1
on mouseUp
sendCommand 1
end
-- on Button 2
on mouseUp
sendCommand 2
end
-- movie script!
on sendCommand which
-- use 'which' here, e.g.
put "You pressed button " & which
end
I guess your button scripts are cast member scripts?
This code would be better as a behavior, because then you'd only need one script. But it will work ok like this.

Resources