Skip to content

Instantly share code, notes, and snippets.

@duckida
duckida / instructions.md
Created February 16, 2026 15:24
How to use Inland 3.5" TFT with Raspberry Pi OS Bookworm

How to use Inland/Generic 3.5" TFT with Raspberry Pi OS Bookworm

  1. Edit /boot/firmware/config.txt. Add the following lines:
enable_uart=1
dtparam=spi=on
dtoverlay=piscreen,drm,speed=16000000
  1. Open sudo raspi-config. Under Advanced Options→Wayland, click X11. Then click OK & Finish. Don't reboot the Pi.
@duckida
duckida / guide.md
Created February 16, 2026 15:23
How to convert xinput calibration to LibInput matrix

Touch Coordinate Calibration with libinput

1. The Mathematical Framework

Modern libinput uses an Affine Transformation Matrix. To map a raw touch coordinate $(x, y)$ to a normalized screen coordinate $(x', y')$, we use the following equation:

$$ \begin{bmatrix} x' \ y' \ 1 \end{bmatrix} = \begin{bmatrix} a & b & c \ d & e & f \ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \ y \ 1 \end{bmatrix} $$

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
# Use this example for digital pin control of an H-bridge driver
# like a DRV8833, TB6612 or L298N.
import time
import board
import digitalio
from adafruit_motor import stepper
import RPi.GPIO as gpio
import time
gpio.setmode(gpio.BCM)
gpio.setwarnings(False)
# Pins
ain1 = 16
ain2 = 20
# Import required modules
import time
import RPi.GPIO as GPIO
# Declare the GPIO settings
GPIO.setmode(GPIO.BOARD)
# set up GPIO pins
GPIO.setup(7, GPIO.OUT) # Connected to PWMA