Add initial working MIPI installer script and touch drivers
This commit is contained in:
parent
b9438288ed
commit
4848a15557
6 changed files with 792 additions and 0 deletions
545
adafruit-pitft-mipi.py
Executable file
545
adafruit-pitft-mipi.py
Executable file
|
|
@ -0,0 +1,545 @@
|
|||
"""
|
||||
Adafruit PiTFT Installer Script
|
||||
(C) Adafruit Industries, Creative Commons 3.0 - Attribution Share Alike
|
||||
"""
|
||||
|
||||
import time
|
||||
import os
|
||||
try:
|
||||
import click
|
||||
except ImportError:
|
||||
raise RuntimeError("The library 'Click' was not found. To install, try typing: sudo pip3 install Click")
|
||||
try:
|
||||
from adafruit_shell import Shell
|
||||
except ImportError:
|
||||
raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell")
|
||||
|
||||
shell = Shell()
|
||||
shell.group = 'PITFT-MIPI'
|
||||
|
||||
__version__ = "1.0.0"
|
||||
|
||||
"""
|
||||
This is the main configuration. Displays should be placed in the order
|
||||
they are to appear in the menu.
|
||||
"""
|
||||
config = [
|
||||
{
|
||||
"type": "28r",
|
||||
"menulabel": "PiTFT 2.4\", 2.8\" or 3.2\" resistive (240x320)",
|
||||
"product": "2.8\" resistive, PID 1601",
|
||||
"touchscreen": {
|
||||
"identifier": "STMPE Touchscreen Calibration",
|
||||
"product": "stmpe",
|
||||
"transforms": {
|
||||
"0": "0.988809 -0.023645 0.060523 -0.028817 1.003935 0.034176 0 0 1",
|
||||
"90": "0.014773 -1.132874 1.033662 1.118701 0.009656 -0.065273 0 0 1",
|
||||
"180": "-1.115235 -0.010589 1.057967 -0.005964 -1.107968 1.025780 0 0 1",
|
||||
"270": "-0.033192 1.126869 -0.014114 -1.115846 0.006580 1.050030 0 0 1",
|
||||
},
|
||||
"calibrations": {
|
||||
"0": "4232 11 -879396 1 5786 -752768 65536",
|
||||
"90": "33 -5782 21364572 4221 35 -1006432 65536",
|
||||
"180": "-4273 61 16441290 4 -5772 21627524 65536",
|
||||
"270": "-9 5786 -784608 -4302 19 16620508 65536",
|
||||
},
|
||||
"overlay": "touch-stmpe",
|
||||
},
|
||||
"mipi_data": {
|
||||
"command_bin": "adafruit_ili9341_drm",
|
||||
"gpio": "dc-gpio=25",
|
||||
"viewport": {
|
||||
"90": "width=320,height=240",
|
||||
"180": "width=240,height=320",
|
||||
"270": "width=320,height=240",
|
||||
"0": "width=240,height=320",
|
||||
},
|
||||
},
|
||||
"width": 320,
|
||||
"height": 240,
|
||||
},
|
||||
{
|
||||
"type": "22",
|
||||
"menulabel": "PiTFT 2.2\" no touch",
|
||||
"product": "2.2\" no touch",
|
||||
"mipi_data": {
|
||||
"command_bin": "adafruit_ili9341_drm",
|
||||
"gpio": "dc-gpio=25",
|
||||
"viewport": {
|
||||
"90": "width=320,height=240",
|
||||
"180": "width=240,height=320",
|
||||
"270": "width=320,height=240",
|
||||
"0": "width=240,height=320",
|
||||
},
|
||||
},
|
||||
"width": 320,
|
||||
"height": 240,
|
||||
},
|
||||
{
|
||||
"type": "28c",
|
||||
"menulabel": "PiTFT 2.8\" capacitive touch",
|
||||
"product": "2.8\" capacitive, PID 1983",
|
||||
"touchscreen": {
|
||||
"identifier": "FocalTech Touchscreen Calibration",
|
||||
"product": "EP0110M09",
|
||||
"transforms": {
|
||||
"0": "-1 0 1 0 -1 1 0 0 1",
|
||||
"90": "0 1 0 -1 0 1 0 0 1",
|
||||
"180": "1 0 0 0 1 0 0 0 1",
|
||||
"270": "0 -1 1 1 0 0 0 0 1",
|
||||
},
|
||||
"calibrations": "320 65536 0 -65536 0 15728640 65536",
|
||||
"overlay": "touch-ft6236",
|
||||
},
|
||||
"mipi_data": {
|
||||
"command_bin": "adafruit_ili9341_drm",
|
||||
"gpio": "dc-gpio=25",
|
||||
"viewport": {
|
||||
"90": "width=320,height=240",
|
||||
"180": "width=240,height=320",
|
||||
"270": "width=320,height=240",
|
||||
"0": "width=240,height=320",
|
||||
},
|
||||
},
|
||||
"width": 320,
|
||||
"height": 240,
|
||||
},
|
||||
{
|
||||
"type": "35r",
|
||||
"menulabel": "PiTFT 3.5\" resistive touch",
|
||||
"product": "3.5\" Resistive",
|
||||
"touchscreen": {
|
||||
"identifier": "STMPE Touchscreen Calibration",
|
||||
"product": "stmpe",
|
||||
"transforms": {
|
||||
"0": "-1.098388 0.003455 1.052099 0.005512 -1.093095 1.026309 0 0 1",
|
||||
"90": "-0.000087 1.094214 -0.028826 -1.091711 -0.004364 1.057821 0 0 1",
|
||||
"180": "1.102807 0.000030 -0.066352 0.001374 1.085417 -0.027208 0 0 1",
|
||||
"270": "0.003893 -1.087542 1.025913 1.084281 0.008762 -0.060700 0 0 1",
|
||||
},
|
||||
"calibrations": {
|
||||
"0": "5724 -6 -1330074 26 8427 -1034528 65536",
|
||||
"90": "5 8425 -978304 -5747 61 22119468 65536",
|
||||
"180": "-5682 -1 22069150 13 -8452 32437698 65536",
|
||||
"270": "3 -8466 32440206 5703 -1 -1308696 65536",
|
||||
},
|
||||
"overlay": "touch-stmpe",
|
||||
},
|
||||
"mipi_data": {
|
||||
"command_bin": "adafruit_hx8357_drm",
|
||||
"gpio": "dc-gpio=25",
|
||||
"viewport": {
|
||||
"90": "width=480,height=320",
|
||||
"180": "width=320,height=480",
|
||||
"270": "width=480,height=320",
|
||||
"0": "width=320,height=480",
|
||||
},
|
||||
},
|
||||
"width": 480,
|
||||
"height": 320,
|
||||
"x11_scale": 1.5,
|
||||
},
|
||||
{
|
||||
"type": "st7789_240x240",
|
||||
"menulabel": "PiTFT Mini 1.3\" or 1.54\" display",
|
||||
"product": "1.54\" or 1.3\" no touch",
|
||||
"mipi_data": {
|
||||
"command_bin": "adafruit_st7789_drm",
|
||||
"gpio": "dc-gpio=25,backlight-gpio=22",
|
||||
"viewport": {
|
||||
"0": "width=240,height=240",
|
||||
"90": "width=240,height=240,x-offset=80",
|
||||
"180": "width=240,height=240,y-offset=80",
|
||||
"270": "width=240,height=240",
|
||||
},
|
||||
},
|
||||
"width": 240,
|
||||
"height": 240,
|
||||
},
|
||||
{
|
||||
"type": "st7789_240x320",
|
||||
"menulabel": "ST7789V 2.0\" no touch",
|
||||
"product": "2.0\" no touch",
|
||||
"mipi_data": {
|
||||
"command_bin": "adafruit_st7789_drm",
|
||||
"gpio": "dc-gpio=25,backlight-gpio=22",
|
||||
"viewport": {
|
||||
"0": "width=320,height=240",
|
||||
"90": "width=240,height=320",
|
||||
"180": "width=320,height=240",
|
||||
"270": "width=240,height=320",
|
||||
},
|
||||
},
|
||||
"width": 320,
|
||||
"height": 240,
|
||||
},
|
||||
{
|
||||
"type": "st7789_240x135",
|
||||
"menulabel": "MiniPiTFT 1.14\" display",
|
||||
"product": "1.14\" no touch",
|
||||
"mipi_data": {
|
||||
"command_bin": "adafruit_st7789_drm",
|
||||
"gpio": "dc-gpio=25,backlight-gpio=22",
|
||||
"viewport": {
|
||||
"0": "width=136,height=240,x-offset=52,y-offset=40",
|
||||
"90": "width=240,height=136,y-offset=52,x-offset=40",
|
||||
"180": "width=136,height=240,x-offset=52,y-offset=40",
|
||||
"270": "width=240,height=136,y-offset=52,x-offset=40",
|
||||
},
|
||||
},
|
||||
"width": 240,
|
||||
"height": 135,
|
||||
},
|
||||
{
|
||||
"type": "st7789v_bonnet_240x240",
|
||||
"menulabel": "TFT 1.3\" Bonnet + Joystick",
|
||||
"product": "1.3\" Joystick",
|
||||
"mipi_data": {
|
||||
"command_bin": "adafruit_st7789_drm",
|
||||
"gpio": "dc-gpio=25,backlight-gpio=22",
|
||||
"viewport": {
|
||||
"0": "width=240,height=240",
|
||||
"90": "width=240,height=240,x-offset=80",
|
||||
"180": "width=240,height=240,y-offset=80",
|
||||
"270": "width=240,height=240",
|
||||
},
|
||||
},
|
||||
"width": 240,
|
||||
"height": 240,
|
||||
},
|
||||
]
|
||||
|
||||
# default mipi data
|
||||
mipi_data = {
|
||||
"speed": 40000000,
|
||||
"spi": "spi0-0",
|
||||
}
|
||||
|
||||
PITFT_ROTATIONS = ("90", "180", "270", "0")
|
||||
UPDATE_DB = False
|
||||
SYSTEMD = None
|
||||
MIPI_MINIMUM_KERNEL = 5.15
|
||||
pitft_config = None
|
||||
pitftrot = None
|
||||
auto_reboot = None
|
||||
|
||||
def warn_exit(message):
|
||||
shell.warn(message)
|
||||
shell.exit(1)
|
||||
|
||||
def print_version(ctx, param, value):
|
||||
if not value or ctx.resilient_parsing:
|
||||
return
|
||||
print("Adafruit PiTFT Helper v{}".format(__version__))
|
||||
shell.exit(1)
|
||||
|
||||
def progress(ellipsis_count):
|
||||
for i in range(ellipsis_count):
|
||||
print("...", end='')
|
||||
time.sleep(1)
|
||||
print("")
|
||||
|
||||
def sysupdate():
|
||||
global UPDATE_DB
|
||||
if not UPDATE_DB:
|
||||
print("Updating apt indexes...", end='')
|
||||
progress(3)
|
||||
if not shell.run_command('sudo apt update', True):
|
||||
warn_exit("Apt failed to update indexes!")
|
||||
if not shell.run_command('sudo apt-get update', True):
|
||||
warn_exit("Apt failed to update indexes!")
|
||||
print("Reading package lists...")
|
||||
progress(3)
|
||||
UPDATE_DB = True
|
||||
return True
|
||||
|
||||
############################ Sub-Scripts ############################
|
||||
|
||||
def softwareinstall():
|
||||
print("Installing Pre-requisite Software...This may take a few minutes!")
|
||||
if not shell.run_command("apt-get install -y libts0", True):
|
||||
if not shell.run_command("apt-get install -y tslib"):
|
||||
if not shell.run_command("apt-get install -y libts-dev"):
|
||||
warn_exit("Apt failed to install TSLIB!")
|
||||
if not shell.run_command("apt-get install -y bc fbi git python3-dev python3-pip python3-smbus python3-spidev evtest libts-bin device-tree-compiler libraspberrypi-dev build-essential"):
|
||||
warn_exit("Apt failed to install software!")
|
||||
if not shell.run_command("pip3 install evdev"):
|
||||
warn_exit("Pip failed to install software!")
|
||||
return True
|
||||
|
||||
def uninstall_bootconfigtxt():
|
||||
"""Remove any old flexfb/fbtft stuff"""
|
||||
if shell.pattern_search("/boot/config.txt", "adafruit-pitft-helper"):
|
||||
print("Already have an adafruit-pitft-helper section in /boot/config.txt.")
|
||||
print("Removing old section...")
|
||||
shell.run_command("cp /boot/config.txt /boot/configtxt.bak")
|
||||
shell.pattern_replace("/boot/config.txt", '\n# --- added by adafruit-pitft-helper.*?\n# --- end adafruit-pitft-helper.*?\n', multi_line=True)
|
||||
return True
|
||||
def update_configtxt():
|
||||
"""update /boot/config.txt with appropriate values"""
|
||||
uninstall_bootconfigtxt()
|
||||
# Driver does not work if hdmi_force_hotplug=1 is present
|
||||
shell.pattern_replace("/boot/config.txt", "hdmi_force_hotplug=1", "hdmi_force_hotplug=0")
|
||||
display_overlay = f"dtoverlay=mipi-dbi-spi,{mipi_data['spi']},speed=40000000"
|
||||
display_overlay += f"\ndtparam=compatible={mipi_data['command_bin']}\\0panel-mipi-dbi-spi"
|
||||
viewport = ""
|
||||
if mipi_data['viewport'][pitftrot] is not None:
|
||||
viewport = mipi_data['viewport'][pitftrot]
|
||||
display_overlay += f"\ndtparam={viewport}"
|
||||
if "gpio" in mipi_data:
|
||||
display_overlay += f"\ndtparam={mipi_data['gpio']}"
|
||||
|
||||
# Touch Overlay
|
||||
touch_overlay = ""
|
||||
if "touchscreen" in pitft_config and "overlay" in pitft_config["touchscreen"]:
|
||||
# use dtc to compile and copy overlay
|
||||
touch_overlay = pitft_config["touchscreen"]["overlay"]
|
||||
shell.run_command(f"dtc -I dts -O dtb -o /boot/overlays/{touch_overlay}.dtbo overlays/{touch_overlay}.dts")
|
||||
touch_overlay = f"\ndtoverlay={touch_overlay}"
|
||||
date = shell.date()
|
||||
shell.write_text_file("/boot/config.txt", f"""
|
||||
# --- added by adafruit-pitft-helper {date} ---
|
||||
[all]
|
||||
dtparam=spi=on
|
||||
dtparam=i2c1=on
|
||||
dtparam=i2c_arm=on
|
||||
|
||||
{display_overlay}
|
||||
{touch_overlay}
|
||||
# --- end adafruit-pitft-helper {date} ---
|
||||
""")
|
||||
return True
|
||||
|
||||
def update_udev():
|
||||
shell.write_text_file("/etc/udev/rules.d/95-touchmouse.rules", """
|
||||
SUBSYSTEM=="input", ATTRS{name}=="touchmouse", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
|
||||
""", append=False)
|
||||
shell.write_text_file("/etc/udev/rules.d/95-ftcaptouch.rules", """
|
||||
SUBSYSTEM=="input", ATTRS{name}=="EP0110M09", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
|
||||
SUBSYSTEM=="input", ATTRS{name}=="generic ft5x06*", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
|
||||
""", append=False)
|
||||
shell.write_text_file("/etc/udev/rules.d/95-stmpe.rules", """
|
||||
SUBSYSTEM=="input", ATTRS{name}=="*stmpe*", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen"
|
||||
""", append=False)
|
||||
return True
|
||||
|
||||
def compile_display_fw():
|
||||
command_src = "mipi/panel.txt"
|
||||
|
||||
# We could just copy the file to panel.txt, edit that, then remove it after
|
||||
shell.copy(f"mipi/{mipi_data['command_bin']}.txt", command_src)
|
||||
|
||||
# Make sure each of the lines with "# rotation" starts with exactly 1 # and no more
|
||||
shell.pattern_replace(command_src, "^#*(.*?# rotation.*?$)", "#\\1")
|
||||
# Uncomment the one for the rotation we are going for
|
||||
shell.pattern_replace(command_src, "^#(.*?# rotation " + pitftrot + ".*?$)", "\\1")
|
||||
# Download the mipi-dbi-cmd script if it doesn't exist
|
||||
if not shell.exists("mipi-dbi-cmd"):
|
||||
shell.run_command("wget https://github.com/notro/panel-mipi-dbi/raw/main/mipi-dbi-cmd")
|
||||
shell.run_command("chmod +x mipi-dbi-cmd")
|
||||
# Run the mipi-dbi-script and output directly to the /lib/firmware folder
|
||||
shell.run_command(f"./mipi-dbi-cmd /lib/firmware/{mipi_data['command_bin']}.bin mipi/panel.txt")
|
||||
shell.remove(command_src)
|
||||
return True
|
||||
|
||||
def update_pointercal():
|
||||
if "calibrations" in pitft_config["touchscreen"]:
|
||||
if isinstance(pitft_config["touchscreen"]["calibrations"], dict):
|
||||
shell.write_text_file("/etc/pointercal", pitft_config["touchscreen"]["calibrations"][pitftrot])
|
||||
else:
|
||||
shell.write_text_file("/etc/pointercal", pitft_config["touchscreen"]["calibrations"])
|
||||
return True
|
||||
|
||||
def install_mipi():
|
||||
global mipi_data
|
||||
|
||||
if "mipi_data" in pitft_config:
|
||||
mipi_data.update(pitft_config['mipi_data'])
|
||||
if not compile_display_fw():
|
||||
shell.bail("Unable to compile MIPI firmware")
|
||||
# if there's X11 installed...
|
||||
if shell.exists("/etc/lightdm"):
|
||||
print("Setting raspi-config to boot to desktop w/o login...")
|
||||
shell.run_command("raspi-config nonint do_boot_behaviour B4")
|
||||
|
||||
# Disable overscan compensation (use full screen):
|
||||
shell.run_command("raspi-config nonint do_overscan 1")
|
||||
|
||||
shell.pattern_replace("/boot/config.txt", "^[^#]*dtoverlay=vc4-kms-v3d.*$", "#dtoverlay=vc4-kms-v3d")
|
||||
shell.pattern_replace("/boot/config.txt", "^[^#]*dtoverlay=vc4-fkms-v3d.*$", "#dtoverlay=vc4-fkms-v3d")
|
||||
|
||||
if not update_configtxt():
|
||||
shell.bail("Unable to update /boot/config.txt")
|
||||
return True
|
||||
|
||||
def update_xorg():
|
||||
if "touchscreen" in pitft_config:
|
||||
transform = "Option \"TransformationMatrix\" \"{}\"".format(pitft_config["touchscreen"]["transforms"][pitftrot])
|
||||
shell.write_text_file("/usr/share/X11/xorg.conf.d/20-calibration.conf", f"""
|
||||
Section "InputClass"
|
||||
Identifier "{pitft_config["touchscreen"]["identifier"]}"
|
||||
MatchProduct "{pitft_config["touchscreen"]["product"]}"
|
||||
MatchDevicePath "/dev/input/event*"
|
||||
Driver "libinput"
|
||||
{transform}
|
||||
EndSection
|
||||
""",
|
||||
append=False,
|
||||
)
|
||||
return True
|
||||
|
||||
def get_config_types():
|
||||
types = []
|
||||
for item in config:
|
||||
types.append(item["type"])
|
||||
return types
|
||||
|
||||
def get_config(type):
|
||||
for item in config:
|
||||
if item["type"] == type:
|
||||
return item
|
||||
return None
|
||||
|
||||
def success():
|
||||
global auto_reboot
|
||||
shell.info("Success!")
|
||||
print("""
|
||||
Settings take effect on next boot.
|
||||
""")
|
||||
if auto_reboot is None:
|
||||
auto_reboot = shell.prompt("REBOOT NOW?", default="y")
|
||||
if not auto_reboot:
|
||||
print("Exiting without reboot.")
|
||||
shell.exit()
|
||||
print("Reboot started...")
|
||||
shell.reboot()
|
||||
shell.exit()
|
||||
|
||||
####################################################### MAIN
|
||||
target_homedir = "/home/pi"
|
||||
@click.command()
|
||||
@click.option('-v', '--version', is_flag=True, callback=print_version, expose_value=False, is_eager=True, help="Print version information")
|
||||
@click.option('-u', '--user', nargs=1, default="/home/pi", type=str, help="Specify path of primary user's home directory", show_default=True)
|
||||
@click.option('--display', nargs=1, default=None, help="Specify a display option (1-{}) or type {}".format(len(config), get_config_types()))
|
||||
@click.option('--rotation', nargs=1, default=None, type=int, help="Specify a rotation option (1-4) or degrees {}".format(tuple(sorted([int(x) for x in PITFT_ROTATIONS]))))
|
||||
@click.option('--reboot', nargs=1, default=None, type=click.Choice(['yes', 'no']), help="Specify whether to reboot after the script is finished")
|
||||
def main(user, display, rotation, reboot):
|
||||
global target_homedir, pitft_config, pitftrot, auto_reboot
|
||||
shell.clear()
|
||||
if user != target_homedir:
|
||||
target_homedir = user
|
||||
print("Homedir = {}".format(target_homedir))
|
||||
|
||||
print("""This script downloads and installs
|
||||
PiTFT Support using userspace touch
|
||||
controls and a DTO for display drawing.
|
||||
one of several configuration files.
|
||||
Run time of up to 5 minutes. Reboot required!
|
||||
""")
|
||||
if reboot is not None:
|
||||
auto_reboot = reboot.lower() == 'yes'
|
||||
|
||||
# Check that the user is running the minimum kernel on this device
|
||||
if not shell.kernel_minimum(MIPI_MINIMUM_KERNEL):
|
||||
shell.warn(f"In order to continue, you will need to update your kernel to a minimum of {MIPI_MINIMUM_KERNEL}. ")
|
||||
if shell.get_os() == "Raspbian":
|
||||
shell.info("It looks like you are running this on a Raspberry Pi. You can update it to the latest version by running 'sudo rpi-update'.")
|
||||
shell.exit()
|
||||
|
||||
if display in [str(x) for x in range(1, len(config) + 1)]:
|
||||
pitft_config = config[int(display) - 1]
|
||||
print("Display Type: {}".format(pitft_config["menulabel"]))
|
||||
elif display in get_config_types():
|
||||
pitft_config = get_config(display)
|
||||
print("Display Type: {}".format(pitft_config["menulabel"]))
|
||||
else:
|
||||
# Build menu from config
|
||||
selections = []
|
||||
for item in config:
|
||||
option = "{} ({}x{})".format(item['menulabel'], item['width'], item['height'])
|
||||
selections.append(option)
|
||||
selections.append("Quit without installing")
|
||||
|
||||
PITFT_SELECT = shell.select_n("Select configuration:", selections)
|
||||
if PITFT_SELECT == len(config) + 1:
|
||||
shell.exit(1)
|
||||
pitft_config = config[PITFT_SELECT - 1]
|
||||
|
||||
if rotation is not None and 1 <= rotation <= 4:
|
||||
pitftrot = PITFT_ROTATIONS[rotation - 1]
|
||||
print("Rotation: {}".format(pitftrot))
|
||||
elif str(rotation) in PITFT_ROTATIONS:
|
||||
pitftrot = str(rotation)
|
||||
print("Rotation: {}".format(pitftrot))
|
||||
else:
|
||||
PITFT_ROTATE = shell.select_n(
|
||||
"Select rotation:", (
|
||||
"90 degrees (landscape)",
|
||||
"180 degrees (portrait)",
|
||||
"270 degrees (landscape)",
|
||||
"0 degrees (portrait)"
|
||||
))
|
||||
pitftrot = PITFT_ROTATIONS[PITFT_ROTATE - 1]
|
||||
|
||||
if 'rotations' in pitft_config and isinstance(pitft_config['rotations'], dict) and pitftrot in pitft_config['rotations'] and pitft_config['rotations'][pitftrot] is None:
|
||||
shell.bail("""Unfortunately {rotation} degrees for the {display} is not working at this time. Please
|
||||
restart the script and choose a different orientation.""".format(rotation=pitftrot, display=pitft_config["menulabel"]))
|
||||
|
||||
# check init system (technique borrowed from raspi-config):
|
||||
shell.info('Checking init system...')
|
||||
if shell.run_command("which systemctl", True) and shell.run_command("systemctl | grep '\-\.mount'", True):
|
||||
SYSTEMD = True
|
||||
print("Found systemd")
|
||||
elif os.path.isfile("/etc/init.d/cron") and not os.path.islink("/etc/init.d/cron"):
|
||||
SYSTEMD = False
|
||||
print("Found sysvinit")
|
||||
else:
|
||||
shell.bail("Unrecognised init system")
|
||||
|
||||
if shell.grep("boot", "/proc/mounts"):
|
||||
print("/boot is mounted")
|
||||
else:
|
||||
print("/boot must be mounted. if you think it's not, quit here and try: sudo mount /dev/mmcblk0p1 /boot")
|
||||
if shell.prompt("Continue?"):
|
||||
print("Proceeding.")
|
||||
else:
|
||||
shell.bail("Aborting.")
|
||||
|
||||
if not shell.isdir(target_homedir):
|
||||
shell.bail("{} must be an existing directory (use -u /home/foo to specify)".format(target_homedir))
|
||||
|
||||
shell.info("System update")
|
||||
if not sysupdate():
|
||||
shell.bail("Unable to apt-get update")
|
||||
|
||||
shell.info("Installing Python libraries & Software...")
|
||||
if not softwareinstall():
|
||||
shell.bail("Unable to install software")
|
||||
|
||||
shell.info("Adding MIPI support...")
|
||||
if not install_mipi():
|
||||
shell.bail("Unable to configure mipi")
|
||||
|
||||
shell.info("Updating /boot/config.txt...")
|
||||
if not update_configtxt():
|
||||
shell.bail("Unable to update /boot/config.txt")
|
||||
|
||||
if "touchscreen" in pitft_config:
|
||||
shell.info("Updating SysFS rules for Touchscreen...")
|
||||
if not update_udev():
|
||||
shell.bail("Unable to update /etc/udev/rules.d")
|
||||
|
||||
shell.info("Updating TSLib default calibration...")
|
||||
if not update_pointercal():
|
||||
shell.bail("Unable to update /etc/pointercal")
|
||||
|
||||
if shell.exists("/etc/lightdm"):
|
||||
shell.info("Updating X11 default calibration...")
|
||||
if not update_xorg():
|
||||
shell.bail("Unable to update calibration")
|
||||
success()
|
||||
|
||||
# Main function
|
||||
if __name__ == "__main__":
|
||||
shell.require_root()
|
||||
main()
|
||||
36
mipi/adafruit_hx8357_drm.txt
Normal file
36
mipi/adafruit_hx8357_drm.txt
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# Adafruit HX8257 PiTFT Plus TFT LCD Screen
|
||||
# width=480,height=320
|
||||
|
||||
command 0x01 # _SWRESET and Delay 100ms
|
||||
delay 100
|
||||
|
||||
command 0xB9 0xFF 0x83 0x57 # _SETC and delay 500ms
|
||||
delay 250
|
||||
delay 250
|
||||
|
||||
command 0xB3 0x80 0x00 0x06 0x06 # _SETRGB 0x80 enables SDO pin (0x00 disables)
|
||||
command 0xB6 0x25 # _SETCOM -1.52V
|
||||
command 0xB0 0x68 # _SETOSC Normal mode 70Hz, Idle mode 55 Hz
|
||||
command 0xCC 0x05 # _SETPANEL BGR, Gate direction swapped
|
||||
command 0xB1 0x00 0x15 0x1C 0x1C 0x83 0xAA # _SETPWR1 Not deep standby BT VSPR VSNR AP
|
||||
command 0xC0 0x50 0x50 0x01 0x3C 0x1E 0x08 # _SETSTBA OPON normal OPON idle STBA GEN
|
||||
command 0xB4 0x02 0x40 0x00 0x2A 0x2A 0x0D 0x78 # _SETCYC NW 0x02 RTN DIV DUM DUM GDON GDOFF
|
||||
|
||||
# _SETGAMMA
|
||||
command 0xE0 0x02 0x0A 0x11 0x1d 0x23 0x35 0x41 0x4b 0x4b 0x42 0x3A 0x27 0x1B 0x08 0x09 0x03 0x02 0x0A 0x11 0x1d 0x23 0x35 0x41 0x4b 0x4b 0x42 0x3A 0x27 0x1B 0x08 0x09 0x03 0x00 0x01
|
||||
command 0x3A 0x55 # _COLMOD 16 bit
|
||||
|
||||
# Command 36h sets the read order from frame memory to the display panel
|
||||
# Remember to swap width/height on 90/270 rotations
|
||||
command 0x36 0x00 # rotation 0
|
||||
#command 0x36 0xA0 # rotation 90
|
||||
#command 0x36 0xC0 # rotation 180
|
||||
#command 0x36 0x60 # rotation 270
|
||||
|
||||
command 0x35 0x00 # _TEON TW off
|
||||
command 0x44 0x00 0x02 # _TEARLINE
|
||||
command 0x11 # _SLPOUT
|
||||
delay 150
|
||||
|
||||
command 0x29 # _DISPON
|
||||
delay 50
|
||||
48
mipi/adafruit_ili9341_drm.txt
Normal file
48
mipi/adafruit_ili9341_drm.txt
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# Adafruit ILI9341 PiTFT TFT LCD Screen
|
||||
# width=320,height=240
|
||||
|
||||
command 0x01 # Software reset
|
||||
delay 128
|
||||
|
||||
command 0xEF 0x03 0x80 0x02
|
||||
command 0xCF 0x00 0xC1 0x30
|
||||
command 0xED 0x64 0x03 0x12 0x81
|
||||
command 0xE8 0x85 0x00 0x78
|
||||
command 0xCB 0x39 0x2C 0x00 0x34 0x02
|
||||
command 0xF7 0x20
|
||||
command 0xEA 0x00 0x00
|
||||
command 0xc0 0x23 # Power control VRH[5:0]
|
||||
command 0xc1 0x10 # Power control SAP[2:0];BT[3:0]
|
||||
command 0xc5 0x3e 0x28 # VCM control
|
||||
command 0xc7 0x86 # VCM control2
|
||||
|
||||
#define MADCTL_MY 0x80 ///< Bottom to top
|
||||
#define MADCTL_MX 0x40 ///< Right to left
|
||||
#define MADCTL_MV 0x20 ///< Reverse Mode
|
||||
#define MADCTL_ML 0x10 ///< LCD refresh Bottom to top
|
||||
#define MADCTL_RGB 0x00 ///< Red-Green-Blue pixel order
|
||||
#define MADCTL_BGR 0x08 ///< Blue-Green-Red pixel order
|
||||
#define MADCTL_MH 0x04 ///< LCD refresh right to left
|
||||
|
||||
# Command 36h sets the read order from frame memory to the display panel
|
||||
# Remember to swap width/height on 90/270 rotations
|
||||
command 0x36 0x88 # rotation 0
|
||||
#command 0x36 0xE8 # rotation 90
|
||||
#command 0x36 0x48 # rotation 180
|
||||
#command 0x36 0x28 # rotation 270
|
||||
|
||||
|
||||
command 0x37 0x00 # Vertical scroll zero
|
||||
command 0x3a 0x55 # COLMOD: Pixel Format Set
|
||||
command 0xb1 0x00 0x18 # Frame Rate Control (In Normal Mode/Full Colors)
|
||||
command 0xb6 0x08 0x82 0x27 # Display Function Control
|
||||
command 0xF2 0x00 # 3Gamma Function Disable
|
||||
command 0x26 0x01 # Gamma curve selected
|
||||
|
||||
# Set Gamma
|
||||
command 0xe0 0x0F 0x31 0x2B 0x0C 0x0E 0x08 0x4E 0xF1 0x37 0x07 0x10 0x03 0x0E 0x09 0x00
|
||||
command 0xe1 0x00 0x0E 0x14 0x03 0x11 0x07 0x31 0xC1 0x48 0x08 0x0F 0x0C 0x31 0x36 0x0F
|
||||
command 0x11 # Exit Sleep
|
||||
delay 120
|
||||
command 0x29 # Display on
|
||||
delay 120
|
||||
29
mipi/adafruit_st7789_drm.txt
Normal file
29
mipi/adafruit_st7789_drm.txt
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Adafruit ST7789 MiniPiTFT LCD and TFT Bonnet
|
||||
# width=240,height=240
|
||||
|
||||
command 0x01 # _SWRESET and Delay 150ms
|
||||
delay 150
|
||||
|
||||
command 0x11 # _SLPOUT and Delay 10ms
|
||||
delay 10
|
||||
|
||||
command 0x3A 0x55 # _COLMOD and Delay 10ms
|
||||
delay 10
|
||||
|
||||
command 0x36 0x08 # _MADCTL Botton->Top Refresh
|
||||
command 0x21 # _INVON Hack and Delay 10ms
|
||||
delay 10
|
||||
|
||||
command 0x13 # _NORON and Delay 10ms
|
||||
delay 10
|
||||
|
||||
# Command 36h sets the read order from frame memory to the display panel
|
||||
# Remember to swap width/height on 90/270 rotations if required
|
||||
command 0x36 0x00 # rotation 0
|
||||
#command 0x36 0xA0 # rotation 90
|
||||
#command 0x36 0xC0 # rotation 180
|
||||
#command 0x36 0x60 # rotation 270
|
||||
|
||||
command 0x29 # _DISPON and Delay 500ms
|
||||
delay 250
|
||||
delay 250
|
||||
53
overlays/touch-ft6236.dts
Normal file
53
overlays/touch-ft6236.dts
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Device Tree overlay for the Focaltech FT6236 capacitive
|
||||
* touch screen controller on the Adafruit PiTFT
|
||||
*
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
|
||||
|
||||
fragment@0 {
|
||||
target = <&gpio>;
|
||||
__overlay__ {
|
||||
pitft_pins: pitft_pins {
|
||||
brcm,pins = <24>;
|
||||
brcm,function = <0>; /* in out */
|
||||
brcm,pull = <2>; /* pullup none */
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
fragment@1 {
|
||||
target = <&i2c1>;
|
||||
__overlay__ {
|
||||
/* needed to avoid dtc warning */
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
ft6236: ft6236@38 {
|
||||
compatible = "focaltech,ft6236";
|
||||
reg = <0x38>;
|
||||
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&pitft_pins>;
|
||||
|
||||
interrupt-parent = <&gpio>;
|
||||
interrupts = <24 2>;
|
||||
touchscreen-size-x = <240>;
|
||||
touchscreen-size-y = <320>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
__overrides__ {
|
||||
touch-sizex = <&ft6236>,"touchscreen-size-x?";
|
||||
touch-sizey = <&ft6236>,"touchscreen-size-y?";
|
||||
touch-invx = <&ft6236>,"touchscreen-inverted-x?";
|
||||
touch-invy = <&ft6236>,"touchscreen-inverted-y?";
|
||||
touch-swapxy = <&ft6236>,"touchscreen-swapped-x-y?";
|
||||
};
|
||||
};
|
||||
81
overlays/touch-stmpe.dts
Normal file
81
overlays/touch-stmpe.dts
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Device Tree overlay for the STMPE resistive
|
||||
* touch screen controller on the Adafruit PiTFT
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
|
||||
|
||||
fragment@0 {
|
||||
target = <&spi0>;
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
|
||||
fragment@1 {
|
||||
target = <&spidev1>;
|
||||
__overlay__ {
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
|
||||
fragment@2 {
|
||||
target = <&gpio>;
|
||||
__overlay__ {
|
||||
pitft_pins: pitft_pins {
|
||||
brcm,pins = <24>;
|
||||
brcm,function = <0>; /* in out */
|
||||
brcm,pull = <2>; /* pullup none */
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
fragment@3 {
|
||||
target = <&spi0>;
|
||||
__overlay__ {
|
||||
/* needed to avoid dtc warning */
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
pitft: pitft_ts@1 {
|
||||
compatible = "st,stmpe610";
|
||||
reg = <1>;
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&pitft_pins>;
|
||||
|
||||
spi-max-frequency = <500000>;
|
||||
irq-gpio = <&gpio 24 0x2>; /* IRQF_TRIGGER_FALLING */
|
||||
interrupts = <24 2>; /* high-to-low edge triggered */
|
||||
interrupt-parent = <&gpio>;
|
||||
interrupt-controller;
|
||||
|
||||
stmpe_touchscreen {
|
||||
compatible = "st,stmpe-ts";
|
||||
st,sample-time = <4>;
|
||||
st,mod-12b = <1>;
|
||||
st,ref-sel = <0>;
|
||||
st,adc-freq = <2>;
|
||||
st,ave-ctrl = <3>;
|
||||
st,touch-det-delay = <4>;
|
||||
st,settling = <2>;
|
||||
st,fraction-z = <7>;
|
||||
st,i-drive = <0>;
|
||||
};
|
||||
|
||||
stmpe_gpio: stmpe_gpio {
|
||||
#gpio-cells = <2>;
|
||||
compatible = "st,stmpe-gpio";
|
||||
/*
|
||||
* only GPIO2 is wired/available
|
||||
* and it is wired to the backlight
|
||||
*/
|
||||
st,norequest-mask = <0x7b>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
Loading…
Reference in a new issue