Announcement

Collapse
No announcement yet.

img_SetAttributes(hndl, ALL, I_TOUCH_DISABLE) makes display hang

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

  • img_SetAttributes(hndl, ALL, I_TOUCH_DISABLE) makes display hang

    Dear readers,

    I am using the function
    Code:
    img_SetAttributes(hndl, ALL, I_TOUCH_DISABLE)
    to turn off the touch sensitivity of screen objects when I dim the screen (by setting the contrast to 0). As soon as the screen is touched, I call function
    Code:
    img_ClearAttributes(hndl, ALL, I_TOUCH_DISABLE)
    to turn the touch sensitivity back on.
    This works fine, but unfortunately by calling these function the Diablo display module also becomes unstable. After a few user actions the display freezes. Sometimes the display freezes immediately; sometimes only after a while.
    By setting a flag, the imgSetAttributes/img_ClearAttributes functions are only executed once when the screen is dimmed or turned on again.
    If I do not call these functions, my display will never hang.

    The Diablo display is communicating with a custom PCB using a serial connection.
    After the display is frozen, and it is reset by interrupting the power supply, it works normally again.

    Why does the invocation of the imgSetAttributes/img_ClearAttributes functions cause the display to hang ? Is there a memory leak somewhere ?
    Are these instructions 'too heavy' (my Diablo application has 15 forms with in total hundreds of screen elements, MagicObjects and MagicEvents) ?

  • #2
    Hi,

    When using the img_ClearAttributes(hndl, ALL, I_TOUCH_DISABLE) you will be enabling touch on every widget and not just the widgets on the displayed form causing a possible conflict. You could try using,

    ActivateForm(currentform);

    where currentform is the form that you are on when the screen is dimmed and it will redraw the form and touch enable widgets on that form only. I haven't tested this so it is something you will have to try.

    Best regards

    Paul

    Comment


    • #3
      Hi Paul,

      Thank you for your answer.
      In general, calling ActivateForm(CurrentForm) seems to work well.
      However, I am opening several screens using MagicObjects, where the arguments in the call determine what else is drawn after opening the screen.
      If such a screen is refreshed with ActivateForm, I only get to see a basic, blank, screen, without the objects drawn with the MagicObjects call.
      It is also a bit disturbing that the screen, after it has been made visible by increasing the contrast, flashes again because of the ActivateForm call, but this is acceptable to me.

      So I'm still looking for a generic solution to temporarily turn off the touchscreen.
      Is it also possible to request a list of object IDs of for example the UserButtons on the active form ?
      In that case, I could disable the touch sensitivity for all buttons individually with img_SetAttributes(hndl, <button ID>, I_TOUCH_DISABLE).

      Kind regards,
      Bauke

      Comment


      • #4
        Hi,

        You could try using this instead but I'm not 100% sure if it will work but worth a try.

        Code:
        for (i := FormStartIndex[CurrentForm]; i < FormEndIndex[CurrentForm]; i++)
        j := img_GetWord(hndl, i, IMAGE_TAG) ;
        if (j)
        j-- ;
        //img_SetAttributes(hndl, i, I_STAYONTOP+I_ENABLED); // make sure this is on top of form, if applicable
        //if (j != tKeyboard)
        if (((j <= tWinButton) || (j >= t4Dbutton)) && (j != tSmartGauge) ) // enable inputs
        img_ClearAttributes(hndl, i, I_TOUCH_DISABLE); // ensure touch is enabled
        endif
        //img_Show(hndl,i) ; // show initialy, if required
        //if (j == tForm)
        // DoGFXObjects() ; // display GFX 'widgets' for image backgruobds
        //endif
        endif
        next
        Best regards

        Paul

        Comment


        • #5
          Hi Paul,

          Thanks for your solution.
          I modified the code slightly to make it generally applicable:
          Code:
          #constant disableTouch 1
          #constant enableTouch 0
          
          func setTouch(var touchStatus)
          #constant tSmartGauge 35
          
            var i,j;
          
            for (i := FormStartIndex[CurrentForm]; i < FormEndIndex[CurrentForm]; i++)
              j := img_GetWord(hndl, i, IMAGE_TAG) ;
              if (j)
                j-- ;
                if (((j <= tWinButton) || (j >= t4Dbutton)) && (j != tSmartGauge) )
                  if (touchStatus == disableTouch)
                    img_SetAttributes(hndl, i, I_TOUCH_DISABLE); // disable touch on input control
                  else
                    img_ClearAttributes(hndl, i, I_TOUCH_DISABLE); // enable touch on input control
                  endif
                endif
              endif
            next
          endfunc
          (I added tSmartGauge as a constant because somehow it was unknown in my environment)

          I added the code printed above to my MagicCode1 (Const Globals + Routine) module.
          The touch sensitivity for the controls on the current screen can be disabled by calling:
          Code:
          setTouch(disableTouch);
          Enabling the touch sensitivity:
          Code:
          setTouch(enableTouch);
          I need to test the code more extensively but so far this solution seems to be working fine and the display module does not hang anymore.

          Thanks,
          Bauke

          Comment


          • #6
            Hi Bauke,

            Thanks for the update and glad it worked out.

            Best regards

            Paul

            Comment

            Working...
            X