RTC
What this example shows
Set the time and date on the onboard real-time clock (RTC), then read the time back and show it, refreshing the whole screen every 10 seconds. The panel has no partial update, so the example clears the box behind the time with white before each redraw.
Example code
"""Use the onboard RTC."""
# Include all the required libraries
from inkplate7spectra import Inkplate
import time
# Create Inkplate object
inkplate = Inkplate()
# Initialize the display, needs to be called only once
inkplate.begin()
inkplate.set_text_size(3)
# This is how to set the RTC's time
# Arguments are hour, minute, seconds
inkplate.rtc_set_time(9, 39, 10)
# And this is the date
# Arguments are weekday, day in month, month and year
inkplate.rtc_set_date(2, 9, 2, 2026)
# Box that the time text is drawn into -- must be cleared before each redraw,
# since we redraw the whole screen every tick (this board has no partial-
# refresh support)
box_x, box_y, box_w, box_h = 100, 100, 300, 60
# Infinite loop
while True:
rtc_data = inkplate.rtc_get_data()
hour = rtc_data["hour"]
minute = rtc_data["minute"]
second = rtc_data["second"]
if hour < 10:
hour = "0" + str(hour)
if minute < 10:
minute = "0" + str(minute)
if second < 10:
second = "0" + str(second)
inkplate.fill_rect(box_x, box_y, box_w, box_h, inkplate.WHITE)
inkplate.set_cursor(box_x, box_y)
current_time = str(hour) + ":" + str(minute) + ":" + str(second)
inkplate.print(current_time)
inkplate.display()
# Let's wait 10 seconds
time.sleep(10)
Functions used
Inkplate()returns InkplateCreates the display object from the inkplate7spectra module.
ReturnsThe display object.
inkplate.begin()returns boolSets up the board, the RTC included, and a white frame buffer. Call it once.
ReturnsTrue.
inkplate.set_text_size(s)returns NoneSets the text scale factor, here 3.
ReturnsNothing.
inkplate.rtc_set_time(rtc_hour, rtc_minute, rtc_second)returns NoneWrites the time to the RTC.
ReturnsNothing.
inkplate.rtc_set_date(rtc_weekday, rtc_day, rtc_month, rtc_yr)returns NoneWrites the date to the RTC and marks it as set. rtc_yr is the full year, for example 2026.
ReturnsNothing.
inkplate.rtc_get_data()returns dictReads the RTC.
ReturnsA dictionary with the keys second, minute, hour, day, weekday, month and year (full year).
inkplate.fill_rect(x, y, w, h, c)returns NoneDraws a filled rectangle, here white over the old time.
ReturnsNothing.
inkplate.set_cursor(x, y)returns NoneSets where print() starts.
ReturnsNothing.
inkplate.print(text)returns NoneDraws text at the cursor into the frame buffer.
ReturnsNothing.
inkplate.display(leave_on=False)returns NoneSends the frame buffer to the panel and refreshes it.
ReturnsNothing.
What to expect
The time appears in black at (100, 100), three times the base size, in the form HH:MM:SS, starting at 09:39:10. The screen refreshes with the new time every 10 seconds. Nothing is printed in the shell.
🔗Open the complete example
examples/inkplate7spectra/rtc.py