cancel
Showing results for 
Search instead for 
Did you mean: 

How to update a flexbutton wildcard text nested within a custom container

jim239955_st
Associate II

I have created a custom container available in multiple screens that can be used for adjusting a selected menu value.

Each screen has a number of selectable parameters and when the parameter is selected a custom container becomes visible containing a flexbutton bearing the selected parameter title along with a scroll wheel to adjust the value, and a simple text box containing a wildcard text to show the units of the parameter (like ppm for instance) . The flexbutton is used to lock in the adjusted value and make the container invisible again.

I have created a routine called 'setText' within 'customcontainer1.cpp' which sets the two wildcard texts depending upon the index of the parameter selected in the main screens.

I know this routine works if i call it when the screen is first accessed I.E when 'customcontainer11' is created when i first access screen 1 or 'customcontainer12' is created when i first access screen 2. I checked this by temporarily putting the 'setText' inside the routine 'CustomContainer1::CustomContainer1()' routine.

My issue is that when i select a parameter in a certain screen the container always pops up with the originally set default text values. It does not access the 'setText routine or if it does then it does not affect the content of the wildcards.

In my ScreenView1.cpp module when i select a parameter that needs to be changed an index and a flag is set (both global variables) and then on the next tick my 'cursorcheck' routine (which runs every tick) checks the flags and if required calls the following:

customContainer11.setText();

customContainer11.setVisible(true);

customContainer11.invalidate();

On the next tick the container becomes visible but it seems if it actually accesses and runs the setText routine it does not affect the content of the wildcards.

What am I doing wrong? Should i be nesting the setText routine within another routine that is accessed to redraw the container to make it visible when the 'invalidate' command is run? if so what is that routine?

any advice would be much appreciated.

4 REPLIES 4
Osman SOYKURT
ST Employee

Hello jim239955_st,

Can you show some screenshots of your application and how it behaves, and also how you want it behaves.

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX

sure, I have had to clip the screenshot as it would otherwise show some commercially sensitive information but here is a screen shot showing the flexbutton to select a parameter (in this case 'Target'), and a second screen shot to show the adjustment container when it is made visible over the top.

0693W00000WKznlQAD.png

0693W00000WKzp3QAD.pngthe problem is that 'parameter' and 'units' are the default text in the wildcard. It should show 'Target' and 'ppm'

Osman SOYKURT
ST Employee

Hello jim239955_st,

Ok, I understand. Can you show the code of your setText() function of your container? Also, how do you save you data? Are they static instances in your view screen or do you have them in a model ? (cf tutorial 3 & MVP Design pattern documentation)

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX
jim239955_st
Associate II

Hi Osman and thank you for getting back to me.

Most of my variables, arrays and parameters are defined and initialised as globals in Main.C before RTOS is activated. It is my understanding that they are then accessible and able to be ,modified from anywhere in the program?

This is the section in screen1view.cpp where either flexbutton 7 or 8 are selected for the two adjustable parameters on that page. A global variable 'ParamAdj' is set as 1 or 2 respectively. This variable is accessed in screen1view.cpp as an external variable:

void Screen1View::flexButtonCallbackHandler(const touchgfx::AbstractButtonContainer& src)

{

  if (&src == &flexButton6)

  {

    //Interaction8

    //When flexButton6 clicked change screen to Screen2

    //Go to Screen2 with no screen transition

    application().gotoScreen2ScreenNoTransition();

  }

  else if (&src == &flexButton1)

  {

    //Interaction2

    //When flexButton1 clicked call virtual function

    //Call function1

    function1();

  }

  else if (&src == &flexButton7)

  {

    //Interaction9

    //When flexButton7 clicked show customContainer21

    //Show customContainer21

   ParamAdj=1;

   AdjustScreen=0;

  }

  else if (&src == &flexButton8)

  {

    //Interaction10

    //When flexButton8 clicked show customContainer21

    //Show customContainer21

   ParamAdj=2;

   AdjustScreen=0;

  }

  else if (&src == &flexButton5)

  {

    //Interaction7

    //When flexButton5 clicked change screen to Screen18

    //Go to Screen18 with no screen transition

    application().gotoScreen18ScreenNoTransition();

  }

}

void Screen1View::cursorcheck()

{

if (AdjustScreen==1){

AdjustScreen=0;

customContainer21.setVisible(false);

customContainer21.invalidate();

}

if (ParamAdj!=0){

customContainer21.setText();

customContainer21.setVisible(true);

customContainer21.invalidate();

}

}

At each Tick the routine 'cursorcheck' runs from the model and propagates through to screen1view.cpp. It is supposed to recognise that ParamAdj has been set to 1 or 2 and then run the settext routine before invalidating the custom container to make it visible on the next tick.

This is the code in CustomContainer2.cpp:

void CustomContainer2::setText()

{

  switch (ParamAdj){

   case 0:

   Unicode::strncpy(flexButton1Buffer, "not set", FLEXBUTTON1_SIZE);

   flexButton1.setWildcardTextBuffer(flexButton1Buffer);

   Unicode::strncpy(textArea1Buffer, "tst", TEXTAREA1_SIZE);

   break;

   case 1:

   Unicode::strncpy(flexButton1Buffer, "TARGET", FLEXBUTTON1_SIZE);

   flexButton1.setWildcardTextBuffer(flexButton1Buffer);

   Unicode::strncpy(textArea1Buffer, "ppm", TEXTAREA1_SIZE);

   scrollWheel1.animateToItem((target*100), 0);

   break;

   case 2:

   Unicode::strncpy(flexButton1Buffer, "FEEDBACK READING", FLEXBUTTON1_SIZE);

   flexButton1.setWildcardTextBuffer(flexButton1Buffer);

   Unicode::strncpy(textArea1Buffer, "ppm", TEXTAREA1_SIZE);

   scrollWheel1.animateToItem((feedback*100), 0);

   break;

   }

   flexButton1.invalidate();

   textArea1.resizeToCurrentText();

   textArea1.invalidate();

   scrollWheel1.invalidate();

}

void CustomContainer2::scrollWheel1UpdateItem(TextContainer& item, int16_t itemIndex)

  {

    // Override and implement this function in CustomContainer2

item.updateText(itemIndex);

  }

void CustomContainer2::scrollWheel1UpdateCenterItem(TextCenterContainer& item, int16_t itemIndex)

  {

    // Override and implement this function in CustomContainer2

item.updateText(itemIndex);

  }

Because the variables i use are global and are declared as Extern in both screen1view.cpp AND Customcontainer2.cpp I am assuming that the values will propagate through. Is this correct?