2020-12-16 06:05 AM
I have an application with two separate screens. I have declared completely analogous presenter, view, etc. files for each, understanding that the model points to the current presenter to update the current view/screen. All functions and variables appear where they should in the hpp and base class files for each view. The trigger for all updates is the system tick, handled in the model file; the systick just checks for RTOS messages in separate queues and requests screen updates accordingly. And, the model file "knows" about all boxes on all pages. Everything on screen 1 (the home screen) works fine, but nothing on screen 2 will update. So, I am looking for some example of how to do this. Clearly, I am missing something, but I can't see it. I am running GFX v4.14.0 under RTOS, Cube IDE v1.5.0. Thanks
Solved! Go to Solution.
2020-12-16 02:37 PM
Does it receive the message2? If it does, then check the presenter and screenview2.hpp and .cpp once more.
2020-12-16 08:37 AM
Try show example , how you update screen 1/2 now.
2020-12-16 12:30 PM
Here is where I have found the chain to fail. In this test program I wrote, the first screen updates perfectly in the model tick function, shown below. The second screen's files have been set up identically to the first one's, with only the update function name being changed. Maybe I misunderstand naming or calling convention, but you can see from this snippet what I am doing. Again, the first bit of code to process message queue 1 works, but the second one processing message queue 2 does not:
void Model::tick()
{
unsigned int counter;
//if a new message has arrived in the queue from somewhere (in this case, the
//periodic update task in main()), trigger the start of a screen update
if(xQueueReceive(messageQS1, &counter, 0) == pdTRUE){
//send the data received in the queue on to be processed
//and ultimately passed to the View 1 screen for displaying
modelListener->setNewCounter1Value(counter);
}
if(xQueueReceive(messageQS2, &counter, 0) == pdTRUE){
//send the data received in the queue on to be processed
//and ultimately passed to the View 2 screen for displaying
modelListener->setNewCounter2Value(counter);
}
}
And, here is the code for the model listener, showing the virtual functions:
class ModelListener
{
public:
ModelListener() : model(0) {}
virtual ~ModelListener() {}
void bind(Model* m)
{
model = m;
}
virtual void setNewCounter1Value(unsigned int){}
virtual void setNewCounter2Value(unsigned int){}
protected:
Model* model;
};
2020-12-16 02:37 PM
Does it receive the message2? If it does, then check the presenter and screenview2.hpp and .cpp once more.
2020-12-17 06:45 AM
Good suggestion, thank you. I have traced the path all the way through the view layer, and for sure I am getting to that point. I can watch an LED blink when the call to the view update function is made, so we're getting there. I checked the text area names as defined in the screen2 base class, and everything matches... see the snippets below. The only curious thing I have noted here and elsewhere is that sometimes the names (like my "textArea2") do not show up in the auto-complete list, so calls like textArea2.invalidate() are not color highlighted (but the analogous "textArea1" lines are...) Whether this is significant, or indicates a tool issue, I don't know, but everything builds all the same. Here is the code where I verified the view update is being triggered:
//send data to the screen
void Screen2View::updateCounter2(unsigned int newValue){
Unicode::snprintf(textArea2Buffer, TEXTAREA2_SIZE, "%i", newValue); //these variables names check out...
textArea2.invalidate(); //code is not recognized by auto-suggest, but otherwise no warnings or errors
BSP_LED_Toggle(LED_GREEN); //light blinks okay...
}
Here's the relevant section of the screen2 base class, showing that the text box area is properly defined:
:
:
/*
* Member Declarations
*/
touchgfx::TiledImage tiledImage1;
touchgfx::Button button1;
touchgfx::TextAreaWithOneWildcard textArea2;
touchgfx::TextArea textTitle2;
/*
* Wildcard Buffers
*/
static const uint16_t TEXTAREA2_SIZE = 4;
touchgfx::Unicode::UnicodeChar textArea2Buffer[TEXTAREA2_SIZE];
:
:
Everything between screens 1 and 2 is completely symmetric, so I can't figure what's different that keeps the one from updating. Any examples to examine where someone is actually doing this would be appreciated. I'm using a 746 Disco board by the way.
2020-12-17 07:59 AM
Update -- I can even change the visibility of the text box, so that it blinks(!) but cannot change the text itself. So, to boil it down: does anyone know what might cause the following statements to not work in the update view function? Again, the names check out, and the exact same statements work for another text box that happens to be on another screen, but is called by another name.
Unicode::snprintf(textArea2Buffer, TEXTAREA2_SIZE, "%i", newValue);
textArea2.invalidate();
2020-12-17 08:16 AM
snprintf alone i mean do nothing with screen.
I use
Unicode::snprintf(textAreaVerBuffer, TEXTAREAVER_SIZE, "1.%d", VERSION);
textAreaVer.setWildcard(textAreaVerBuffer);
textAreaVer.invalidate();
textAreaVer.resizeToCurrentText();
textAreaVer.invalidate();
maybe next method too need call to allign text... , but setWildcard is required.
2020-12-17 09:45 AM
Probably a long shot but I think this "%i" should be "%u" as you are passing an unsigned integer.
Unicode::snprintf(textArea2Buffer, TEXTAREA2_SIZE, "%i", newValue);
Maybe double and triple check your TouchGFX settings..wildcards etc.
2020-12-17 11:25 AM
Thanks guys. I have it working now. I found that the parameter being passed was being reset in such a way that it appeared not to change its value, so the logic was good, and I just had a bad data byte masking the issue. As for the strange way in which the system doesn't recognize the variables in auto-suggest/complete (working within Cube IDE), I found that you have to remove the project from the workspace, then reload it in order for newly added screen objects to be registered. Appreciate the help --