Display Time with ":" Always in the Same Location #2135
-
I'm displaying time in the upper right corner of my screen and hours less than 10 are single digit (no leading zero) so the width of the time will either be 4 characters (i.e. 9:15) or 5 characters (i.e. 10:15). Does anyone have any cleaver ways to display the time so it always appears in the same location? I'm using MR_DATUM for now but I think there still might be a slight shift in location depending on the width of the numbers used? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
There are functions to do this here: Example of use for time in a String type in these lines here: |
Beta Was this translation helpful? Give feedback.
-
That looks like what I was looking for! Plenty of hidden gems yet to be found. I'm a little unclear on why your padding has spaces on both sides of the 88:88 and then you're also adding a space at the end of your time. I got your example to work but the padding doesn't seem to be working correctly because I'm getting some extra pixels on the right of the time sometimes. It looks like the whole time value is written the first time and then it shifts to the left on the next call and stays at the new location after that. I'm sure there's a bug somewhere in my code hiding or maybe I've implemented your logic incorrectly. If you have a moment maybe you could look and see if there's anything obviously wrong here. `void refreshHeader()
}` |
Beta Was this translation helpful? Give feedback.
-
OK, thanks for the explanation. It's been running for a while and it hasn't shifted or left any old pixels. I'll keep an eye on it and see how it goes. Thanks for the help. |
Beta Was this translation helpful? Give feedback.
-
As a follow up I thought I'd post what I found to be my problem. In your rightOffset command you use When I put in some debug statements I could see the Bad coding on my part I guess, perhaps I should always be using |
Beta Was this translation helpful? Give feedback.
There are functions to do this here:
https://github.com/Bodmer/OpenWeather/blob/master/examples/TFT_eSPI_OpenWeather_LittleFS/TFT_eSPI_OpenWeather_LittleFS.ino#L611
Example of use for time in a String type in these lines here:
https://github.com/Bodmer/OpenWeather/blob/master/examples/TFT_eSPI_OpenWeather_LittleFS/TFT_eSPI_OpenWeather_LittleFS.ino#L517-L523