Announcement

Collapse
No announcement yet.

Magic touch query

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

  • Magic touch query

    Hi All

    I've hit a bit of a problem when I have tried to use the magic touch object to handle some of my touch screen requirements and wondered if anyone could help.

    Basically I have two Leddigit objects on my form and I want to set a variable called led based on which of the two is touched.

    Initially the MagicTouch code was not being called when the Leddigit objects were touched. I read in another thread that the touch property for 'output' type objects was not automatically enabled (the example in this case was a gauge I think) and the solution was to add the following code in a Magic code object with an insertion point of PreActivateForm.

    img_ClearAttributes(hndl, iLeddigits0, I_TOUCH_DISABLE);
    img_ClearAttributes(hndl, iLeddigits1, I_TOUCH_DISABLE);

    Having done this, when I touch the Leddigit objects, my display (Gen4-uLCD-43DT) simply resets!!!!

    The post I got the above advice from was quite old so maybe not appropriate for this display? Am I missing something simple?

    If it helps, in the MagicTouch object I have the following code



    txt_MoveCursor(0,0); // Diagnostic to see if this routine is being called
    print(ImageTouched);

    if (CurrentForm == 0) // When input form is selected detect the touch to select which object is to be updated

    if(ImageTouched == iLeddigits0) //Sense the blue LED has been touched

    txt_MoveCursor(0,0);
    print("CC Number");
    led := red;

    else if(ImageTouched == iLeddigits1) //Sense the blue LED has been touched

    txt_MoveCursor(0,0);
    print("CC Value ");
    led := blue;

    endif

    endif

  • #2
    Hi Tim, Welcome to the forum!

    First off, output widgets such as LEDdigit are not designed to be touched in Visi-Genie, hence
    enabling its touch capability must be done manually by img_ClearAttributes(hndl, iLeddigitsX, I_TOUCH_DISABLE) function.

    Below is a working code based on the process that you need.

    Remember:
    Read the comments of the code to be guided


    MagicCode0.inc (InsertPoint ---> PostActiveForm)
    Code:
    if (CurrentForm == 0)                                     // recommended if the LEDdigits are located in a single form
        img_ClearAttributes(hndl, iLeddigits0, I_TOUCH_DISABLE);      // enable touch 
        img_ClearAttributes(hndl, iLeddigits1, I_TOUCH_DISABLE);
    else
        img_SetAttributes(hndl, iLeddigits0, I_TOUCH_DISABLE);    // disable touch
        img_SetAttributes(hndl, iLeddigits1, I_TOUCH_DISABLE);
    endif
    MagicTouch.inc
    Code:
    txt_MoveCursor(0,0);
    
    if (ImageTouched == iLeddigits0)
        print("LEDdigit RED ");
    else if (ImageTouched == iLeddigits1)
        print("LEDdigit BLUE");
    endif
    
    ImageTouched := -1;        // used to stop Genie processing the object ‘later on’ - refer to manual
    MagicMove.inc
    Code:
    ImageTouched := -1;
    MagicRelease.inc
    Code:
    ImageTouched := -1;

    Attached is the sample code.




    Best regards,

    - Vince -


    Attached Files

    Comment


    • #3
      Hi Vince

      Thanks for your help. The problem of the display crashing has been fixed so thanks for that.

      It does now seem to have disrupted a few other things though. The code works once and from my debug I can see it using the MagicTouch code. After this first touch however, it then seems to freeze or crash becoming unresponsive to any touch of either the Leddigits or the two other items I have on the screen.

      I followed the code above but had to comment out the magic release and magic move code setting ImageTouched := -1; because this was disabling items I have on other screens.

      I have had this working using a routine in the main loop (which is currently commented out) but hoped to tidy things up using the magic touch functionality.

      I hope you don't mind but I've attached my code in case you are able to have a quick look where I am going wrong.

      Axon V4.zip

      Comment


      • #4
        Hi Tim,

        You only need a little modification in your code to get this done.

        Below is the implementation.

        MagicTouch.inc
        Code:
        if(ImageTouched == iLeddigits0)                        //Sense the blue LED has been touched
        
                txt_MoveCursor(0,0);
                print("CC Number");
                led := red;
                ImageTouched := -1;
        
            else if(ImageTouched == iLeddigits1)                   //Sense the blue LED has been touched
        
                txt_MoveCursor(0,0);
                print("CC Value ");
                led := blue;
                ImageTouched := -1;
          endif
        MagicMove.inc and MagicRelease.inc
        Code:
        if(ImageTouched == iLeddigits0 )                        //Sense the red LED
        
                ImageTouched := -1;
        
            else if(ImageTouched == iLeddigits1)                   //Sense the blue LED
        
                ImageTouched := -1;
        
            endif
        Attached is your modified code.


        - Vince
        Attached Files

        Comment


        • #5
          Vince, thank you so much that's awesome working perfectly!

          Was it just the MagicMove.inc
          and
          MagicRelease.inc
          code that needed changing? or did any other aspects need updating?

          Comment


          • #6
            Hi again,

            Code changes in MagicMove.inc and MagicRelease.inc relative to the code you sent is to make sure that the program will stop processing the specific object 'later on' (after pressing, releasing and moving) to avoid error when running the entire code. There is no need for an update to other parameters but bear in mind the set conditions in implementing the code "ImageTouched := -1" .

            Best regards,

            - Vince -

            Comment


            • #7
              Thanks Vince, I think I'm getting the hang of this now

              Still get the odd glitch but have been able to work through most of them its usually when I set or don't set the "ImageTouched := -1"
              . at the right time

              Comment


              • #8
                No worries Tim.

                If you encounter problem/s in your project in the future, we will gladly assist you.

                Best regards,

                Vince

                Comment

                Working...
                X