2. Support for the special screen

So I will be using, for this terminal, the 4" square display from wave-share. It is not a must to have but if you want it as well, the instructions to set-up the PI for the display can be found on the wiki.

NOTE: I'm not going to be using touch functionality for this screen as the OS I'm using is raspbian Lite terminal version. For inputs I will be using a custom keyboard attached to it. So I will be skipping the touch setup for this.

Extra configuration for screen:

So I will be using, for this terminal, the 4" square display from wave-share. It is not a must to have but if you want it as well, the instructions to set-up the PI for the display can be found on the wiki.

NOTE: I'm not going to be using touch functionality for this screen as the OS I'm using is raspbian Lite terminal version. For inputs I will be using a custom keyboard attached to it. So I will be skipping the touch setup for this.

4" square display from wave-share

Edit /boot/config.txt :

sudo nano /boot/config.txt

At the end of the file, add the following:

gpio=0-9=a2
gpio=12-17=a2
gpio=20-25=a2
dtoverlay=dpi24
enable_dpi_lcd=1
display_default_lcd=1
extra_transpose_buffer=2
dpi_group=2
dpi_mode=87
dpi_output_format=0x7f216
dpi_timings=720 0 46 2 42 720 0 16 2 18 0 0 0 60 0 60000000 6
dtoverlay=waveshare-4dpic-3b-4b
dtoverlay=waveshare-4dpic-3b
dtoverlay=waveshare-4dpic-4b

#Note: For Raspberry Pi 4, you need to comment out dtoverlay=vc4-fkms-V3D.

Download the 4inch DPI LCD DTBO files and extract them. There will be 3 .dtbo files.

mkdir -p -- Downloads # creates download folder, if it doesn't exist
cd Downloads
wget https://www.waveshare.com/w/upload/0/03/4DPIC_DTBO.zip
unzip 4DPIC_DTBO.zip
ls

# OURTPUT:
# $ waveshare-4dpic-3b.dtbo
# $ waveshare-4dpic-3b-4b.dtbo
# $ waveshare-4dpic-4b.dtbo

Copy the above three files to the overlays directory /boot/overlays/

# if your extraction directory doesn't have any other .dtbo files, 
# you can simply do the following:
cd 4DPIC_DTBO
sudo cp *.dtbo /boot/overlays/
cd $HOME

To rotate the display, edit: /boot/config.txt:

sudo nano /boot/config.txt

Add the following:

display_rotate=1 #1:90;2: 180; 3: 270

Add this to the /boot/config.txt to avoid any warning messages

# for disbaling low voltage Warning:
avoid_warnings=2

Finally:

sudo reboot

Customise the terminal:

Optional for python script as programmer system but "must" for the shell script as programming system i.e. installer.sh:

Install custom terminal that can show custom .ttf fonts (as default xterm can only increase sizes of it's available bitmap fonts that you can also customise by running: sudo dpkg-reconfigure console-setup)

sudo apt-get install fontconfig -y
sudo apt-get install fbterm -y
which fbterm
# /usr/bin/fbterm
sudo setcap 'cap_sys_tty_config+ep' /usr/bin/fbterm
sudo usermod -aG video <USERNAME> # mine is "pi"

Install custom font:

I used a font called CPMono ( You can of course choose yours ). It came in .otf format. So I converted it into .ttf using a could service: https://cloudconvert.com/otf-to-ttf .

Once I was happy, I moved the font to my pi from my local machine to the pi using scp and then moved it to the following location:

cd /usr/share/fonts/truetype
sudo mkdir CPMono # or your some font name, doesn't have to be accurate
cd $HOME
sudo mv CPMono_v07-Plain.ttf /usr/share/fonts/truetype/CPMono/
fc-cache -f -v

Get your font names and pick the name:

fc-list : family

For my system these were the output

Fontconfig warning: ignoring UTF-8: not a valid region tag
Telegrama
Century Schoolbook L
DejaVu Sans Mono
URW Palladio L
URW Gothic L
Dingbats
URW Chancery L
DejaVu Sans
Nimbus Sans L
Droid Sans Fallback
Standard Symbols L
Nimbus Mono L
Nimbus Roman No9 L
Noto Mono
CPMono_v07,CPMono_v07 Plain
DejaVu Serif
URW Bookman L

I am going to use theCPMono_v07,CPMono_v07 Plainas my font of choice.

Next edit the fbterm configuration file:

$ sudo nano ~/.fbtermrc

There I changed few fields like (Here you can play with few parameters to configure the new fbterm terminal )

# font family names/pixelsize used by fbterm, multiple font family names must be seperated by ','
font-names=CPMono_v07,CPMono_v07 Plain
font-size=24
# cursor shape: 0 = underline, 1 = block
cursor-shape=1 

Let fbterm take over after boot as your main terminal:

Edit .bashrc file:

sudo nano ~/.bashrc

And add the following to it at the end of the file:

# --- start fbetrm with my custom font installed
/usr/bin/fbterm # you can get absolute path of fbterm by running "which fbterm"

And that's it.

Reboot to test.

Good to have a gif of fire burning after "burning firmware" 😅

This step is not necessary and the programmer script will work without this. You also have a choice to disable it while launching programmer.sh by

./programmer.sh -d #disables the fire gif after uploading 

To enable the feature you can launch the script with enable flag

./programmer.sh -e

By default gif is disabled.

NOTE: The installer.sh script will not install the dependencies for this part. You have to do it manually here.

We would be using https://github.com/google/gif-for-cli

sudo apt-get install ffmpeg -y
sudo apt-get install zlib* -y
sudo apt-get install libjpeg* -y # this will throw errors/conflicts, but the binary will work nevertheless
# finally
pip3 install --user gif-for-cli

The gif-for-cli command will likely be installed into ~/.local/bin or similar, you may need to put that directory in your $PATH by adding this to your .bashrc:

sudo nano $HOME/.bashrc

Add these lines

if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

After saving

source ~/.bashrc

And you should be good to go

Last updated

Was this helpful?