> For the complete documentation index, see [llms.txt](https://werkhause.gitbook.io/firmware-uploader-terminal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://werkhause.gitbook.io/firmware-uploader-terminal/system-pre-requisites/2.-support-for-the-special-screen.md).

# 2. Support for the special screen

So I will be using, for this terminal, the [**4" square display from wave-share**](https://www.waveshare.com/4inch-dpi-lcd-c.htm). 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**](https://www.waveshare.com/wiki/4inch_DPI_LCD_%28C%29)**.**

> 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**](https://www.waveshare.com/4inch-dpi-lcd-c.htm). 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**](https://www.waveshare.com/wiki/4inch_DPI_LCD_%28C%29)**.**

> 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](/files/-MfXar08aMbYO9kRv8Ai)

Edit `/boot/config.txt` :

```bash
sudo nano /boot/config.txt
```

At the end of the file, add the following:

```bash
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 the&#x6D;*.* There will be 3 .dtbo files.

```bash
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/`

```bash
# 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`:

```bash
sudo nano /boot/config.txt
```

Add the following:

```bash
display_rotate=1 #1：90；2: 180； 3: 270
```

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

```bash
# for disbaling low voltage Warning:
avoid_warnings=2
```

Finally:

```bash
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`)

```bash
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](https://1-free-fonts.com/fonts/download/6748/CPMono.zip) ( 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:

```bash
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:&#x20;

```bash
fc-list : family
```

For my system these were the output

```bash
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 the`CPMono_v07,CPMono_v07 Plain`as my font of choice.&#x20;

Next edit the `fbterm` configuration file:

```bash
$ sudo nano ~/.fbtermrc
```

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

```bash
# 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:&#x20;

```bash
sudo nano ~/.bashrc
```

And add the following to it at the end of the file: &#x20;

```bash
# --- 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.&#x20;

Reboot to test.&#x20;

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

![](/files/-MgC01UjAoHW1nBbTUHL)

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

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

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

```bash
./programmer.sh -e
```

By default gif is disabled.&#x20;

**NOTE:** The `installer.sh` script will not install the dependencies for this part.  You have to do it manually here.&#x20;

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

```bash
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`:

```bash
sudo nano $HOME/.bashrc
```

Add these lines

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

After saving

```bash
source ~/.bashrc
```

And you should be good to go
