Skip to main content
Chandler
Associate II
December 16, 2020
Solved

Looking for example of updating two separate screens based on simple systick and RTOS queue messages

  • December 16, 2020
  • 3 replies
  • 1779 views

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

This topic has been closed for replies.
Best answer by HHarj.1

Does it receive the message2? If it does, then check the presenter and screenview2.hpp and .cpp once more.

3 replies

MM..1
Chief III
December 16, 2020

Try show example , how you update screen 1/2 now.

Chandler
ChandlerAuthor
Associate II
December 16, 2020

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;

};

HHarj.1
HHarj.1Best answer
Associate III
December 16, 2020

Does it receive the message2? If it does, then check the presenter and screenview2.hpp and .cpp once more.

Chandler
ChandlerAuthor
Associate II
December 17, 2020

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();

MM..1
Chief III
December 17, 2020

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.

Chandler
ChandlerAuthor
Associate II
December 17, 2020

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 --