Real Time Clock
The real-time clock is one of the main functions of Xtron Pro. Xtron Pro is composed of the core and the gamepad, the core can work as a watch with a silicone case. With the real-time clock function, you can write basic clock applications.
The real-time clock is a low power clock/date device with a programmable time-of-day alarm and a programmable interupt output. To use of the RTC function, first you should load pxt-xtronpro-rtc extension to MakeCode Arcade, which will add a RTC catogory in the toolbox.
Example
The following example will display the time, date and alarm on the screen.
Click the below link you will go to MakeCode Arcade simulator, which will show the example, then click the Edit Code button to open the Editor to modify or download the example.
Tutorial
Click the below tutorial link to make your own watch application.
API
time
Returns the selected item of the time in decimal number.
stringFormatTime
Get time in string format.
setTime
Set the time of the RTC.
setAlarm
Set the alarm time of the RTC.
onEvent
Run some code when the alarm time is up.
clearAlarmStatus
Clear alarm interrupt status, it is alway used in alarm onEvent function, if you forget to use it, the alarm can only fire once even though in repeat mode.
alarm
Returns the selected item of the alarm time in decimal number.
stringFormatAlarm
Get alarm time in string format.
alarmRepeatMode
Get the alarm repeat mode of the RTC.
Learn More
isAlarmOn
Get the alarm On/Off status.