{"action":"created","comment":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/pulls/comments/60306643","id":60306643,"diff_hunk":"@@ -0,0 +1,117 @@\n+# XPT2046 Module\n+| Since  | Origin / Contributor  | Maintainer  | Source  |\n+| :----- | :-------------------- | :---------- | :------ |\n+| 2016-04-14| [Starofall](https://github.com/Starofall) | [Starofall](https://github.com/Starofall) | [xpt2046.c](../../../app/modules/xpt2046.c)|\n+\n+XPT2046 is a touch controller used by several cheep displays - often in combination with the ILI9341 display controller.\n+The module is build based on the libarys of [spapadim](https://github.com/spapadim/XPT2046/) and  [PaulStoffregen](https://github.com/PaulStoffregen/XPT2046_Touchscreen).\n+\n+\n+## xpt2046.setup(cs_pin, irq_pin, height, width)\n+Setups the XPT2046 module to read touch values from the display. It is required to call spi.setup() before calling xpt2046.setup (see example).\n+As the ucg lib also requires spi.setup() to be called before it is important to only call it once in total and to activate spi.FULLDUPLEX.\n+The `clock_div` used in spi.setup() should be 16 or higher, as lower values might produces inaccurate results.\n+\n+#### Syntax\n+`xpt2046.setup(cs_pin, irq_pin, height, width)`\n+\n+#### Parameters\n+- `cs_pin` GPIO pin for cs\n+- `irq_pin` GPIO pin for irq\n+- `height` display height in pixel\n+- `width` display width in pixel\n+\n+#### Returns\n+`nil`\n+\n+```lua\n+-- Setup spi with `clock_div` of 16 and spi.FULLDUPLEX\n+spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 16,spi.FULLDUPLEX)\n+-- SETTING UP DISPLAY (using ucg module)\n+local disp = ucg.ili9341_18x240x320_hw_spi(8, 4, 0)\n+disp:begin(0);\n+-- SETTING UP TOUCH\n+xpt2046.setup(2,1,320,240)\n+xpt2046.setCalibration(198, 1776, 1762, 273);\n+```\n+\n+\n+## xpt2046.setCalibration(x1, y1, x2, y2)\n+Sets the configuration of the display. Configuration values can be optained by using xpt2046.getRaw() and read the values in the edges.\n+\n+#### Syntax\n+`xpt2046.setCalibration(x1, y1, x2, y2)`\n+\n+#### Parameters\n+- `x1` raw x value at top left\n+- `y1` raw y value at top left\n+- `x2` raw x value at bottom right\n+- `y2` raw y value at bottom right\n+\n+#### Returns\n+`nil`\n+\n+\n+## xpt2046.isTouched()\n+Checks if the touch panel is touched.\n+\n+#### Syntax\n+`xpt2046.isTouched()`\n+\n+#### Returns\n+true if the display is touched else false\n+\n+```lua\n+if(xpt2046.isTouched()) then\n+\tlocal x, y = xpt2046.getPosition()\n+\tprint(x .. \"-\" .. y)\n+end\n+```\n+\n+\n+## xpt2046.getPosition()\n+Returns the position the display is touched using the calibration values and given width and height.\n+\n+#### Syntax\n+`xpt2046.getPosition()`\n+\n+#### Returns\n+returns both the x and the y position.\n+\n+#### Example\n+```lua\n+local x, y = xpt2046.getPosition()\n+print(x .. \"-\" .. y)\n+```\n+\n+\n+## xpt2046.getPositionMeaned()","path":"docs/en/modules/xpt2046.md","position":88,"original_position":88,"commit_id":"f52229d0fdf243502d2298d75cb6842ba34f2f7f","original_commit_id":"9a61cc7f8f1fdcf3ba9fde43a09d7d4bdb1dcff5","user":{"login":"devsaurus","id":10791520,"avatar_url":"https://avatars.githubusercontent.com/u/10791520?v=3","gravatar_id":"","url":"https://api.github.com/users/devsaurus","html_url":"https://github.com/devsaurus","followers_url":"https://api.github.com/users/devsaurus/followers","following_url":"https://api.github.com/users/devsaurus/following{/other_user}","gists_url":"https://api.github.com/users/devsaurus/gists{/gist_id}","starred_url":"https://api.github.com/users/devsaurus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devsaurus/subscriptions","organizations_url":"https://api.github.com/users/devsaurus/orgs","repos_url":"https://api.github.com/users/devsaurus/repos","events_url":"https://api.github.com/users/devsaurus/events{/privacy}","received_events_url":"https://api.github.com/users/devsaurus/received_events","type":"User","site_admin":false},"body":"_averaged_ instead of _meaned_?","created_at":"2016-04-19T20:38:56Z","updated_at":"2016-04-19T20:38:56Z","html_url":"https://github.com/nodemcu/nodemcu-firmware/pull/1242#discussion_r60306643","pull_request_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/pulls/1242","_links":{"self":{"href":"https://api.github.com/repos/nodemcu/nodemcu-firmware/pulls/comments/60306643"},"html":{"href":"https://github.com/nodemcu/nodemcu-firmware/pull/1242#discussion_r60306643"},"pull_request":{"href":"https://api.github.com/repos/nodemcu/nodemcu-firmware/pulls/1242"}}},"pull_request":{"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/pulls/1242","id":66508548,"html_url":"https://github.com/nodemcu/nodemcu-firmware/pull/1242","diff_url":"https://github.com/nodemcu/nodemcu-firmware/pull/1242.diff","patch_url":"https://github.com/nodemcu/nodemcu-firmware/pull/1242.patch","issue_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/1242","number":1242,"state":"open","locked":false,"title":"Added support for XPT2046 touch screens as own module","user":{"login":"Starofall","id":5400076,"avatar_url":"https://avatars.githubusercontent.com/u/5400076?v=3","gravatar_id":"","url":"https://api.github.com/users/Starofall","html_url":"https://github.com/Starofall","followers_url":"https://api.github.com/users/Starofall/followers","following_url":"https://api.github.com/users/Starofall/following{/other_user}","gists_url":"https://api.github.com/users/Starofall/gists{/gist_id}","starred_url":"https://api.github.com/users/Starofall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Starofall/subscriptions","organizations_url":"https://api.github.com/users/Starofall/orgs","repos_url":"https://api.github.com/users/Starofall/repos","events_url":"https://api.github.com/users/Starofall/events{/privacy}","received_events_url":"https://api.github.com/users/Starofall/received_events","type":"User","site_admin":false},"body":"I integrated the source from the referenced github projects into the nodemcu-firmware.\r\nThis offers fast and efficient access to the touch display on a nodemcu.\r\n\r\nEspecially as many ILI9341 (which is supported by the ucg lib) displays uses the XPT2046 for touch.","created_at":"2016-04-14T15:51:50Z","updated_at":"2016-04-19T20:38:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"34c711482229d6081c619129a139f86772e3227b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/pulls/1242/commits","review_comments_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/pulls/1242/comments","review_comment_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/1242/comments","statuses_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/statuses/f52229d0fdf243502d2298d75cb6842ba34f2f7f","head":{"label":"Starofall:dev","ref":"dev","sha":"f52229d0fdf243502d2298d75cb6842ba34f2f7f","user":{"login":"Starofall","id":5400076,"avatar_url":"https://avatars.githubusercontent.com/u/5400076?v=3","gravatar_id":"","url":"https://api.github.com/users/Starofall","html_url":"https://github.com/Starofall","followers_url":"https://api.github.com/users/Starofall/followers","following_url":"https://api.github.com/users/Starofall/following{/other_user}","gists_url":"https://api.github.com/users/Starofall/gists{/gist_id}","starred_url":"https://api.github.com/users/Starofall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Starofall/subscriptions","organizations_url":"https://api.github.com/users/Starofall/orgs","repos_url":"https://api.github.com/users/Starofall/repos","events_url":"https://api.github.com/users/Starofall/events{/privacy}","received_events_url":"https://api.github.com/users/Starofall/received_events","type":"User","site_admin":false},"repo":{"id":56116142,"name":"nodemcu-firmware","full_name":"Starofall/nodemcu-firmware","owner":{"login":"Starofall","id":5400076,"avatar_url":"https://avatars.githubusercontent.com/u/5400076?v=3","gravatar_id":"","url":"https://api.github.com/users/Starofall","html_url":"https://github.com/Starofall","followers_url":"https://api.github.com/users/Starofall/followers","following_url":"https://api.github.com/users/Starofall/following{/other_user}","gists_url":"https://api.github.com/users/Starofall/gists{/gist_id}","starred_url":"https://api.github.com/users/Starofall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Starofall/subscriptions","organizations_url":"https://api.github.com/users/Starofall/orgs","repos_url":"https://api.github.com/users/Starofall/repos","events_url":"https://api.github.com/users/Starofall/events{/privacy}","received_events_url":"https://api.github.com/users/Starofall/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Starofall/nodemcu-firmware","description":"lua based interactive firmware for mcu like esp8266","fork":true,"url":"https://api.github.com/repos/Starofall/nodemcu-firmware","forks_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/forks","keys_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/teams","hooks_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/hooks","issue_events_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/issues/events{/number}","events_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/events","assignees_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/assignees{/user}","branches_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/branches{/branch}","tags_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/tags","blobs_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/git/refs{/sha}","trees_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/statuses/{sha}","languages_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/languages","stargazers_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/stargazers","contributors_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/contributors","subscribers_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/subscribers","subscription_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/subscription","commits_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/commits{/sha}","git_commits_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/git/commits{/sha}","comments_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/comments{/number}","issue_comment_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/issues/comments{/number}","contents_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/contents/{+path}","compare_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/merges","archive_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/downloads","issues_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/issues{/number}","pulls_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/pulls{/number}","milestones_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/milestones{/number}","notifications_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/labels{/name}","releases_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/releases{/id}","deployments_url":"https://api.github.com/repos/Starofall/nodemcu-firmware/deployments","created_at":"2016-04-13T03:00:25Z","updated_at":"2016-04-13T03:00:28Z","pushed_at":"2016-04-15T02:00:48Z","git_url":"git://github.com/Starofall/nodemcu-firmware.git","ssh_url":"git@github.com:Starofall/nodemcu-firmware.git","clone_url":"https://github.com/Starofall/nodemcu-firmware.git","svn_url":"https://github.com/Starofall/nodemcu-firmware","homepage":"http://nodemcu.com","size":87784,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nodemcu:dev","ref":"dev","sha":"a33f5868551000d6f8e06def540bc5755b2146f0","user":{"login":"nodemcu","id":9865736,"avatar_url":"https://avatars.githubusercontent.com/u/9865736?v=3","gravatar_id":"","url":"https://api.github.com/users/nodemcu","html_url":"https://github.com/nodemcu","followers_url":"https://api.github.com/users/nodemcu/followers","following_url":"https://api.github.com/users/nodemcu/following{/other_user}","gists_url":"https://api.github.com/users/nodemcu/gists{/gist_id}","starred_url":"https://api.github.com/users/nodemcu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodemcu/subscriptions","organizations_url":"https://api.github.com/users/nodemcu/orgs","repos_url":"https://api.github.com/users/nodemcu/repos","events_url":"https://api.github.com/users/nodemcu/events{/privacy}","received_events_url":"https://api.github.com/users/nodemcu/received_events","type":"User","site_admin":false},"repo":{"id":26917568,"name":"nodemcu-firmware","full_name":"nodemcu/nodemcu-firmware","owner":{"login":"nodemcu","id":9865736,"avatar_url":"https://avatars.githubusercontent.com/u/9865736?v=3","gravatar_id":"","url":"https://api.github.com/users/nodemcu","html_url":"https://github.com/nodemcu","followers_url":"https://api.github.com/users/nodemcu/followers","following_url":"https://api.github.com/users/nodemcu/following{/other_user}","gists_url":"https://api.github.com/users/nodemcu/gists{/gist_id}","starred_url":"https://api.github.com/users/nodemcu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodemcu/subscriptions","organizations_url":"https://api.github.com/users/nodemcu/orgs","repos_url":"https://api.github.com/users/nodemcu/repos","events_url":"https://api.github.com/users/nodemcu/events{/privacy}","received_events_url":"https://api.github.com/users/nodemcu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nodemcu/nodemcu-firmware","description":"lua based interactive firmware for mcu like esp8266","fork":false,"url":"https://api.github.com/repos/nodemcu/nodemcu-firmware","forks_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/forks","keys_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/teams","hooks_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/hooks","issue_events_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/events{/number}","events_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/events","assignees_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/assignees{/user}","branches_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/branches{/branch}","tags_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/tags","blobs_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/statuses/{sha}","languages_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/languages","stargazers_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/stargazers","contributors_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/contributors","subscribers_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/subscribers","subscription_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/subscription","commits_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/contents/{+path}","compare_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/merges","archive_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/downloads","issues_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues{/number}","pulls_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/pulls{/number}","milestones_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/milestones{/number}","notifications_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/labels{/name}","releases_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/releases{/id}","deployments_url":"https://api.github.com/repos/nodemcu/nodemcu-firmware/deployments","created_at":"2014-11-20T15:06:45Z","updated_at":"2016-04-19T09:07:03Z","pushed_at":"2016-04-19T04:54:08Z","git_url":"git://github.com/nodemcu/nodemcu-firmware.git","ssh_url":"git@github.com:nodemcu/nodemcu-firmware.git","clone_url":"https://github.com/nodemcu/nodemcu-firmware.git","svn_url":"https://github.com/nodemcu/nodemcu-firmware","homepage":"http://nodemcu.com","size":104451,"stargazers_count":2106,"watchers_count":2106,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":966,"mirror_url":null,"open_issues_count":112,"forks":966,"open_issues":112,"watchers":2106,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodemcu/nodemcu-firmware/pulls/1242"},"html":{"href":"https://github.com/nodemcu/nodemcu-firmware/pull/1242"},"issue":{"href":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/1242"},"comments":{"href":"https://api.github.com/repos/nodemcu/nodemcu-firmware/issues/1242/comments"},"review_comments":{"href":"https://api.github.com/repos/nodemcu/nodemcu-firmware/pulls/1242/comments"},"review_comment":{"href":"https://api.github.com/repos/nodemcu/nodemcu-firmware/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodemcu/nodemcu-firmware/pulls/1242/commits"},"statuses":{"href":"https://api.github.com/repos/nodemcu/nodemcu-firmware/statuses/f52229d0fdf243502d2298d75cb6842ba34f2f7f"}}}}