cancel
Showing results for 
Search instead for 
Did you mean: 

TextArea with wildcard Array

LL-DG1000
Associate

Hi,

I am currently working on a project to imitate a level display for an elevator. Using TouchGFX, i have 10 buttons with values 1-10 and once a button has been pressed it will add said value to a textbox with a wildcard on the screen. once that is filled the next button to be pressed will add a value to the following textbox.

is there anyway of adding these TextAreaWithOneWildcard to an array or vector that ill allow me to cycle through each text area when printing each value to the screen.

This is what i am thinking of doing for the printing section, where selections[] would be an array or vector that would hold the references to the text area such that as "i" increases, the program will print a desired value to correct text area.

 

for (int i=0; i < 6; i++)

{

Unicode::snprintf(selections[i]Buffer, selections[i]_SIZE, "%s", floor[i];

selections[i].invalidate()

}

 

 

 

1 REPLY 1
Karakala
Associate

I had the same problem and I found the solution. So I'm posting it in case someone have the same problematic.

We want to create an array which contains some wildcard buffers (called textAreaBuffer by default in TouchGFX). We must in fact create a dynamic array of pointers of pointers. Here is the code to do so :

 

touchgfx::Unicode::UnicodeChar** text_AreaBuffer_array {new touchgfx::Unicode::UnicodeChar* [7]};
text_AreaBuffer_array[0] = textArea1Buffer;
text_AreaBuffer_array[1] = textArea2Buffer;
text_AreaBuffer_array[2] = textArea3Buffer;
text_AreaBuffer_array[3] = textArea4Buffer;
text_AreaBuffer_array[4] = textArea5Buffer;
text_AreaBuffer_array[5] = textArea6Buffer;
text_AreaBuffer_array[6] = textArea7Buffer;

 

 

In my code, I had 7 wildcard buffers to modify. I didn't find a way to put them in my text_AreaBuffer_array other than manually like so. Then if you want to display, let's say the index of the wildcard in text_AreaBuffer_array, or whatever, you can do this :

 

for(uint8_t index = 0; index <= 6; index++){
    Unicode::snprintf(text_AreaBuffer_array[index], TEXTAREA_SIZE, "%d", index);
    textArea_array[index]->resizeToCurrentText();
    textArea_array[index]->invalidate();       
}

 

In my case, all the wildcards had the same buffer size (= TEXTAREA_SIZE) .