# Special button - snapshot power on

**URL:** <https://forum.midibox.org/t/special-button-snapshot-power-on/17420>\
**Category:** MIDIbox HUIs\
**Created:** [March 18, 2013, 6:39pm UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420 "2013-03-18T18:39:39Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![dinama](https://forum.midibox.org/letter_avatar_proxy/v4/letter/d/e480ec/32.png) [@dinama](https://forum.midibox.org/u/dinama)\
**Post date:** [March 18, 2013, 6:39pm UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/1 "2013-03-18T18:39:39Z")

</div>

Hi.

I have not programming skill so is about a week that i try to solve this thing.

I want a special button for my midibox.

This button have the same function of “snapshot at poweron” but manually triggered .

So when i push this button the box will send all current pot settings ( actual values â€‹â€‹marked by the position of the potentiometer not the one stored in bank) whithout store it in bank.

In other words get the current physical position of all pots, and then transmit them to output midi port.

I try to write a meta event to do this

MB64\_META\_Handler

movf MIDI\_EVNT1, W

goto MB64\_PATCH\_SendCurrent

but there is somethig wrong in this.

[http://discourse.midibox.org/t/topic/9361](http://discourse.midibox.org/t/topic/9361)

unsigned char i;

unsigned char MyArray[num\_ains];

for (i = 0 ; i \<= num\_ains ; i++) {

MyArray[(i)] = MIOS\_AIN\_Pin7bitGet(i);

}

but this is a pseudocode and i don’t have skill to translate it in a real solution.

I think there is a simple solution with meta handler and existing functions but i don’t see it.

please can someone help me.

thanks

---

<div class="post-metadata">

**Author:** ![T.K](https://forum.midibox.org/user_avatar/forum.midibox.org/t.k/32/7_2.png) [@T.K](https://forum.midibox.org/u/T.K)\
**Post date:** [March 18, 2013, 9:06pm UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/2 "2013-03-18T21:06:41Z")

</div>

Just

```
call MB64_PATCH_SendCurrent

```

what’s wrong with this function?

&nbsp;

Or do you want to send the current patch?

Then

```
call MB64_PATCH_Send

```

The code is located in mb64\_patch.inc (for your inspiration)

&nbsp;

Best Regards, Thorsten.

---

<div class="post-metadata">

**Author:** ![dinama](https://forum.midibox.org/letter_avatar_proxy/v4/letter/d/e480ec/32.png) [@dinama](https://forum.midibox.org/u/dinama)\
**Post date:** [March 19, 2013, 11:51am UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/3 "2013-03-19T11:51:05Z")

</div>

Hi.

I try your solution but it does not work.

&nbsp;

i modify mb64\_meta.inc

&nbsp;

MB64\_META\_Handler  
&nbsp;movf&nbsp;&nbsp;&nbsp; MIDI\_EVNT1, W  
&nbsp;&nbsp;call MB64\_PATCH\_SendCurrent

&nbsp;

and compile a new hex file.

&nbsp;

This is&nbsp; the part of .ini file where the meta event is assigned to button

&nbsp;

[bUTTONS]  
&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp; # Additional 4 Buttons in the menu section  
&nbsp;&nbsp;&nbsp; 19&nbsp; =&nbsp; F0 00 7f @Onoff

&nbsp;

these are other options active

[sNAPSHOT\_AT\_POWERON]  
&nbsp;&nbsp; enabled

[AUTO\_SNAPSHOT]  
&nbsp;&nbsp; enabled

&nbsp;

When i turn on midibox i can see on display “Loading Setup from bankstick” then “Sending Snapshot” .

After this the midibox turn-off alone, restart , again on display&nbsp; “Loading Setup from bankstick”&nbsp;&nbsp; and “Sending Snapshot” , then the box crash&nbsp;.

the display text remains “Sending Snapshot”.

&nbsp;

I try with

goto MB64\_PATCH\_SendCurrent

with same result.

&nbsp;

It like there is a loop that sends the machine in crash.

i don’t know

When i delete

movf&nbsp;&nbsp;&nbsp; MIDI\_EVNT1, W  
&nbsp;&nbsp;call MB64\_PATCH\_SendCurrent

the midibox return ok.

---

<div class="post-metadata">

**Author:** ![T.K](https://forum.midibox.org/user_avatar/forum.midibox.org/t.k/32/7_2.png) [@T.K](https://forum.midibox.org/u/T.K)\
**Post date:** [March 19, 2013, 7:31pm UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/4 "2013-03-19T19:31:31Z")

</div>

Alright, now it’s clear (you should have mentioned this earlier): since the MB64\_PATCH functions also send the meta event, you will get an infinite loop.

&nbsp;

I remember that I had the same problem with the snapshot SFB, and I remember that I solved this by implementing a request flag mechanism in main.inc to ensure, that the patch is only sent once.

&nbsp;

So, new approach:

&nbsp;

write

```
MB64_META_Handler
        bsf MB_STAT2, MB_STAT2_PWR_SNAPSHOT_REQ
        return

```

&nbsp;

if you want to request the MB64\_PATCH\_SendCurrent call

&nbsp;

or write

```
MB64_META_Handler
        bsf MB_STAT, MB_STAT_SNAPSHOT_REQ
        return

```

&nbsp;

if you want to request the MB64\_PATCH\_Send call

&nbsp;

The USER\_Tick function in main.inc will check this flag, call the appr. function if it’s 1, and clear the flag thereafter.

&nbsp;

Best Regards, Thorsten.

---

<div class="post-metadata">

**Author:** ![dinama](https://forum.midibox.org/letter_avatar_proxy/v4/letter/d/e480ec/32.png) [@dinama](https://forum.midibox.org/u/dinama)\
**Post date:** [March 24, 2013, 9:51am UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/5 "2013-03-24T09:51:48Z")

</div>

_perfect!!!_

_thanks_

---

<div class="post-metadata">

**Author:** ![dinama](https://forum.midibox.org/letter_avatar_proxy/v4/letter/d/e480ec/32.png) [@dinama](https://forum.midibox.org/u/dinama)\
**Post date:** [March 24, 2013, 6:50pm UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/6 "2013-03-24T18:50:10Z")

</div>

Sorry but after a few attempts i discovered a problem.

i use your solution and i assign to a button&nbsp;the meta handler.

&nbsp;

MB64\_META\_Handler

bsf MB\_STAT2, MB\_STAT2\_PWR\_SNAPSHOT\_REQ

return

&nbsp;

but now with

[AUTO\_SNAPSHOT]&nbsp;&nbsp; enabled

when i change bank with button 17-18-19 midibox don’t recall the values stored in bankstick but everytime

make a snapshot of current pot position.

&nbsp;

if i use

[AUTO\_SNAPSHOT]&nbsp;&nbsp; disabled&nbsp; midibox recall the values stored in bankstick but don’t sent it to midi out port.

&nbsp;

This is&nbsp; the part of .ini file where the meta event is assigned to button

&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;17&nbsp; =&nbsp; FF 04 00 @OnOnly  
&nbsp;&nbsp;&nbsp; 18&nbsp; =&nbsp; FF 04 01 @OnOnly  
&nbsp;&nbsp;&nbsp; 19&nbsp; =&nbsp; FF 04 03&nbsp;@OnOnly  
&nbsp;&nbsp;&nbsp; 20&nbsp; =&nbsp; F0 00 7F @OnOnly

---

<div class="post-metadata">

**Author:** ![T.K](https://forum.midibox.org/user_avatar/forum.midibox.org/t.k/32/7_2.png) [@T.K](https://forum.midibox.org/u/T.K)\
**Post date:** [March 24, 2013, 7:51pm UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/7 "2013-03-24T19:51:55Z")

</div>

I’ve to ask you some questions to ensure that I understood you correctly:

&nbsp;

Which option do you want to use?

[AUTO\_SNAPSHOT] &nbsp;enabled?

And you want that values are stored in BankStick, and that they are sent to the MIDI OUT?

&nbsp;

Best Regards, Thorsten.

---

<div class="post-metadata">

**Author:** ![dinama](https://forum.midibox.org/letter_avatar_proxy/v4/letter/d/e480ec/32.png) [@dinama](https://forum.midibox.org/u/dinama)\
**Post date:** [March 24, 2013, 9:06pm UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/8 "2013-03-24T21:06:01Z")

</div>

i think it’s better for me to use

[AUTO\_SNAPSHOT] &nbsp;enabled

because when in bank1&nbsp;i push button

18&nbsp; =&nbsp; FF 04 01 @OnOnly (or FF 02 01 if i don’t want to save the value in bank1)

i want to jump to bank 2 and restore value stored in bank2 and sent it to midi out.

&nbsp;

maybe the problem is the flag that i set in meta-handler for my special button

MB64\_META\_Handler

bsf MB\_STAT2, MB\_STAT2\_PWR\_SNAPSHOT\_REQ

return

&nbsp;

maybe USER\_Tick function in main.inc&nbsp;don’t clear the flag

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![T.K](https://forum.midibox.org/user_avatar/forum.midibox.org/t.k/32/7_2.png) [@T.K](https://forum.midibox.org/u/T.K)\
**Post date:** [March 24, 2013, 9:09pm UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/9 "2013-03-24T21:09:50Z")

</div>

Could you please search in main.inc, if the flag is cleared?

(this is a learning example which should help you to get a better understanding of the code without asking me ;-))

&nbsp;

Best Regards, Thorsten.

---

<div class="post-metadata">

**Author:** ![dinama](https://forum.midibox.org/letter_avatar_proxy/v4/letter/d/e480ec/32.png) [@dinama](https://forum.midibox.org/u/dinama)\
**Post date:** [March 25, 2013, 5:45am UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/10 "2013-03-25T05:45:19Z")

</div>

Ok i think this is the line where the flag is reset in user tick

bcf MB\_STAT2, MB\_STAT2\_PWR\_SNAPSHOT\_REQ

So why every time i change bank i don’t have value stored in bank but the snapshot value?

---

<div class="post-metadata">

**Author:** ![T.K](https://forum.midibox.org/user_avatar/forum.midibox.org/t.k/32/7_2.png) [@T.K](https://forum.midibox.org/u/T.K)\
**Post date:** [March 26, 2013, 7:34pm UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/11 "2013-03-26T19:34:49Z")

</div>

Yes, you are right.

&nbsp;

I’m surprised by myself that nobody noticed this yet!

I can work on the MB64\_PATCH\_SendCurrent routine, so that the value is stored in the snapshot as well.

But this needs some time…

&nbsp;

Best Regards, Thorsten.

---

<div class="post-metadata">

**Author:** ![dinama](https://forum.midibox.org/letter_avatar_proxy/v4/letter/d/e480ec/32.png) [@dinama](https://forum.midibox.org/u/dinama)\
**Post date:** [April 3, 2013, 7:34pm UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/12 "2013-04-03T19:34:54Z")

</div>

Any news?

---

<div class="post-metadata">

**Author:** ![T.K](https://forum.midibox.org/user_avatar/forum.midibox.org/t.k/32/7_2.png) [@T.K](https://forum.midibox.org/u/T.K)\
**Post date:** [April 3, 2013, 7:50pm UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/13 "2013-04-03T19:50:51Z")

</div>

Not yet… as mentioned above, it will need some time.

I’ve to open my MB64 case, replace the MBHP\_CORE\_LPC17 module by a MBHP\_CORE, have to find out what I did years ago and then try out changes (which are error prone…) in order to help you on this topic.

&nbsp;

Best Regards, Thorsten.

---

<div class="post-metadata">

**Author:** ![dinama](https://forum.midibox.org/letter_avatar_proxy/v4/letter/d/e480ec/32.png) [@dinama](https://forum.midibox.org/u/dinama)\
**Post date:** [May 1, 2013, 7:54am UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/14 "2013-05-01T07:54:29Z")

</div>

news, please

---

<div class="post-metadata">

**Author:** ![T.K](https://forum.midibox.org/user_avatar/forum.midibox.org/t.k/32/7_2.png) [@T.K](https://forum.midibox.org/u/T.K)\
**Post date:** [May 2, 2013, 6:38pm UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/15 "2013-05-02T18:38:04Z")

</div>

no news yet

&nbsp;

Best Regards, Thorsten.

---

<div class="post-metadata">

**Author:** ![dinama](https://forum.midibox.org/letter_avatar_proxy/v4/letter/d/e480ec/32.png) [@dinama](https://forum.midibox.org/u/dinama)\
**Post date:** [May 29, 2013, 3:51pm UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/16 "2013-05-29T15:51:46Z")

</div>

please give me a news. i’d like to finish my project. thanks

---

<div class="post-metadata">

**Author:** ![T.K](https://forum.midibox.org/user_avatar/forum.midibox.org/t.k/32/7_2.png) [@T.K](https://forum.midibox.org/u/T.K)\
**Post date:** [May 30, 2013, 8:19pm UTC](https://forum.midibox.org/t/special-button-snapshot-power-on/17420/17 "2013-05-30T20:19:34Z")

</div>

currently too many people are giving me requests…

Is this enhancement really so important? It seems that you are the only guy who is interested on this, or are there others (maybe even with programming skills) who could help out?

&nbsp;

Best Regards, Thorsten.
