Announcement

Collapse
No announcement yet.

Widgets disappearing when switching forms

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

  • Widgets disappearing when switching forms

    Hello,

    I' writing a GUI with several forms.

    At the moment I have two forms for testing the switching functionality, by pressing the IMediaButtons in the lower left and right corner.
    When I have cycled thorough the forms and come back to the first, there are some buttons missing (e.g. the MediaButtons), however they are still clickable.
    I have pasted screenshots in the order of appearance.
    1St2ndClick image for larger version

Name:	IMG_2448.JPG
Views:	40
Size:	3.34 MB
ID:	759674th

    I find it pretty strange, as the code for creating e.g. 1st and 3rd screen is identical.

    I have added the relevant part of the code below.

    Maybe someone of you has an idea on how to fix this issue. If you need further information, please let me know.

    Your help is much appreciated.

    Cheers,

    Clemi


    Code:
    repeat
    if(sys_GetTimer(TIMER0)== 0) // if TIMER0 is now zero (which means 200 ms has passed), check the receive buffer
    if(com_Count()) // if there is a character available (COM0)
    readRFID();
    endif
    sys_SetTimer(TIMER0, 200); // reset TIMER0
    endif
    
    active_state := Form_RFID(); //run Form1 initially, get return value
    if(active_state == FORM_RFID)
    active_state := Form_RFID(); //run Form2
    else if(active_state == FORM_TEMPS)
    active_state := Form_Temps(); //run Form1
    endif
    forever
    endfunc
    
    
    func Form_RFID()
    var _touch_state, _touched_widget_number, _return_value;
    
    widget_SetAttributes(handle, F1_LEFT, WIDGET_F_TOUCH_ENABLE); // Enable touch for switch
    widget_SetAttributes(handle, F1_RIGHT, WIDGET_F_TOUCH_ENABLE); // Enable touch for switch
    // Form1 1.1 generated 08.06.2021 10:29:26
    
    gfx_BGcolour(0xCE79) ;
    gfx_Cls() ;
    // IMediaPanel2 1.0 generated 08.06.2021 10:29:26
    flash_FunctionCall(FLASHBANK_5, Fgfx_MediaPanel, 0, vIMediaPanel2RAM, IIMediaPanel2, 15, 0) ; // Can also use img_FileExec() and img_FileLoadFunction(), but definitions must be in RAM
    
    // ILed1 1.0 generated 08.06.2021 10:29:26
    gfx_Led(1, vILed1RAM, IILed1) ;
    
    // Statictext1 1.0 generated 08.06.2021 10:29:26
    img_Show(hndl,iStatictext1) ;
    
    // Statictext2 1.0 generated 08.06.2021 10:29:26
    img_Show(hndl,iStatictext2) ;
    
    
    // IMediaPanel1 1.0 generated 08.06.2021 10:29:27
    flash_FunctionCall(FLASHBANK_5, Fgfx_MediaPanel, 0, vIMediaPanel1RAM, IIMediaPanel1, 15, 0) ; // Can also use img_FileExec() and img_FileLoadFunction(), but definitions must be in RAM
    
    // IMediaPanel4 1.0 generated 08.06.2021 10:29:27
    flash_FunctionCall(FLASHBANK_5, Fgfx_MediaPanel, 0, vIMediaPanel4RAM, IIMediaPanel4, 15, 0) ; // Can also use img_FileExec() and img_FileLoadFunction(), but definitions must be in RAM
    
    // Statictext3 1.0 generated 08.06.2021 10:29:27
    img_Show(hndl,iStatictext3) ;
    
    // ISwitch1 1.0 generated 08.06.2021 10:29:27
    //gfx_Switch(state, vISwitch1RAM, IISwitch1) ;
    gfx_Switch(1, vISwitch1RAM, IISwitch1) ;
    
    // IButtonD1 1.0 generated 08.06.2021 10:29:27
    //gfx_Button4(state, vIButtonD1RAM, IIButtonD1) ;
    gfx_Button4(1, vIButtonD1RAM, IIButtonD1) ;
    
    // Strings1 1.1 generated 08.06.2021 10:29:27
    txt_FontID(hFont1) ; // Font index correct at time of code generation
    txt_FGcolour(WHITE) ;
    txt_BGcolour(0xBDD7) ;
    gfx_MoveTo(212 , 88) ;
    //PrintDiskUnicode(hstrings, Strings1StartH, Strings1StartL, Strings1Size, i) ; // where i is Message 0 - Strings1Count-1
    PrintDiskUnicode(hstrings, Strings1StartH, Strings1StartL, Strings1Size, 3) ; // where i is Message 0 - Strings1Count-1
    
    // IMediaButton1 1.0 generated 08.06.2021 12:05:31
    flash_FunctionCall(FLASHBANK_5, Fgfx_MediaButton, 1, vIMediaButton1RAM, IIMediaButton1, 17, 0x40) ; // Where state is 0 or 1, requires a minimum #STACK of 280
    // IMediaButton2 1.0 generated 08.06.2021 10:29:26
    flash_FunctionCall(FLASHBANK_5, Fgfx_MediaButton, 1, vIMediaButton2RAM, IIMediaButton2, 17, 0x40) ; // Where state is 0 or 1, requires a minimum #STACK of 280
    
    
    touch_Set(TOUCH_ENABLE);
    repeat
    _touch_state := touch_Get(TOUCH_STATUS); // get touchscreen status
    if(_touch_state == TOUCH_PRESSED)
    putstr("ID_pressed");
    _touched_widget_number := widget_Touched(handle, ALL); //scan widget list, looking for a touch
    if(_touched_widget_number != -1)
    switch (_touched_widget_number)
    case F1_LEFT:
    _return_value := FORM_TEMPS;
    putstr("TestTemp");
    goto exit;
    break;
    case F1_RIGHT:
    _return_value := FORM_TEMPS;
    putstr("TestTemp");
    goto exit;
    break;
    case F1_READ:
    requestRFID();
    break;
    case F1_OPEN:
    break;
    endswitch
    endif
    endif
    forever
    
    exit:
    pause(200);
    
    widget_ClearAttributes(handle, F1_LEFT, WIDGET_F_TOUCH_ENABLE); // Enable touch for switch
    widget_ClearAttributes(handle, F1_RIGHT, WIDGET_F_TOUCH_ENABLE); // Enable touch for switch
    
    return _return_value;
    
    endfunc
    
    func Form_Temps()
    var _touch_state, _touched_widget_number, _return_value;
    
    widget_SetAttributes(handle, F2_LEFT, WIDGET_F_TOUCH_ENABLE); // Enable touch for switch
    widget_SetAttributes(handle, F2_RIGHT, WIDGET_F_TOUCH_ENABLE); // Enable touch for switch
    
    // Form2 1.1 generated 08.06.2021 12:07:28
    gfx_BGcolour(0xCE79) ;
    gfx_Cls() ;
    
    // IMediaPanel3 1.0 generated 08.06.2021 12:07:28
    flash_FunctionCall(FLASHBANK_5, Fgfx_MediaPanel, 0, vIMediaPanel3RAM, IIMediaPanel3, 15, 0) ; // Can also use img_FileExec() and img_FileLoadFunction(), but definitions must be in RAM
    
    // IMediaPanel5 1.0 generated 08.06.2021 12:07:28
    flash_FunctionCall(FLASHBANK_5, Fgfx_MediaPanel, 0, vIMediaPanel5RAM, IIMediaPanel5, 15, 0) ; // Can also use img_FileExec() and img_FileLoadFunction(), but definitions must be in RAM
    
    // IMediaPanel6 1.0 generated 08.06.2021 12:07:28
    flash_FunctionCall(FLASHBANK_5, Fgfx_MediaPanel, 0, vIMediaPanel6RAM, IIMediaPanel6, 15, 0) ; // Can also use img_FileExec() and img_FileLoadFunction(), but definitions must be in RAM
    
    // IMediaPanel7 1.0 generated 08.06.2021 12:07:28
    flash_FunctionCall(FLASHBANK_5, Fgfx_MediaPanel, 0, vIMediaPanel7RAM, IIMediaPanel7, 15, 0) ; // Can also use img_FileExec() and img_FileLoadFunction(), but definitions must be in RAM
    
    // IMediaPanel8 1.0 generated 08.06.2021 12:07:29
    flash_FunctionCall(FLASHBANK_5, Fgfx_MediaPanel, 0, vIMediaPanel8RAM, IIMediaPanel8, 15, 0) ; // Can also use img_FileExec() and img_FileLoadFunction(), but definitions must be in RAM
    
    // IMediaPanel9 1.0 generated 08.06.2021 12:07:29
    flash_FunctionCall(FLASHBANK_5, Fgfx_MediaPanel, 0, vIMediaPanel9RAM, IIMediaPanel9, 15, 0) ; // Can also use img_FileExec() and img_FileLoadFunction(), but definitions must be in RAM
    
    // Statictext5 1.0 generated 08.06.2021 12:07:29
    img_Show(hndl,iStatictext5) ;
    
    // Statictext6 1.0 generated 08.06.2021 12:07:29
    img_Show(hndl,iStatictext6) ;
    
    // Statictext7 1.0 generated 08.06.2021 12:07:29
    img_Show(hndl,iStatictext7) ;
    
    // Statictext8 1.0 generated 08.06.2021 12:07:29
    img_Show(hndl,iStatictext8) ;
    
    // Statictext9 1.0 generated 08.06.2021 12:07:29
    img_Show(hndl,iStatictext9) ;
    
    // Statictext4 1.0 generated 08.06.2021 12:07:28
    img_Show(hndl,iStatictext4) ;
    
    // ILedDigits2 1.0 generated 08.06.2021 12:07:29
    gfx_LedDigits(temp_manifold, vILedDigits2RAM, IILedDigits2) ;
    
    // ILedDigits1 1.0 generated 08.06.2021 12:07:29
    gfx_LedDigits(temp_prisma, vILedDigits1RAM, IILedDigits1) ;
    
    // ILedDigits3 1.0 generated 08.06.2021 12:07:30
    gfx_LedDigits(temp_dehumidifier, vILedDigits3RAM, IILedDigits3) ;
    
    // ILedDigits4 1.0 generated 08.06.2021 12:07:30
    gfx_LedDigits(temp_loops, vILedDigits4RAM, IILedDigits4) ;
    
    // ILedDigits5 1.0 generated 08.06.2021 12:07:30
    gfx_LedDigits(humidity_sensor, vILedDigits5RAM, IILedDigits5) ;
    
    // IMediaButton3 1.0 generated 08.06.2021 12:07:28
    flash_FunctionCall(FLASHBANK_5, Fgfx_MediaButton, 1, vIMediaButton3RAM, IIMediaButton3, 17, 0x40) ; // Where state is 0 or 1, requires a minimum #STACK of 280
    
    // IMediaButton4 1.0 generated 08.06.2021 12:07:28
    flash_FunctionCall(FLASHBANK_5, Fgfx_MediaButton, 1, vIMediaButton4RAM, IIMediaButton4, 17, 0x40) ; // Where state is 0 or 1, requires a minimum #STACK of 280
    
    
    touch_Set(TOUCH_ENABLE);
    repeat
    _touch_state := touch_Get(TOUCH_STATUS); // get touchscreen status
    if(_touch_state == TOUCH_PRESSED)
    putstr("Temp_pressed");
    _touched_widget_number := widget_Touched(handle, ALL); //scan widget list, looking for a touch
    if(_touched_widget_number != -1)
    switch (_touched_widget_number)
    case F2_LEFT:
    _return_value := FORM_RFID;
    putstr("TestTemp");
    goto exit;
    break;
    case F2_RIGHT:
    _return_value := FORM_RFID;
    putstr("TestTemp");
    goto exit;
    break;
    endswitch
    endif
    endif
    forever
    
    exit:
    pause(200);
    
    widget_ClearAttributes(handle, F2_LEFT, WIDGET_F_TOUCH_ENABLE); // Enable touch for switch
    widget_ClearAttributes(handle, F2_RIGHT, WIDGET_F_TOUCH_ENABLE); // Enable touch for switch
    //img_SetAttributes(hndl, Form1, I_TOUCH_DISABLE);
    
    return _return_value;
    
    endfunc

  • #2
    Hi,

    To understand the issue better, can you share your project with us?

    To ensure that you will send it completely, you can follow this article: How can I share my projects?

    Best regards.

    Comment


    • #3
      Hello Ivan,

      sure I can do that. Please have a look at the attachment.

      Cheers

      20210329-00-Prüfstand.zip

      Comment


      • #4
        Hi,

        You need to create a internal/inherent handle for the applicable widgets. First, create a global variable (ex. ihndl).

        Code:
        var ihndl;
        This variable will serve as the handler for all internal and inherent widgets. To initialize this, you need use the function widget_Create.

        Code:
        ihndl := widget_Create(NUM_OF_INT_INH_WIDGETS);
        You will then need to add the widgets to the handler. For example:

        Code:
        ihndl := widget_Add(ihndl, X, widgetRAM);
        // X is the index which specifies the index you want to use for the widget
        // widgetRAM is the array generated by Paste Code for the internal/inherent widget
        Both widget_Create and widget_Add only needs to be performed once in your setup.

        After this, you need to ensure that when you are drawing a form, you have to clear the INITIALISED flag from the internal/inherent widget before drawing the widget.

        This can be done using:

        Code:
        ihndl := widget_ClearAttributes(ihndl, X, WIDGET_F_INITIALISED);
        // X is the index which specifies the index you used for the widget
        This lets the code know that when you draw the widget, it will draw it as a whole since it needs to be reinitialized.

        You can refer to the project attached.

        Best Regards.
        Attached Files

        Comment


        • #5
          Dear Ivan,

          thank you very much.

          Code:
          ihndl := widget_ClearAttributes(ihndl, X, WIDGET_F_INITIALISED);
          did it for me. Now everything is shown correctly.

          Best regards

          Comment

          Working...
          X