August 2022
Intermediate to advanced
108 pages
2h 23m
English
Now we have some building blocks to work with. We know the hardware works and that we can open the clock via the SPI. We can also set individual bit patterns representing time. We can use those blocks to piece together a basic clock prototype.
We’ll start with a short module for setting the time. For now, we’ll assume the SPI is already open and that we have access to it via a spi reference. We’ll create two functions in the module. One will turn all of the LEDs off. The other will set a time given an open spi reference along with integer values representing hours, minutes, seconds, and brightness for the time display.
Let’s start with the show function:
| | defmodule Clock do |
| | def show(spi, hours, minutes, seconds, ... |
Read now
Unlock full access