Start a new topic

What is Popcallback?

I'm not understanding what this is or does.Likewise things like b0.attachPop. They are used throughout the examples so I can't figure out how they work without this missing piece of the puzzle.


Can someone explain, please?


Thanks


Examine not only the ino code but also the corresponding HMI.


b0 Touch Press Event - Send Component ID is not checked

        this would be  b0.attachPush if it was checked

        when no longer needed to catch the Press Event

        then would be b0.detachPush.

     Touch Release Event - Send Component ID IS checked

        to catch the Release Event then b0.attachPop

        when no longer needed to catch the Release Event

        then would be b0.detachPop


Parameters of attachPop is (<funct>, <compVar>);

  <funct> is a function you write

  <compVar> is the component variable 

b0.attachPop(b0PopCallback, &b0);


void b0.PopCallback(void *ptr) {

  // your function for when b0 is Released


}


But what is "Pop"? In your context it sounds like it may just be another way of saying 'release'? Press = Push, Release = Poop? 

>>>b0.attachPop(b0PopCallback, &b0); 

What is "&b0"


>>>void b0.PopCallback(void *ptr) {


Should "b0.PopCallback" be "b0PopCallback" to match the function called in  "b0.attachPop"?


Thanks


Indeed. 

Reviewing the code shows Press = Push and Release = Pop.


Can't say with exactness why the author used push and pop

 - he didn't say or leave remarks to this effect in his code


However,

   You are programming an MCU,  MCUs have stacks

   To PUSH a value onto the stack is to store in the stack

   To POP a value from the stack is to retrieve the value.


Now have you ever been able to Press without a Release?

  (outside of a final action - maybe operator died and fell on)

Pretty much a pair set of actions

   if press, then eventually release

In the same manner, you don't push to a stack without a pop

   otherwise you eventually have a stack overflow with no

   more space on the stack - and that is usually a fatal action

   to your running program.


Could have used Press and Release in the program

  - release usually refers to freeing memory

Maybe to avoid conflict then Push and Pop were chosen

who knows for sure without the author stating his whys. 

Login or Signup to post a comment