summary refs log tree commit diff
path: root/modules/hardware/ads7846.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/hardware/ads7846.nix')
-rw-r--r--modules/hardware/ads7846.nix33
1 files changed, 21 insertions, 12 deletions
diff --git a/modules/hardware/ads7846.nix b/modules/hardware/ads7846.nix
index bb1fe61..4d7582a 100644
--- a/modules/hardware/ads7846.nix
+++ b/modules/hardware/ads7846.nix
@@ -5,7 +5,7 @@
   services =
     let
       calibrationPoints = "3900 200 200 3900";
-      calibrationMatrix = "-1 0 1 0 1 0 0 0 1";
+      calibrationMatrix = "-1 0 1 0 1 0";
     in
     {
       libinput.enable = true;
@@ -29,8 +29,17 @@
 
   hardware.deviceTree =
     let
-      # todo: parameter-ize this more.
+      cs = 1;
       penirq = 25;
+      penirq_pull = 2;
+      speed = 50000;
+      pmin = 0;
+      pmax = 255;
+      xohms = 150;
+      xmin = 200;
+      xmax = 3900;
+      ymin = 200;
+      ymax = 3900;
     in
     {
       overlays = [
@@ -77,7 +86,7 @@
                                     ads7846_pins: ads7846_pins {
                                             brcm,pins = <${toString penirq}>; /* mel: previously illegal value of 255 */
                                             brcm,function = <0>; /* in */
-                                            brcm,pull = <0>; /* none */
+                                            brcm,pull = <${toString penirq_pull}>; /* none */
                                     };
                             };
                     };
@@ -91,23 +100,23 @@
 
                                     ads7846: ads7846@1 {
                                             compatible = "ti,ads7846";
-                                            reg = <1>;
+                                            reg = <${toString cs}>;
                                             pinctrl-names = "default";
                                             pinctrl-0 = <&ads7846_pins>;
 
-                                            spi-max-frequency = <2000000>;
+                                            spi-max-frequency = <${toString speed}>;
                                             interrupts = <${toString penirq} 2>; /* high-to-low edge triggered */
                                             interrupt-parent = <&gpio>;
                                             pendown-gpio = <&gpio ${toString penirq} 1>;
 
                                             /* driver defaults */
-                                            ti,x-min = /bits/ 16 <0>;
-                                            ti,y-min = /bits/ 16 <0>;
-                                            ti,x-max = /bits/ 16 <0x0FFF>;
-                                            ti,y-max = /bits/ 16 <0x0FFF>;
-                                            ti,pressure-min = /bits/ 16 <0>;
-                                            ti,pressure-max = /bits/ 16 <0xFFFF>;
-                                            ti,x-plate-ohms = /bits/ 16 <400>;
+                                            ti,x-min = /bits/ 16 <${toString xmin}>;
+                                            ti,y-min = /bits/ 16 <${toString ymin}>;
+                                            ti,x-max = /bits/ 16 <${toString xmax}>;
+                                            ti,y-max = /bits/ 16 <${toString ymax}>;
+                                            ti,pressure-min = /bits/ 16 <${toString pmin}>;
+                                            ti,pressure-max = /bits/ 16 <${toString pmax}>;
+                                            ti,x-plate-ohms = /bits/ 16 <${toString xohms}>;
                                     };
                             };
                     };