{"id":159,"date":"2018-06-16T23:22:04","date_gmt":"2018-06-16T16:22:04","guid":{"rendered":"https:\/\/prosindo.com\/blog\/?p=159"},"modified":"2021-11-09T06:51:59","modified_gmt":"2021-11-08T23:51:59","slug":"calibrate-waveshare-5-resistive-touchscreen","status":"publish","type":"post","link":"https:\/\/prosindo.com\/blog\/2018\/06\/16\/calibrate-waveshare-5-resistive-touchscreen\/","title":{"rendered":"Calibrate Waveshare 5&#8243; Resistive Touchscreen (and 7.9&#8243; Capacitive)"},"content":{"rendered":"<p>config.txt<br \/>\n<code>max_usb_current=1<\/code><br \/>\n<code>hdmi_group=2<\/code><br \/>\n<code>hdmi_mode=87<\/code><br \/>\n<code>hdmi_cvt 800 480 60 6 0 0 0 <\/code><br \/>\n<code>hdmi_drive=1<\/code><\/p>\n<p># install calibrator and evdev (allows multiple keyboards mice treated as separate device)<br \/>\n<code>sudo apt install xinput-calibrator xserver-xorg-input-evdev<\/code><\/p>\n<p># make evdev higher number than libinput<br \/>\n<code>sudo mv \/usr\/share\/X11\/xorg.conf.d\/10-evdev.conf \/usr\/share\/X11\/xorg.conf.d\/45-evdev.conf<\/code><\/p>\n<p># list devices<br \/>\n<code>xinput<\/code><\/p>\n<p># view calibration option<br \/>\n<code>xinput --list-props &lt;deviceid&gt;<\/code><\/p>\n<p># calibrate<br \/>\n<code>xinput_calibrator<\/code><\/p>\n<p># copy paste the result like below to <code>\/usr\/share\/X11\/xorg.conf.d\/99-calibration.conf<\/code>:<br \/>\n<code>Section \"InputClass\"<\/code><br \/>\n<code>Identifier \"calibration\"<\/code><br \/>\n<code>MatchProduct \"BYZHYYZHY By ZH851\"<\/code><br \/>\n<code>Option \"Calibration\" \"182 3859 277 3944\"<\/code><br \/>\n<code>Option \"SwapAxes\" \"0\"<\/code><br \/>\n<code>EndSection<\/code><\/p>\n<p># check\u00a0 the values<br \/>\n<code>DISPLAY=:0 xinput list-props \"BYZHYYZHY By ZH851\"<\/code><\/p>\n<p># manual set values<br \/>\n<code>DISPLAY=:0 xinput set-prop \"BYZHYYZHY By ZH851\" \"Evdev Axis Calibration\" 200, 3800, 275, 3850<\/code><\/p>\n<p>ALTERNATIVE (using libinput):<br \/>\n# check calibration values<br \/>\n<code>xinput_calibrator -v<\/code><br \/>\n<code>DEBUG: Found that 'BYZHYYZHY By ZH851' is a sysfs name.<\/code><br \/>\n<code>DEBUG: Adding click 0 (X=129, Y=86)<\/code><br \/>\n<code>DEBUG: Adding click 1 (X=655, Y=96)<\/code><br \/>\n<code>DEBUG: Adding click 2 (X=133, Y=406)<\/code><br \/>\n<code>DEBUG: Adding click 3 (X=669, Y=401)<\/code><\/p>\n<p># check screen resolution<br \/>\n<code>xrandr | grep current<\/code><br \/>\n<code>Screen 0: minimum 800 x 480, current 800 x 480, maximum 800 x 480<\/code><\/p>\n<p># calculate values<br \/>\n<code>a = (screen_width * 6 \/ 8) \/ (click_3_X - click_0_X)<\/code><br \/>\n<code>c = ((screen_width \/ 8) - (a * click_0_X)) \/ screen_width<\/code><br \/>\n<code>e = (screen_height * 6 \/ 8) \/ (click_3_Y - click_0_Y)<\/code><br \/>\n<code>f = ((screen_height \/ 8) - (e * click_0_Y)) \/ screen_height<\/code><\/p>\n<p><code>a = (800 * 6 \/ 8) \/ (669 - 129) = 1.1111<\/code><br \/>\n<code>c = ((800 \/ 8) - (1.1111 * 129)) \/ 800 = -0.0542<\/code><br \/>\n<code>e = (480 * 6 \/ 8) \/ (401 - 86) = 1.1429<\/code><br \/>\n<code>f = ((480 \/ 8) - (1.1429 * 86)) \/ 480 = -0.0798<\/code><\/p>\n<p># test new values<br \/>\n<code>xinput set-prop \"BYZHYYZHY By ZH851\" \"libinput Calibration Matrix\" a, 0.0, c, 0.0, e, f, 0.0, 0.0, 1.0<\/code><\/p>\n<p><code>xinput set-prop \"BYZHYYZHY By ZH851\" \"libinput Calibration Matrix\" 1.1111, 0.0, -0.0542, 0.0, 1.1429, -0.0798, 0.0, 0.0, 1.0<\/code><\/p>\n<p># if calculation incorrect, reset and repeat calculation above<br \/>\n<code>xinput set-prop \"BYZHYYZHY By ZH851\" \"libinput Calibration Matrix\" 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0<\/code><\/p>\n<p># make changes permanent to <code>\/usr\/share\/X11\/xorg.conf.d\/99-calibration.conf<\/code>:<br \/>\n<code>Section \"InputClass\"<br \/>\nIdentifier \"calibration\"<br \/>\nMatchProduct \"BYZHYYZHY By ZH851\"<br \/>\nOption \"TransformationMatrix\" \"1.1111 0.0 -0.0542 0.0 1.1429 -0.0798 0.0 0.0 1.0\"<br \/>\nEndSection<\/code><\/p>\n<p>For 7.9&#8243; Capacitive Screen:<\/p>\n<p>add this lines to \/boot\/config.txt:<br \/>\n<code>#disable these settings below<br \/>\n#display_auto_detect=1<br \/>\n#dtoverlay=vc4-kms-v3d<br \/>\n#max_framebuffers=2<br \/>\nmax_usb_current=1<\/code><br \/>\n<code>hdmi_group=2<\/code><br \/>\n<code>hdmi_mode=87<\/code><br \/>\n<code>hdmi_timings=400 0 100 10 140 1280 10 20 20 2 0 0 0 60 0 43000000 3<\/code><br \/>\n<code>display_rotate=3 # 1 - 90deg, 2 - 180deg, 3 - 270deg<\/code><\/p>\n<p>Rotate 0 degree:<br \/>\n<code>xinput set-prop \"WaveShare WaveShare\" \"libinput Calibration Matrix\" 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0<\/code><\/p>\n<p>Rotate 90 degree:<br \/>\n<code>xinput set-prop \"WaveShare WaveShare\" \"libinput Calibration Matrix\" 0.0, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0, 1.0<\/code><\/p>\n<p>Rotate 270 degree:<br \/>\n<code>xinput set-prop \"WaveShare WaveShare\" \"libinput Calibration Matrix\" 0.0, -1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0<\/code><\/p>\n<p># make changes permanent to <code>\/usr\/share\/X11\/xorg.conf.d\/99-calibration.conf<\/code>:<br \/>\n<code>Section \"InputClass\"<br \/>\nIdentifier \"calibration\"<br \/>\nMatchProduct \"WaveShare WaveShare\"<br \/>\nOption \"TransformationMatrix\" \"0.0 -1.0 1.0 1.0 0.0 0.0 0.0 0.0 1.0\"<br \/>\nEndSection<\/code><\/p>\n<p>Source:<br \/>\nhttps:\/\/www.waveshare.com\/wiki\/5inch_HDMI_LCD_(B)<br \/>\nhttps:\/\/www.waveshare.com\/wiki\/7.9inch_HDMI_LCD<br \/>\nhttps:\/\/wiki.archlinux.org\/index.php\/Talk:Calibrating_Touchscreen<\/p>\n","protected":false},"excerpt":{"rendered":"<p>config.txt max_usb_current=1 hdmi_group=2 hdmi_mode=87 hdmi_cvt 800 480 60 6 0 0 0 hdmi_drive=1 # install calibrator and evdev (allows multiple keyboards mice treated as separate device) sudo apt install xinput-calibrator xserver-xorg-input-evdev # make evdev higher number than libinput sudo mv \/usr\/share\/X11\/xorg.conf.d\/10-evdev.conf \/usr\/share\/X11\/xorg.conf.d\/45-evdev.conf # list devices xinput # view calibration option xinput &#8211;list-props &lt;deviceid&gt; # calibrate &hellip; <a href=\"https:\/\/prosindo.com\/blog\/2018\/06\/16\/calibrate-waveshare-5-resistive-touchscreen\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Calibrate Waveshare 5&#8243; Resistive Touchscreen (and 7.9&#8243; Capacitive)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-159","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/posts\/159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/comments?post=159"}],"version-history":[{"count":9,"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/posts\/159\/revisions"}],"predecessor-version":[{"id":251,"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/posts\/159\/revisions\/251"}],"wp:attachment":[{"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/media?parent=159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/categories?post=159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prosindo.com\/blog\/wp-json\/wp\/v2\/tags?post=159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}