Toggle with both short press and long press on the same button

Hey! I am looking to implement the following behavior: I want to use the same button to send something on CC 1 when I short press it (toggling the LED blue) but send on CC 2 when I long press it (toggling the LED green). Is that possible?

I am looking at the documentation here ( 2.1: Buttons | Intech Studio Documentation ) but when I try to combine that with my existing press to toggle button logic it says that I need to shorten my code because it has too many characters? Is what I want to do achievable somehow?

There should be a Profile called “Longpress Toggle” on the Cloud that does just that!

1 Like

Thanks! It almost does what I want. Maybe it’s even better than what I thought I wanted.

However, I cannot save it because it says the active configuration has a syntax error. That happens also with the exact Profile from the cloud with no changes. It does not tell me what or where the error is.

I can see the issue, the ELSEIF block seems to be currently bugged in Editor. Just turning that part of the configuration to code should solve the syntax error issue.

1 Like

I am using grid editor 1.5.4.
I have looked online and I am not finding the options to merge code. I too am trying to get some longpress/press options going on some buttons but I can’t store them due to syntax errors.
Can somebody direct me to how to merge code.
Thank you!!

How does one turn that ELSEIF block to code? I can not figure this out as I would like to utilize the same funcitonality of the logpress/short press that the O.P. mentioned.
I too am using the Press/Longpress toggle but can’t figure out how to “that part of the configuration to code should solve the syntax error issue.” aspect of things.

Well sadly currently this is quite tedious to do (because the bug causes to detect incorrect syntax and that prevents Merge to Code as well) but here’s a workaround (apologies the left part is cut off):

merge_workaround

1, Copy all of the minified code with the bottom-right corner button
2, Delete all blocks and create an empty Code Block
3, Paste all copied code into that Code Block and commit it

The config should now work properly.

What I did was to use the Merge To Code button for the individual Action Blocks and then just “write” the code myself, circumventing the inability to use Merge To Code on the broken ELSEIF block. I guess the advantage is that the code won’t be minified that way, if you care.

1 Like

That is super cool. So the underlying code isn’t “broken” it is simply the behind the scenes aspect of the If/Else framework.
I did what you said here, I set the MIDI CC output that I want prior to copying the entire code block package and it worked perfectly! I tried having ChatGpt to create the code for me as I am very new to all of this, and it was able to get close but it couldn’t manage having the longpress MIDI CC fire-off when the timer amount was satisfied…it would only fire off upon RELEASE of the long press which is not what I wanted. Oh well…I guess we will have to rely on humans for now like you ;). THank you very much for providing this.
One more question…how did you make this looping demonstration? Is that a gif?

1 Like

No problem, happy to help!

Yes, the small demonstration is a GIF. I used a Windows program called ScreenToGif to make it, it’s an excellent application!
I believe there is a Mac alternative as well, although I’m unsure about the name of the app.

Hi-
I tried this method and it worked…BUT…when I then quit and re-opened Grid Editor, as soon as I clicked on the button that had this newly formatted code assigned to it, it caused Grid Editor to freeze-up. I think the underlying bug in the action block that has the issue is also causing an issue even when converted to raw code.

Removing the green lines of code might help with that!

But without seeing an error message from Editor it is hard to tell what the issue could be.

I received this from intech and this is working perfectly:

if self:button_state() > 0 then timer_start(num, 1100) elseif self:button_state() == 0 and self:button_elapsed_time() < 1000 then timer_stop(num) midi_send(ch, 176, self.cc, 127) end

They are going to be updating Grid Editor soon as they have solved the bug with the Else/If code block. It is noted on their github page as well as I was told via email that this will be pushed out very soon.
I guess the positive side is this caused me to get to know a tiny little bit about Lua coding and how to get around my intech devices better than I had previously known.
I am LOVING my gear as I moved to Intech from the Monogram Pallete hardware. I was a longtime user of their stuff…but now that Monogram is non-existent, I always felt I was one Mac OS update away from it being bricked, so I proactively searched far and wide for an external hardware MIDI CC solution and a pair of Intech devices as done the trick! Very very happy with my purchase!

2 Likes