For the LCD/Joystick HAT: https://www.waveshare.com/1.44inch-lcd-hat.htm
PIN Mapping:
Symbol | Raspberry Pi PIN (BCM) | Description |
---|---|---|
KEY1 | P21 | Button 1/GPIO |
KEY2 | P20 | Button 2/GPIO |
KEY3 | P16 | Button 3/GPIO |
Joystick Up | P6 | Joystick Up |
Joystick Down | P19 | Joystick Down |
Joystick Left | P5 | Joystick Left |
Joystick Right | P26 | Joystick Right |
Joystick Press | P13 | Joystick Press |
SCLK | P11/SCLK | SPI clock input |
MOSI | P10/MOSI | SPI data input |
DC | P25 | Data/Command selection (high for data, low for command) |
CS | P8/CE0 | Chip selection, low active |
RST | P27 | Reset, low active |
BL | P24 | Backlight |
- Ensure that packages are installed:
apt-get install fbset raspi-config raspi-gpio
- Enable SPI:
raspi-config # Select interface / SPI / Enable
- Load the following modules at boot-time, by adding these lines in
/etc/modules
spi-bcm2835
fbtft_device
- Provide configuration for the
fbtft
device, by creating the file/etc/modprobe.d/fbtft.conf
:
options fbtft_device name=adafruit18_green gpios=reset:27,dc:25,cs:8,led:24 speed=40000000 bgr=1 fps=60 custom=1 height=128 width=128 rotate=180
-
Reboot
-
You should get a new device called
fb1
ls /dev/fb*
echo 0 > /sys/class/backlight/fb_st7735r/bl_power # On
echo 1 > /sys/class/backlight/fb_st7735r/bl_power # Off
fbset -i -fb /dev/fb1
mode "128x128"
geometry 128 128 128 128 16
timings 0 0 0 0 0 0 0
nonstd 1
rgba 5/11,6/5,5/0,0/0
endmode
Frame buffer device information:
Name : fb_st7735r
Address : 0
Size : 32768
Type : PACKED PIXELS
Visual : TRUECOLOR
XPanStep : 0
YPanStep : 0
YWrapStep : 0
LineLength : 256
Accelerator : No
ffmpeg -v 0 -y \
-i imagefile.png \
-vf scale=128:128 -vcodec rawvideo -f rawvideo -pix_fmt rgb565 - > /dev/fb1
In file /boot/config.txt
# KEY 1/2/3
dtoverlay=gpio-key,gpio=21,gpio_pull=up,active_low=1,label=key1,keycode=1
dtoverlay=gpio-key,gpio=20,gpio_pull=up,active_low=1,label=key2,keycode=2
dtoverlay=gpio-key,gpio=16,gpio_pull=up,active_low=1,label=key3,keycode=3
# Joystick
dtoverlay=gpio-key,gpio=6,gpio_pull=up,active_low=1,label=up,keycode=103
dtoverlay=gpio-key,gpio=19,gpio_pull=up,active_low=1,label=down,keycode=108
dtoverlay=gpio-key,gpio=5,gpio_pull=up,active_low=1,label=left,keycode=105
dtoverlay=gpio-key,gpio=26,gpio_pull=up,active_low=1,label=right,keycode=106
dtoverlay=gpio-key,gpio=13,gpio_pull=up,active_low=1,label=enter,keycode=28
for pin in 21 20 16 6 19 5 26 13 ; do
raspi-gpio set $pin pu
echo $pin > /sys/class/gpio/export
done
cat /sys/class/gpio/gpio$pin/value
thx, good work.