Skip to main content
RMoha.2
Associate III
July 21, 2020
Question

Colon in the digital clock

  • July 21, 2020
  • 5 replies
  • 2198 views

Is the colon between the hours and minutes in the digital clock accessible? Is there a way to make it blink at the "seconds" ?

This topic has been closed for replies.

5 replies

Alexandre RENOUX
Visitor II
July 22, 2020

Hello,

Yes adding a colon is doable.

Just copy the digitalClock.cpp and .hpp in your gui folder (respectively in src/common and include/gui/common).

Then modify the updateClock() function in digitalClock.cpp as follows:

void DigitalClock::updateClock()
{
 // ....
 else if (displayMode == DISPLAY_24_HOUR)
 {
 const char* format = useLeadingZeroForHourIndicator ? "%02d;%02d;%02d" : "%d;%02d;%02d";
 Unicode::snprintf(buffer, BUFFER_SIZE, format, currentHour, currentMinute, currentSecond);
 }
 text.invalidate();
}
}

What do you mean by "blink at the seconds" ?

/Alexandre

RMoha.2
RMoha.2Author
Associate III
July 22, 2020

please see attached, the colon between the hours and minutes blinks every second, a kind of replacement for the displaying the seconds.

Alexandre RENOUX
Visitor II
July 22, 2020

Hello,

This blinking effect is difficult with the current digital clock widget. The widget has to be changed quite a lot (it might even be better to create your own widget based on the analog clock).

The reason is that right now the widget has only one single text area. But to make something blink, you need to create a dedicated text area that you make disappear and reappear every second.

As a first idea, I would create 3 text areas in a container, one for hours, one for the colon, one for the minutes.

I would modify the hours and minutes accordingly in the handleTickEvent and also make the colon appear and disappear (setVisible(true or false)) in this function as well.

If I have time I will make something.

/Alexandre

Alexandre RENOUX
Visitor II
July 23, 2020

Hello,

Please find enclosed an example of DigitalClock with blinking colon using a Custom Container.

/Alexandre