Announcement

Collapse
No announcement yet.

disabling a anibutton

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • disabling a anibutton

    Hello,

    How can an anibutton be disabled such that it disappears from the screen and it does not reappear when location where the anibutton is placed is pressed.

    Thanks in advance

  • #2
    Hi,

    Can you specify what environment are you using?

    Best regards

    Comment


    • #3
      I am using a Gen4 display with an Arduino Mega and programming the display using ViSI-Genie on the Workshop Pro IDE.

      Comment


      • #4
        Just to let you know: I tried genie.WriteObject(GENIE_OBJECT_ANIBUTTON, 0x18, -1) and selected "Allow buttons to be disabled" within the Project tab within Workshop Pro and this does not work to prevent the re-appearance of the anibutton.

        Comment


        • #5
          Hi,

          It seems that you have mistyped this genie command 'genie.WriteObject(GENIE_OBJECT_ANIBUTTON, 0x18, -1) '. If you are using the ViSi Genie Arduino library, you have to write the command as shown below.

          Code:
          genie.WriteObject(GENIE_OBJ_ANIBUTTON, 0x18, -1); //Disable the Animated button
          I also attached the sample project for your reference.

          I hope this helps.

          Best Regards
          Attached Files

          Comment


          • #6
            Ivan,

            The typo is just here in my post. In the actual program, I have the correct instruction just like you. So, I tried your program and it has the same issue. The anibutton disappears when disabled but if you press the touch screen where the anibutton was placed, it will re-appear. I need it to remain hidden when disabled. Is there a way to do this?

            Regards

            Comment


            • #7
              Hi,

              It seems that you need to disable the touch of the button when you are hiding it. To enable and disable the touch of an Animated button, you can use the snippet code below.

              Code:
              img_SetAttributes(hndl, iAnibuttonN, I_TOUCH_DISABLE); //Disable Anibutton
              img_ClearAttributes(hndl, iAnibuttonN, I_TOUCH_DISABLE); //Enable Anibutton
              The N is the index of the Animated button.

              However, to use this function with ViSi Genie, You need to use add a 'Magic Object' that will handle 'MagicBytes' from the host.
              This feature is available in Workshop4 IDE Pro. The snippet code below is from the host.

              Code:
              genie.WriteMagicBytes(0, DISABLE_ANIBUTTON_TOUCH, 1); // Send Magic Byte to disable the Animated button
              The Magic Bytes could be a predefined command from the host. You can write a code inside the Magic Object to handle the incoming MagicBytes from the host.

              I have attached the modified project for your reference.

              Best Regards
              Attached Files
              ivan_4d
              4D Staff
              Last edited by ivan_4d; 17 January 2022, 06:53 PM.

              Comment


              • #8
                Ivan,

                How would you re-enable the touch of the button?

                Regards

                Comment


                • #9
                  Hi,

                  You can use the similar method I discussed. Send a Magic Byte for enabling the button.

                  Write a program in the MagicCode that will handle the command and execute the enabling and disabling of the button.

                  You can follow the code below for the MagicCode:

                  Code:
                  func rMagicObject0(var action, var object, var newVal, var *ptr)
                     var anibutton1_Disable := 0x31;
                     var anibutton1_Enable := 0x32;
                     var recv_command;
                  
                     if(action != WRITE_MAGIC_BYTES) goto exit; // check command and number of bytes
                  
                     recv_command := ptr[0];
                  
                     if(recv_command == anibutton1_Disable)
                        img_SetAttributes(hndl, iAnibutton0, I_TOUCH_DISABLE); //Disable touch for Anibutton0
                     else if(recv_command == anibutton1_Enable)
                        img_ClearAttributes(hndl, iAnibutton0, I_TOUCH_DISABLE); //Enable touch for Anibutton0
                     endif
                  
                  exit:
                     seroutX(ACK);
                  endfunc
                  For the Arduino Host:

                  Code:
                  byte DISABLE_ANIBUTTON_TOUCH = 0x31;
                  byte ENABLE_ANIBUTTON_TOUCH = 0x32;
                  
                  
                  genie.WriteMagicBytes(0, DISABLE_ANIBUTTON_TOUCH, 1); // Send Magic Byte for disabling the Animated button
                  
                  genie.WriteMagicBytes(0, ENABLE_ANIBUTTON_TOUCH, 1); // Send Magic Byte for enabling the Animated button
                  Best Regards








                  Comment


                  • #10
                    Ivan,

                    Having issues compiling the example you provided. Below are the error messages:


                    C:\Users\edwin surface\Documents\Arduino\Anibutton_Sample\Anibutton_Sample.ino: In function 'void setup()':
                    Anibutton_Sample:32:54: error: invalid conversion from 'byte {aka unsigned char}' to 'uint8_t* {aka unsigned char*}' [-fpermissive]
                    genie.WriteMagicBytes(0, DISABLE_ANIBUTTON_TOUCH, 1); //Send the Magic Byte for disabling the Anibutton
                    ^
                    In file included from C:\Users\edwin surface\Documents\Arduino\Anibutton_Sample\Anibutton_Sample.ino:1:0:
                    C:\Users\edwin surface\Documents\Arduino\libraries\genieArduino-1.4.5\src/genieArduino.h:213:17: error: initializing argument 2 of 'uint16_t Genie::WriteMagicBytes(uint16_t, uint8_t*, uint16_t)' [-fpermissive]
                    uint16_t WriteMagicBytes (uint16_t index, uint8_t *bytes, uint16_t len);
                    ^
                    exit status 1
                    invalid conversion from 'byte {aka unsigned char}' to 'uint8_t* {aka unsigned char*}' [-fpermissive]



                    Regards

                    Comment

                    Working...
                    X