Announcement

Collapse
No announcement yet.

Winbutton, Userbutton, Userimages - Which to use and best practices?

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

  • Winbutton, Userbutton, Userimages - Which to use and best practices?

    Hi,
    Had some (hopefully) simple questions about buttons, best practices and which is most efficient to use for memory and processing.
    Can you please confirm my understanding of a button and it's 3 basic parts:
    Note these questions are pertaining to Visi-Genie specifically

    1. img_ClearAttributes(...)
    • This enables a userbutton, winbutton, userimage or whatever object you want to respond to touches.
    • This should be done for every button used in a magiccode, magicevent, ect. (for instance ImageTouched = iUserimages14 or WriteObject(tUserimage) )
    • It is not necessary or should not be done when winbutton, userbutton, userimage have an action in the onchanged event handler (for instance Form37Activate or Report Message)
    2. img_Show(...)
    • Displays button, at it's current state. Initial state is 0. After indexing image, img_show should be done again to refresh the appearance due to the new state.
    • an initial img_show is not necessary in visi-genie as the button, image, ect will be shown in it's initial state.
    • WriteObject(tUserbutton) can be used instead of img_Show(..) => img_SetWord(... image_index ...) => img_Show(...) to display a refreshed image state.
    3. img_SetWord
    • the action to change the button state (on, off) (on, onpressed, off, offpressed)
    • Not necessary or should not be done as it is already handled in the button "Momentary" properties.

    Recently I have started encountering some issues such as STACK OVERFLOW and my display freezing. I wanted to start eliminating where the cause could be coming from.
    I use a lot of custom Userimages as buttons because my buttons can have 2, 3 or 4 unique states. My thought process here is that I didn't want to have conflicts with the the predefined Userbutton properties. Am I correct in this line of though? Should I be using Userbuttons instead? Are userimages as buttons more resource intensive than userbuttons?

    Thanks in advance,
    Justin

  • #2
    Hi Justin,

    1. img_ClearAttributes(...)
    • This enables a userbutton, winbutton, userimage or whatever object you want to respond to touches.
    • This should be done for every button used in a magiccode, magicevent, ect. (for instance ImageTouched = iUserimages14 or WriteObject(tUserimage) )
    • It is not necessary or should not be done when winbutton, userbutton, userimage have an action in the onchanged event handler (for instance Form37Activate or Report Message
    - The img_ClearAttributes(...) is not limited to just disabling touch, there are also some properties that you can change/set.
    - Touch input widgets (e.g. Buttons and Inputs) have already touch capability enabled unlike the output widgets (e.g. Digits, Gauges, etc..)

    WriteObject(tUserbutton) can be used instead of img_Show(..) => img_SetWord(... image_index ...) => img_Show(...) to display a refreshed image state.
    -Yes, you could do it that way. Btw, you do not need the first image_show() to iterate and change the image.
    img_SetWord(... image_index ...) => img_Show(...)

    3. img_SetWord
    • the action to change the button state (on, off) (on, onpressed, off, offpressed)
    • Not necessary or should not be done as it is already handled in the button "Momentary" properties.
    For output widgets, you must specify the frame of the widget whenever an action has been taken (touch pressed/release). img_SetWord(...) is also not limited to changing the frame of the image there are also other properties involved (e.g. Position of the image). For input widgets, you do not need to use the img_SetWord, unless you want to change the state of the input widget for some reason.

    Usually, Stack Overflow is caused by a recursive program or insufficient stack size. When does it occur?

    There should be no distinct difference in the performance. It does depend on your application, usually, when you do not want to edit too much configuration on the code, the User button is the way to go. Though it consumes more code size than the UserImage.

    Empty Project:
    code size = 1759 bytes out of 32750
    RAM size = 1148 out of 32768

    With User Button
    code size = 2879 bytes out of 32750
    RAM size = 1176 out of 32768

    With User Image
    code size = 1761 bytes out of 32750
    RAM size = 1176 out of 32768


    Additionally, you may check this application notes below

    AN-00030 ViSi-Genie User Button
    https://4dsystems.com.au/blog/4d-an-00030/

    AN-00034 ViSi Genie User Images
    https://4dsystems.com.au/blog/4d-an-00034/

    AN-00116 ViSi-Genie Blocked User Buttons
    https://4dsystems.com.au/blog/4d-an-00116/

    Best Regards,
    Kevin

    Comment

    Working...
    X