This little package displays the current block height for Cosmos chains on SSD1306 OLED displays.
SSD1306 displays are commonly available OLED displays for Raspberry Pi and other IoT devices. Check out Adafruit OLED bonnet, and Adafruit PiOLDED.
Use raspi-config to enable I2C by default.
Install Raspi Config:
-
Go to raspberrypi.org and pick the latest version.
-
Download and install:
# install dependencies
$ sudo apt-get install lua5.1
# get raspi-config
$ wget https://archive.raspberrypi.org/debian/pool/main/r/raspi-config/raspi-config_[DATE]_all.deb
# install
$ sudo dpkg -i raspi-config_[DATE]_all.deb
Run raspi-config
and enable I2C.
Before running this sample, you can check that your OLED display is detected by installing i2c-tools
, then running i2cdetect -y 1
. The first connected SSD1306 will usually be at address 0x3c
. This package assumes 0x3c
. If your device is at a different address, then you may need to modify the code for it to work.
$ sudo apt-get install i2c-tools
$ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
With Cross you can build the binary on your development machine.
Cross-compile a release for your platform. For Ubuntu 64-bit:
cross build --release --target aarch64-unknown-linux-gnu
After the build finishes, copy it to your Raspberry Pi
scp target/aarch64-unknown-linux-gnu/release/pulsar-ssd1306 user@ip:/home/user
cargo build --release
After the build finishes, copy the binary to where you want to run it from:
cp target/aarch64-unknown-linux-gnu/release/pulsar-ssd1306 /usr/local/bin
Pulsar SSD1306 currently works by reading the block height from a Tendermint node running on localhost.
SSH to your Pi and run it with:
sudo ./pulsar-ssd1306
If all goes well, you should see your block height on the display! Obviously, the chain should already be running.
Querying the block height every second from Tendermint is not very efficient. A better approach is to monitor systemd
, and update the display whenever there's a new log entry. I'll leave that as an exercise for an ambitious developer. PRs welcome!