Inky Phat as a clock?


#1

hey all,

looking to have the inkyphat display the time under certain circumstances, but I’m not sure how to make that work, would something like

inkyphat.text( show.time) work?


#2

In Python?
On my sense hat I use

import time, datetime

dateString = "%A %B %-d %-I:%M %p"
msg = "It is %s" % (datetime.datetime.now().strftime(dateString))
sense.show_message(msg, scroll_speed=s, text_colour=(255, 255, 255))

http://strftime.org/


#3

Good lord that’s way more complicated than I thought it would be XD


#4

That shows more than just the time. It shows
Day of the week %A,
Date month %B and day %-d
Time 12h %-I:%M
AM PM %p

And that’s if you using python. You didn’t really give much info on how your using the Inky pHat.
Some of it has to do if you want it to show Mon of Monday, Dec or December, etc.

If all you want is the time, in my case its %-I:%M %p
An example of what the shows is “1:30 PM”

The msg = and sense.show lines are specific to my sense hat. It may be a lot easier on the inky pHat. I don’t know, I don’t own one.


#5

my bad,

yes in python, I only need the time. I am setting up a litle script so that when a specific temperature is achieved through the BME680, it will display the time that temperature was achieved on the eink display, and only update the time when that temperature is achieved again :)

Thanks for the help, Python is still very new to me, using this project to learn it essentially


#6

In my case its a weather clock. My Sense Hat shows a repeating scrolling message
Example
It is Tuesday December 19 1035 AM and 22c with 56% Humidity - Barometric Pressure is Mid Range @ 1005mb - UV index is low at 1.
The various readings are done in real time measured each time the message scrolls.
Doing stuff like above is how I learned Python.


#7

cool! Thanks for sharing, glad to know i am on the right path :)


#8

When I’m doing something in python I usually try to start out simple. Get the basic function working, then tweak it to add extra functions. Then you know what broke it. ;)

In idle ,my preferred editor, there is a “check module” option under Run. That will flag issues for you like missing indents. Which IMHO, is one of the most frustrating things in python. Try to use tab instead of space bar. If that doesn’t flag anything I do the actual “Run Module” option.