Alan Chang Posted November 6, 2017 Author Report Posted November 6, 2017 Hi, Thanks for the explanation. I can think a solution to solve this. By the way, how can I let the number flicker when set the clock? Like this. https://www.youtube.com/watch?v=WBdNld6jixE Thanks.
Joel Bodenmann Posted November 6, 2017 Report Posted November 6, 2017 I'm not really sure whether I understand what you want to achieve, but in general: Use a GTimer inside your custom widget to implement things like animations, flashing and stuff like that. But keep in mind that you are only allowed to draw in the one drawing/rendering function. So use the GTimer only to change an internal flag and draw based on the state of the flag.
Alan Chang Posted November 7, 2017 Author Report Posted November 7, 2017 Hi Joel, Thanks for your information. I used one gdispFillStringBox() to display the clock in my widget. The time format is "hr : min : sec". When I set the clock, it will start in hours and then minutes. I want to let the number be ticking. It means now it is setting the "hours". Should I use Gtimer ? If I use Gtimer, do I need to separate the time format? For example, use five gdispFillStringBox() to display on screen. First gdispFillStringBox() is for hours. Second gdispFillStringBox() is for ":". Tried gdispFillStringBox() is for minutes. Fourth gdispFillStringBox() is for ":". Fifth gdispFillStringBox() is for Second. Finally I use Gimer to control each to make ticking style when set the time for hours and minute. Is it correct? Hope you can understand. Thanks.
Joel Bodenmann Posted November 7, 2017 Report Posted November 7, 2017 Hello Alan, Using a GTimer inside the custom widget to make the digits flash is definitely the (only) right approach. You can either separate the gdispFillStringBox() into multiple ones or (and this should be fast), simply use gdispFillArea() to render a rectangle over the portion of the string you want to hide momentarily (to make it look like it flashes). You can use gdispGetStringWidth() to find the correct width of the rectangle.
Alan Chang Posted November 7, 2017 Author Report Posted November 7, 2017 Hi Joel, Very thanks for your information. I have another question. When I set the digits, the value will be increased by press hardware button. At this moment should I stop the Gtimer? And then use gdispGFillString() to cover and show the increased digits. After no change, update new value to clock immediately and re-start Gtimer. Is that ok? Or is there other way to process this display? Thanks.
Joel Bodenmann Posted November 7, 2017 Report Posted November 7, 2017 Whether that is okay or not is something you need to decide yourself. You have to implement the widget the way you like it The GTimer should definitely only run while you're editing the numbers. I'd add API for that, something like: mywidgetHoursSet(GHandle gh, uint8_t value); mywidgetMinutesSet(GHandle gh, uint8_t value); mywidgetHoursFlash(GHandle gh, bool_t enabled); mywidgetMinutesFlash(GHandle gh, bool_t enabled); So when you want to start changing the hours, you'd do this: // Start flashing the hours digits mywidgetHoursFlash(ghWidget, TRUE); // Some code that allows the user to modify the hours while (...) { // ... mywidgetHoursSet(ghWidget, <newValue>); // ... } // Done changing the hours - stop flashing mywidgetHoursFlash(ghWidget, FALSE);
Alan Chang Posted November 15, 2017 Author Report Posted November 15, 2017 Hi Joel, When I use gdispFillString(), there is always ghost picture from last digits. Like this below. It is from "0" to "1". How can I fix it? Thanks.
Joel Bodenmann Posted November 15, 2017 Report Posted November 15, 2017 I'm pretty sure that you're using gdispDrawString() instead of gdispFillString() or gdispFillStringBox(). The gdispDrawString() only renders (changes) the pixel of the actual new string. Everything else remains the same. gdispFillString() and gdispFillStringBox() will clear the pixels not occupied by the string with the corresponding background color. Use those.
Alan Chang Posted November 16, 2017 Author Report Posted November 16, 2017 Hi Joel, I am really using the gdispFillString() to display the time. Here is the part of my code. sprintf((char*)MODEDATABUFFER, "%0.2d",newhours); gdispFillString(u_x+INFO_PADDING_LEFT_X+76, u_y+INFO_PADDING_LEFT_Y+30, MODEDATABUFFER, u_font, colors->text, Orange); sprintf((char*)MODEDATABUFFER, "%0.2d",newminutes); gdispFillString(u_x+INFO_PADDING_LEFT_X+108, u_y+INFO_PADDING_LEFT_Y+30, MODEDATABUFFER, u_font, colors->text, Orange); sprintf((char*)MODEDATABUFFER, "%0.2d",newseconds); gdispFillString(u_x+INFO_PADDING_LEFT_X+145, u_y+INFO_PADDING_LEFT_Y+30, MODEDATABUFFER, u_font, colors->text, Orange); Then I used the gtimer to update the time. However, when I changed to use gdispFillStringBox, every thing is fine. The digits is well on the screen. So now I change gdispFillStringBox to display the time. Thanks.
Joel Bodenmann Posted November 16, 2017 Report Posted November 16, 2017 gdispFillString() does only fill the bounding rectangle of the string. The bounding rectangle depends on the string you are rendering - although you use the same font you'll have different rectangles based on the string. gdispFillStringBox() allows you to specify the size of the box. Hence that is the correct one to use in this case.
Alan Chang Posted November 17, 2017 Author Report Posted November 17, 2017 Hi Joel, Thanks for your explanation. Now I totally use the gdispFillStringBox() to show the string. Unfortunately, I found some issue again. When I change the page to next, there is sometimes remained the ghost picture from last page. I tried to use gdispFillArea() to clear the string box area. It still can not be solved. Here is my code to show page. void modeIconDisplay(uint8_t modePage){ ... gdispFillArea(0, u_y+INFO_PADDING_LEFT_Y, dispwidth, u_fheight, Black); sprintf((char*)MODEICONBUFFER, " Time"); DATAWIDTH = gdispGetStringWidth(MODEICONBUFFER, u_font); gdispFillStringBox(0, u_y+INFO_PADDING_LEFT_Y, dispwidth, u_fheight, MODEICONBUFFER, u_font, colors->text, SkyBlue, justifyLeft); ...} void modeDataDisplay(uint8_t modePage){ ... sprintf((char*)MODEDATATIME_HOURSEBUFFER, "%0.2d",newModeitemInfo.hours); gdispFillStringBox(u_x+INFO_PADDING_LEFT_X+80, u_y+INFO_PADDING_LEFT_Y, 34, u_fheight, MODEDATATIME_HOURSBUFFER, u_font, colors->text, SkyBlue, justifyCenter); printf((char*)MODEDATATIME_MINUTESBUFFER, "%0.2d",newModeitemInfo.minutes); gdispFillStringBox(u_x+INFO_PADDING_LEFT_X+128, u_y+INFO_PADDING_LEFT_Y, 34, u_fheight, MODEDATATIME_MINUTESBUFFER, u_font, colors->text, SkyBlue, justifyCenter); sprintf((char*)MODEDATATIME_SECONDSBUFFER, "%0.2d",newModeitemInfo.seconds); gdispFillStringBox(u_x+INFO_PADDING_LEFT_X+185, u_y+INFO_PADDING_LEFT_Y, 34, u_fheight, MODEDATATIME_SECONDSBUFFER, u_font, colors->text, Silver, justifyCenter); ... } How cam I fix it? Thanks.
Joel Bodenmann Posted November 17, 2017 Report Posted November 17, 2017 Can you please show us pictures of both pages (eg. the previous page as well)?
Alan Chang Posted November 20, 2017 Author Report Posted November 20, 2017 Hi Joel, Here is the two pages. Oil --> Time Actually, this is sometimes happened. The ghost picture of the previous page appeared on next page. Thanks.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now