Merge pull request #291 from makermelissa/main

Update 2.8-inch Capacitive PiTFT
This commit is contained in:
Melissa LeBlanc-Williams 2024-01-26 11:39:14 -08:00 committed by GitHub
commit a6c6d5dc16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 105 additions and 6 deletions

View file

@ -19,7 +19,7 @@ except ImportError:
shell = Shell() shell = Shell()
shell.group = 'PITFT' shell.group = 'PITFT'
__version__ = "3.7.0" __version__ = "3.7.1"
""" """
This is the main configuration. Displays should be placed in the order This is the main configuration. Displays should be placed in the order
@ -77,8 +77,17 @@ config = [
"180": "1 0 0 0 1 0 0 0 1", "180": "1 0 0 0 1 0 0 0 1",
"270": "0 -1 1 1 0 0 0 0 1", "270": "0 -1 1 1 0 0 0 0 1",
}, },
"overlay_params": {
"0": "touch-invx,touch-invy",
"90": "touch-swapxy,touch-invy",
"180": None,
"270": "touch-swapxy,touch-invx",
},
}, },
"overlay": """dtoverlay=pitft28-capacitive,speed=64000000,fps=30 "overlay_src": "overlays/pitft28-capacitive-overlay.dts",
"overlay_dest": "{boot_dir}/overlays/tinydrm-pitft28-capacitive.dtbo",
"overlay": "dtoverlay=tinydrm-pitft28-capacitive,rotate={pitftrot}",
"fb_overlay": """dtoverlay=pitft28-capacitive,speed=64000000,fps=30
dtoverlay=pitft28-capacitive,rotate={pitftrot}""", dtoverlay=pitft28-capacitive,rotate={pitftrot}""",
"calibrations": "320 65536 0 -65536 0 15728640 65536", "calibrations": "320 65536 0 -65536 0 15728640 65536",
"width": 320, "width": 320,
@ -322,7 +331,9 @@ def update_configtxt(rotation_override=None, tinydrm_install=False):
if "{pitftrot}" in overlay: if "{pitftrot}" in overlay:
rotation = str(rotation_override) if rotation_override is not None else pitftrot rotation = str(rotation_override) if rotation_override is not None else pitftrot
overlay = overlay.format(pitftrot=rotation) overlay = overlay.format(pitftrot=rotation)
if tinydrm_install: # Wayland ignores X11 Transformations, so use params instead
if "overlay_params" in pitft_config and pitftrot in pitft_config["overlay_params"] and pitft_config["overlay_params"][pitftrot] is not None:
overlay += "," + pitft_config["overlay_params"][pitftrot]
shell.write_text_file(f"{boot_dir}/config.txt", """ shell.write_text_file(f"{boot_dir}/config.txt", """
# --- added by adafruit-pitft-helper {date} --- # --- added by adafruit-pitft-helper {date} ---
[all] [all]
@ -543,9 +554,12 @@ def uninstall_fbcp_rclocal():
shell.pattern_replace("/etc/rc.local", '^.*fbcp.*$') shell.pattern_replace("/etc/rc.local", '^.*fbcp.*$')
return True return True
def update_xorg(): def update_xorg(tinydrm_install=False):
if "touchscreen" in pitft_config: if "touchscreen" in pitft_config:
transform = "Option \"TransformationMatrix\" \"{}\"".format(pitft_config["touchscreen"]["transforms"][pitftrot]) transform_setting = pitft_config["touchscreen"]["transforms"][pitftrot]
if not tinydrm_install and "old_transforms" in pitft_config["touchscreen"]:
transform_setting = pitft_config["touchscreen"]["old_transforms"][pitftrot]
transform = f"Option \"TransformationMatrix\" \"{transform_setting}\""
shell.write_text_file("/usr/share/X11/xorg.conf.d/20-calibration.conf", """ shell.write_text_file("/usr/share/X11/xorg.conf.d/20-calibration.conf", """
Section "InputClass" Section "InputClass"
Identifier "{identifier}" Identifier "{identifier}"
@ -780,7 +794,7 @@ restart the script and choose a different orientation.""".format(rotation=pitftr
if shell.exists("/etc/lightdm"): if shell.exists("/etc/lightdm"):
shell.info("Updating Desktop Touch calibration...") shell.info("Updating Desktop Touch calibration...")
if not update_xorg(): if not update_xorg(tinydrm_install=wayland):
shell.bail("Unable to update calibration") shell.bail("Unable to update calibration")
else: else:
if not uninstall_fbcp(): if not uninstall_fbcp():

View file

@ -0,0 +1,85 @@
/*
* Device Tree overlay for Adafruit PiTFT 2.8" capacitive touch screen
*
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target = <&spi0>;
__overlay__ {
status = "okay";
};
};
fragment@1 {
target = <&spidev0>;
__overlay__ {
status = "disabled";
};
};
fragment@2 {
target = <&gpio>;
__overlay__ {
pitft_pins: pitft_pins {
brcm,pins = <24 25>;
brcm,function = <0 1>; /* in out */
brcm,pull = <2 0>; /* pullup none */
};
};
};
fragment@3 {
target = <&spi0>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
pitft: pitft@0{
compatible = "adafruit,yx240qv29";
reg = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pitft_pins>;
spi-max-frequency = <32000000>;
rotation = <90>;
dc-gpios = <&gpio 25 0>;
};
};
};
fragment@4 {
target = <&i2c1>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
ft6236: ft6236@38 {
compatible = "focaltech,ft6236";
reg = <0x38>;
interrupt-parent = <&gpio>;
interrupts = <24 2>;
touchscreen-size-x = <240>;
touchscreen-size-y = <320>;
};
};
};
__overrides__ {
speed = <&pitft>,"spi-max-frequency:0";
rotate = <&pitft>,"rotation:0";
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?";
};
};