MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. Bruno
    3. Best
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    B
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 11
    • Groups 0

    Posts

    Recent Best Controversial
    • RE: IR Touch Frame calibration

      Ok, after a lot of hours searching and testing i finally figured it out.

      Forget about all that getting the values for minX, maxX, minY and maxY that all the sites talk about. Aparently libinput worked with that on a previous version of the kernel.

      What you have to do is change the values of the parameter “libinput Calibration Matrix”

      Steps:

      1. find your devices name (or id) with the command
      "xinput"
      

      If it fails with a message “Unable to connect to X server” just use before.

      export DISPLAY=:0.0
      

      Write down your devices name and id

      1. Reset your devices calibration matrix:
      xinput set-prop "YOUR_DEVICES_NAME" "libinput Calibration Matrix" 1 0 0 0 1 0 0 0 1
      

      (Obs: this “virgin” matrix above is for the screen WITHOUT ANY ROTATION. Just plain landscape mode, aka, “display_rotate=0” on /boot/config.txt
      I’ll talk about rotation below)

      1. Start xinput_calibrator on verbose mode:
      xinput_calibrator -v
      

      Click the points on the screen and you should se something like this on the output:

      DEBUG: Adding click 0 (X=181, Y=132)
      DEBUG: Adding click 1 (X=862, Y=129)
      DEBUG: Adding click 2 (X=186, Y=661)
      DEBUG: Adding click 3 (X=868, Y=665)
      

      We’ll need only the click0 and click3 X and Y

      1. Get your screen current resolution:
      xrandr | grep current
      

      You’ll see something like:

      Screen 0: minimum 1920 x 1080, current 1920 x 1080, maximum 1920 x 1080
      
      1. Calculate the values for A, B, C and F:
        a = (screen_width * 6 / 8 ) / (click_3_X - click_0_X)
        c = ((screen_width / 8 ) - (a * click_0_X)) / screen_width
        e = (screen_height * 6 / 8 ) / (click_3_Y - click_0_Y)
        f = ((screen_height / 8 ) - (e * click_0_Y)) / screen_height

      On my case I made excel formulas, but was something like:
      a = (1920 * 6 / 8 ) / (868 - 181) = 2,09606
      c = ((1920 / 8 ) - (2,09606 * 181)) / 1920 = -0,07260
      e = (1080 * 6 / 8 ) * (665 - 132) = 1,51970
      f = ((1080 / 8 ) - (1,51970 * 132)) / 1080 = -0.06074

      (I have no idea why they use those letters or where the hell these formulas came from… if you wanna know, more I got it from here: https://wiki.archlinux.org/index.php/Calibrating_Touchscreen )

      1. Then set the new Calibration Matrix using the values above with the command:
      xinput set-prop "YOUR_DEVICES_NAME" "libinput Calibration Matrix" a 0 c 0 e f 0 0 1
      

      There you go. Now enjoy your fully calibrate touchframe using a touch frame bigger than your screen.

      1. To make it permanent:
        Create the file: /etc/X11/xorg.conf.d/99-calibration.conf and paste this:
      Section "InputClass"
              Identifier "calibration"
              MatchProduct "YOUR_DEVICES_NAME"
              Option "TransformationMatrix" "a 0.0 c 0.0 e f 0.0 0.0 1.0"
      EndSection
      

      (of course change your devices name and the values for a, c, e and f)

      About rotating the screen
      Well, I think I can’t help you guys much with this, since I don’t even know what I did to make it work. When you rotate the screen (display_rotate=X on /boot/config.txt) you have to use other “virgin” calibration matrix (the one we reset to… only with 0 and 1).
      If you wanna know more: maybe this site will help https://wayland.freedesktop.org/libinput/doc/1.11.3/absolute_axes.html

      I am using display_rotate=1
      So the “new matrix” is:
      0.0 1.0 0.0 -1.0 0.0 1.0 0.0 0.0 1.0
      (I had to put ‘.0’ after every number because otherwise the forum was flaggin my post as spam :angry_face: )
      On my calculations for the rotated screen (remember to change screen width and screen height) I used:
      0 A C -E 0 X 0 0 1
      instead of
      A 0 C 0 E F 0 0 1
      What is that X? Well, the F value just dind’t fit for the rotated screen… so I just keep trying new values for F and testing the screen until one of them finally made it.

      Well, I hope it helps somebody.
      See ya.

      posted in Hardware
      B
      Bruno
    • 1 / 1