cancel
Showing results for 
Search instead for 
Did you mean: 

update rtc sourced digital clock in custom container above multiple screens

Loppi
Associate III

Hi,

I am working on a project where I need to add an info bar above multiple screens containing a digital clock.The digital clock is sourced by the rtc of the mcu. For one screen I read the current time and date with HAL_RTC_GetTime/HAL_RTC_GetDate inside the model and send it through the MVP. In future I plan to use the xQueueSend/Receive.

From what I understand I can make my own container containing all parts of the info bar. But I struggle to follow the concept of updating the parts in the container. How do I include the code to update the container over multiple screens, is there a example for this?

1 ACCEPTED SOLUTION

Accepted Solutions
Loppi
Associate III

I leave this here for anybody who's got the same question.

My temporary solution ist to go the regular way through the MVP structure. It is only necessary to call one function in the Model/ModelListener which is shared by the differen Presenters. The Presenter itself has to call corresponding function of the View. You can simplify this by copying the same function into all Views. The same goes for the function of the custom container which will be called from the differen screen views, e.g. mainView function calls infoBar1.updateDigitalClock. The latter is a custom function inside the custom container. If you are not refreshing the custom container data on every tick you might want to store whatever data in a static variable. This way the default data won't be shown on screen change. You probably can archieve the same result by having a boolean flag which controlls initialization of the screen.

static uint16_t iconID = BITMAP_PBAT0_2_ID;
static 	RTC_TimeTypeDef rtcTimeStorage = { 0 };
 
void infoBar::initialize()
{
	// initialize battery icon with pre-saved icon index
	batteryIcon.setBitmap(iconID);
	// initialize digital clock with pre-saved values after screenchange
	digitalClock1.setTime24Hour(rtcTimeStorage.Hours, rtcTimeStorage.Minutes, rtcTimeStorage.Seconds);
	infoBarBase::initialize();
}

While the whole procedure works just fine, it is a huge effort on big projects. There are other solutions which require post modification of generated files I reject to do. A ST engineer who described this process also said it will be added to TouchGFX designer in the future. I hope that it will be implemented soon.

View solution in original post

1 REPLY 1
Loppi
Associate III

I leave this here for anybody who's got the same question.

My temporary solution ist to go the regular way through the MVP structure. It is only necessary to call one function in the Model/ModelListener which is shared by the differen Presenters. The Presenter itself has to call corresponding function of the View. You can simplify this by copying the same function into all Views. The same goes for the function of the custom container which will be called from the differen screen views, e.g. mainView function calls infoBar1.updateDigitalClock. The latter is a custom function inside the custom container. If you are not refreshing the custom container data on every tick you might want to store whatever data in a static variable. This way the default data won't be shown on screen change. You probably can archieve the same result by having a boolean flag which controlls initialization of the screen.

static uint16_t iconID = BITMAP_PBAT0_2_ID;
static 	RTC_TimeTypeDef rtcTimeStorage = { 0 };
 
void infoBar::initialize()
{
	// initialize battery icon with pre-saved icon index
	batteryIcon.setBitmap(iconID);
	// initialize digital clock with pre-saved values after screenchange
	digitalClock1.setTime24Hour(rtcTimeStorage.Hours, rtcTimeStorage.Minutes, rtcTimeStorage.Seconds);
	infoBarBase::initialize();
}

While the whole procedure works just fine, it is a huge effort on big projects. There are other solutions which require post modification of generated files I reject to do. A ST engineer who described this process also said it will be added to TouchGFX designer in the future. I hope that it will be implemented soon.