Skip to content

Instantly share code, notes, and snippets.

@charlestsai1995
Last active June 9, 2024 11:16
Show Gist options
  • Save charlestsai1995/54ab65a87e2e063ea25eb3aec4193fe1 to your computer and use it in GitHub Desktop.
Save charlestsai1995/54ab65a87e2e063ea25eb3aec4193fe1 to your computer and use it in GitHub Desktop.
CJK support on Beepy

CJK support on Beepy (both display and input)

The Beepy uses a monochrome sharp memory LCD panel which has some caveat. This document includes a way to bring CJK support to Beepy in the framebuffer. The below is based on raspbian on raspberry pi zero, and had ran the Beepy setup script found on https://beepy.sqfmi.com/docs/getting-started.

Install DRM driver for the LCD

We will be using fbterm. Since fbterm supports minimal of 32bpp, we need to install a DRM driver for the sharp memory LCD panel to enable 32bpp mode.

Download the driver made by excel,

$ git clone https://github.com/ardangelo/sharp-drm-driver.git

Compile and install

$ cd ~/sharp-drm-driver
$ make
$ sudo make install

Reboot the raspberry pi to enable the driver

Install Excel's keyboard driver

The official keyboard driver does not function with fcitx IME so we would use Excel's keyboard driver. The driver only works with the customized firmware. Download i2c_puppet.uf2 and update the firmware,

  1. Slide the power switch off (left if facing up)
  2. Connect the Beepy to your computer via USB-C
  3. While holding the "End Call" key (top right on the keypad), slide the power switch on
  4. The Beepy will present itself as a USB mass storage device, drag'n'drop the new firmware (*.uf2) into the drive and it will reboot with the new firmware

Now boot the raspberry pi. The keyboard won't work so need to ssh into the pi. Install the driver

$ git clone https://github.com/ardangelo/beepberry-keyboard-driver.git
$ cd beepberry-keyboard-driver
$ make
$ sudo make install

Re-compile fbterm

Download fbterm from https://github.com/onokatio/fbterm2

$ git clone https://github.com/onokatio/fbterm2.git

Change the "/dev/fb0" to "/dev/fb1" in /src/fbdev.cpp using any editor of your choice, and execute the below to compile and install fbterm.

$ sudo apt-get install libfontconfig1-dev
$ cd ~/fbterm2
$./configure && make && sudo make install

Make sure you execute the below so fbterm can be run by non-root user and can capture shortcut keys

$ sudo gpasswd -a YOUR_USERNAME video
$ sudo setcap 'cap_sys_tty_config+ep' /usr/local/bin/fbterm

Configure fbterm

Now execute fbterm once. The text might be wonky but we will configure it.

$ fbterm

Install fonts. The below fonts should be good for English, Chinese, and Japanese.

$ sudo apt install xfonts-wqy fonts-terminus-otb fonts-dotgothic16

Now edit the fbterm configure file ~/.fbtermrc, change the following

font-names=Terminus,WenQuanYi Bitmap Song,DotGothic16
font-size=14
font-width=8
font-height=16
text-encodings=utf-8
term=xterm-mono

Restart fbterm to make the change effective. Now Beepy should display CJK characters without issue.

(Optional) Install tmux and enable fbterm by default

Running tmux in fbterm seems to resolve many key mapping issues. First install tmux if you have not already,

$ sudo apt install tmux

Now add the below to your ~/.bashrc

if [ -z "$SSH_CONNECTION" ]; then
 # if in virtual terminal, start fbterm
   if [[ "$(tty)" =~ /dev/tty ]] && type fbterm > /dev/null 2>&1; then
        fbterm
  # otherwise, start/attach to tmux
   elif [ -z "$TMUX" ] && type tmux >/dev/null 2>&1; then
        tmux new -As "$(basename $(tty))"
   fi
fi

Logout and back in to have it take effect.

Install fcitx and enable IMEs

Now we can install fcitx and enable IMEs,

$ sudo apt install fcitx-frontend-fbterm

Run fcitx-config-gtk3 under Xorg to enable IMEs or go to ~/.config/fcitx and edit profile (example below enables google pinyin),

EnabledIMList=fcitx-keyboard-us:True,googlepinyin:True,pinyin:False

You can also configure the hotkeys in ~/.config/fcitx/config

Uncomment and change the following in ~/.fbtermrc,

input-method=fcitx-fbterm

Now reboot and launch fcitx,

$ fcitx &

Now press Ctrl + space (phone + space) you should be able to use the input method enabled.

Showcase of the end result

wttr.inClock screensaverDisplaying JapaneseDisplaying Chinese IME

Special thanks to discord/beeper members teenux, themediocritist, _burr_, excel

@laonan
Copy link

laonan commented May 25, 2024

Hello, does anyone know how to set Google Pinyin to a black background? I have a white background.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment