On/Off Button

magicizaproblem

2018-05-26 17:15:36

So far ive been messing around with the on/off project. Ive been tinkering around with the rules. Since im not yet comfortable with the bitwise functions. Ive tried programming the long way im not able to get desired results with the long form. It changes 1 color once but wont change back. any ideas of a solution? Project file is attached.


Attachments:

Open-Close-Project.bmtp

magicizaproblem

2018-05-26 17:23:49

comment

Also for for opening and closing apps i think it makes more sense if i can hold a button to open and close off the same button so i dont have to worry bout the constant open and close loop. is this possible?

Steve-Bome Forum Moderator

2018-05-26 17:42:55

Hi Preston,

The script you posted is working, however I’m testing with my Launchpad MK2 which generates different colors than the Orbit.

You will need to uncomment (remove leading //) on the following lines

//if ga==1 then pp=3
//if ga==0 then pp=12

and then comment the following lines

if ga==1 then pp=5
if ga==0 then pp=32

 

in the rules of 1.2 (Send LED Status)

 

I also have the same button set up to open and close the app (of course your Apple Script will have to do the actual launch/kill work).

I don’t know how you have your Orbit programmed so you might have to change which incoming note and channel to use on translators 1.0 1.1 and 1.2.

The value of ga is used to tell if the program is running or not.  If ga=1 then the program is assumed running. If ga=0 then it assumed to not be running. We are only checking for button push so we ignore if the button is release.  You push the button once and 1.1 will fire if ga=0 to start the application.  You push it again and 1.2 will fire to kill the application.

 

Let me know if I missed you point.

Regards,

Steve

 

 

Steve-Bome Forum Moderator

2018-05-26 20:07:29

Hi Preston,

Here is an example of Long Press.  If I understand it correctly, you did not want instant reaction when you pressed a button to start/stop your application.  This is to avoid problems when unintentionally pressing the button.  The below example uses a timer to detect how long the button has been pressed.  It is set up to ignore any presses less than 2 seconds (2000 ms).

The first translator starts at timer called “Long Press” with a delay of 2000 ms (2 seconds)

The second translator identifies if you released the button. It will kill the timer when the button is released.

In this way if you hold the button down > 2 seconds, the timer will fire and send LED status update (incoming message for the LED Status translator).

The Long press timer will also execute any Apple Script you have added. You will need to add this Script to either Launch or Kill your application depending on the value of ga. If ga=1 then you should launch. If ga=0 you should kill.

Of course you will also need to modify rules for your Orbit controller incoming notes and outgoing colors as I tested this with buttons on my Launchpad MK2

I hope you find this useful!

I also left the original preset intact but disabled it in case you ever want to go back.

Steve

 


Attachments:

Open-Close-Project-Long-Press.bmtp

magicizaproblem

2018-05-26 23:10:02

comment

Thank You Very Much!

Steve-Bome Forum Moderator

2018-05-26 23:16:32

comment

My pleasure, Preston!