Micro Dot pHAT programming help

Hi there, I need a little bit of help in programming a Micro Dot pHAT. I want it to show me the number of days between a particularly date and the current day, and of course, to be able to update by itself, working like a sort of a clock, counting days.

My knowledge in Python is for from being enough to achieve that, even this is probably a beginner level. So, this is my progress till now:

This part of the script will calculate the number of days I need to find and it’s working:

import datetime
today = datetime.date.today()
someday = datetime.date(1978, 10, 29)
diff = today - someday
diff.days

Of course, “diff.days” will bing me the result I need, but I don’t know how to push this to be shown on my Micro Dot pHAT display. Probably it must be something like this “write_string(diff.days, kerning=False)”, but It isn’t working.

I imagine a full script must look like this:

import datetime
from microdotphat import write_string, set_decimal, clear, show
today = datetime.date.today()
someday = datetime.date(1978, 10, 29)
diff = today - someday
diff.days
write_string(diff.days, kerning=False)
show()

Of course I still need to find a way to update it by itself.
Any ideea will be helpful.
Thank you,
Alex

It should just be a matter of formatting your variable as a string.

See if the following makes sense:
https://docs.python.org/2/library/string.html#format-examples

… but, time permitting I’ll try to post some code, or even make an example in the repo that does what you want, or close enough.

HI RogueM,
Thank you for this quick reply. I checked the link and of course it is a bit “old Chinese” for me. It would be helpful if I could benefit from your support again, of course when you’ll have the time.
Thank you,
Alex

It should just be a matter of changing the line above to write_string(str(diff.days), kerning=False), I reckon.

Hi Sandy, that’s great, thank you a lot, it’s working! :)