Running the Raspberry-Pi BCD clock on RISC OS

In a fit of “I wonder how hard that would be?” I had a look into how to do GPIO pin manipulation under RISC OS, when running on a Raspberry-Pi. It turns out that it is blissfully easy for anyone familiar with RISC OS SWIs, so you can do it in BASIC or any other language you like! There’s no requirement to add any new libraries or modules – the support comes as standard with RISC OS for the Pi.

In essence, this will set a GPIO pin to be an output:

SYS "GPIO_WriteMode",<GPIO pin number>,1

And then you switch the pin on or off by putting a 1 or 0 into <value>, like this:

SYS "GPIO_WriteData",<GPIO pin number>,<value>

It’s that simple.

With this in mind, I have written a quick BASIC demonstration which drives my binary-coded-decimal clock shield under RISC OS. It’s supposed to be simple and easy to read rather than particularly efficient, and I’ve tried to make the PROCs comparable to the functions I wrote in the C version for Linux.

Tokenised BBC BASIC file: Download (3KB)
Textfile for reading online: Download (3KB)

I also remembered that I’d written a binary-coded-decimal iconbar clock for RISC OS many years ago (2005!) so I quickly shoehorned the GPIO code into it so I can drive the shield whilst still continuing to use RISC OS. I’ll make a new archive and upload it as soon as I can find my copy of SparkFS, but in the meantime, here’s a photo of the real clock, the iconbar clock, and the RISC OS !Alarm app running together:

Because you can never have too many clocks …

It’s been a long time since I wrote BASIC in RISC OS. Just for the fun of it, too. I hadn’t realised how much I have missed it. RISC OS is truly my “comfort” operating system. And I’m not embarrassed to admit that I have such a thing!

Click here to visit the BCD-clock project page.

Click here to purchase the kit on Tindie.


Comments are closed.