cancel
Showing results for 
Search instead for 
Did you mean: 

Colon in the digital clock

RMoha.2
Associate II

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

5 REPLIES 5
Alexandre RENOUX
Principal

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

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

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
Principal

Hello,

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

/Alexandre

Thanks. That seems more simplifying the issue, just using textAreas instead of the digital clock widget, great thinking!