I started writing some code in Python that would draw three arcs to represent the current time (hours, minutes and seconds) and present them on the Pico explorer board’s display. I got it working but it ran too slow so I’ve ported the code to C++ which runs about 100x faster.
The only thing I can’t figure out how to do is to get the actual clock time. I understand that this will be the time from power-on and that is ok. In Python I do:
utime.gmtime(utime.time())
but I’m having trouble figuring the equivalent in C++. I have figured out some C++ code but it just always returns 23:59.59. I’m hoping someone has had to do this and could put me out of my misery please.
Many thanks for the info. The forum post you linked to led to me finding the answer and also I’ll be coming back to it to set the time directly from the host computer at some later stage of the development.
It seems that pico-examples already had an RTC example. Getting it to work from inside the pimoroni-examples (so I could access the Explorer display) proved difficult mainly because of my lack of knowledge of C++, libraries, linking etc.
In the end I created a brand new project and managed (by lots of googling and a fair bit of trial and error) to get both the RTC and the explorer display to work. It is a lot harder getting this to work in C++ than Python and, at the moment, I have to do a lot of unplugging of the USB cable which I didn’t have to do so much of with Python. I’m unplugging from the host end so as to protect my Pico USB port. I’ll look into getting debugging working at some point.
Here is a screenshot of the result. Lots of things to fix still but at some point I will put it on git hub: