{"action":"created","comment":{"url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/pulls/comments/201807668","pull_request_review_id":136382220,"id":201807668,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTgwNzY2OA==","diff_hunk":"@@ -206,4 +230,150 @@ private static String getStateAsString(int state) {\n         ControllerState controllerState = getState(state);\n         return controllerState.name();\n     }\n+\n+    /**\n+     * Generates a command for resetting the coordinates for the current coordinate system to zero.\n+     *\n+     * @param controllerStatus the current controller status\n+     * @param gcodeState       the current gcode state\n+     * @return a string with the command to reset the coordinate system to zero\n+     */\n+    public static String generateResetCoordinatesToZeroCommand(ControllerStatus controllerStatus, GcodeState gcodeState) {\n+        int offsetCode = convertOffsetGcodeToCode(gcodeState.offset);\n+        Position machineCoord = controllerStatus.getMachineCoord();\n+        return \"G10 L2 P\" + offsetCode +\n+                \" X\" + Utils.formatter.format(machineCoord.get(Axis.X)) +\n+                \" Y\" + Utils.formatter.format(machineCoord.get(Axis.Y)) +\n+                \" Z\" + Utils.formatter.format(machineCoord.get(Axis.Z));\n+    }\n+\n+    /**\n+     * Generates a command for setting the axis to a position in the current coordinate system\n+     *\n+     * @param controllerStatus the current controller status\n+     * @param gcodeState       the current gcode state\n+     * @param axis             the axis to set\n+     * @param position         the position to set\n+     * @return a command for setting the position\n+     */\n+    public static String generateSetWorkPositionCommand(ControllerStatus controllerStatus, GcodeState gcodeState, Axis axis, double position) {\n+        int offsetCode = convertOffsetGcodeToCode(gcodeState.offset);\n+        Position machineCoord = controllerStatus.getMachineCoord();\n+        double coordinate = -(position - machineCoord.get(axis));\n+        return \"G10 L2 P\" + offsetCode + \" \" +\n+                axis.name() + Utils.formatter.format(coordinate);\n+    }\n+\n+    private static int convertOffsetGcodeToCode(Code offsetGcode) {","path":"ugs-core/src/com/willwinder/universalgcodesender/TinyGUtils.java","position":153,"original_position":153,"commit_id":"23815b4861cad1cd7c9989b96738815c3f13afbb","original_commit_id":"23815b4861cad1cd7c9989b96738815c3f13afbb","user":{"login":"winder","id":125509,"node_id":"MDQ6VXNlcjEyNTUwOQ==","avatar_url":"https://avatars1.githubusercontent.com/u/125509?v=4","gravatar_id":"","url":"https://api.github.com/users/winder","html_url":"https://github.com/winder","followers_url":"https://api.github.com/users/winder/followers","following_url":"https://api.github.com/users/winder/following{/other_user}","gists_url":"https://api.github.com/users/winder/gists{/gist_id}","starred_url":"https://api.github.com/users/winder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/winder/subscriptions","organizations_url":"https://api.github.com/users/winder/orgs","repos_url":"https://api.github.com/users/winder/repos","events_url":"https://api.github.com/users/winder/events{/privacy}","received_events_url":"https://api.github.com/users/winder/received_events","type":"User","site_admin":false},"body":"This could go right into GcodeUtils.java, maybe even some of the other WCS helpers you have here as well. There is also WorkCoordinateSystem.java, so something like this might technically work:\r\n```\r\n WorkCoordinateSystem.valueOf(offsetGcode.toString()).getPValue();\r\n```","created_at":"2018-07-11T19:07:21Z","updated_at":"2018-07-11T19:07:21Z","html_url":"https://github.com/winder/Universal-G-Code-Sender/pull/1078#discussion_r201807668","pull_request_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/pulls/1078","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/winder/Universal-G-Code-Sender/pulls/comments/201807668"},"html":{"href":"https://github.com/winder/Universal-G-Code-Sender/pull/1078#discussion_r201807668"},"pull_request":{"href":"https://api.github.com/repos/winder/Universal-G-Code-Sender/pulls/1078"}}},"pull_request":{"url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/pulls/1078","id":200711036,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwNzExMDM2","html_url":"https://github.com/winder/Universal-G-Code-Sender/pull/1078","diff_url":"https://github.com/winder/Universal-G-Code-Sender/pull/1078.diff","patch_url":"https://github.com/winder/Universal-G-Code-Sender/pull/1078.patch","issue_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/issues/1078","number":1078,"state":"open","locked":false,"title":"Added support for gcode states and work coordinates","user":{"login":"breiler","id":8962024,"node_id":"MDQ6VXNlcjg5NjIwMjQ=","avatar_url":"https://avatars0.githubusercontent.com/u/8962024?v=4","gravatar_id":"","url":"https://api.github.com/users/breiler","html_url":"https://github.com/breiler","followers_url":"https://api.github.com/users/breiler/followers","following_url":"https://api.github.com/users/breiler/following{/other_user}","gists_url":"https://api.github.com/users/breiler/gists{/gist_id}","starred_url":"https://api.github.com/users/breiler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/breiler/subscriptions","organizations_url":"https://api.github.com/users/breiler/orgs","repos_url":"https://api.github.com/users/breiler/repos","events_url":"https://api.github.com/users/breiler/events{/privacy}","received_events_url":"https://api.github.com/users/breiler/received_events","type":"User","site_admin":false},"body":"Added support for handling gcode states from the responses of the controller. It's also now possible to set and handle work coordinates. \r\n\r\nFurther improvements for #1071\r\n\r\nA small demo can be found here:\r\nhttps://www.youtube.com/watch?v=_kmXCvtE1Pc","created_at":"2018-07-11T14:02:20Z","updated_at":"2018-07-11T19:07:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6a9153e587b5f40b4ba22c612103aa615b1ab362","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/pulls/1078/commits","review_comments_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/pulls/1078/comments","review_comment_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/pulls/comments{/number}","comments_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/issues/1078/comments","statuses_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/statuses/23815b4861cad1cd7c9989b96738815c3f13afbb","head":{"label":"breiler:feature/tinyg","ref":"feature/tinyg","sha":"23815b4861cad1cd7c9989b96738815c3f13afbb","user":{"login":"breiler","id":8962024,"node_id":"MDQ6VXNlcjg5NjIwMjQ=","avatar_url":"https://avatars0.githubusercontent.com/u/8962024?v=4","gravatar_id":"","url":"https://api.github.com/users/breiler","html_url":"https://github.com/breiler","followers_url":"https://api.github.com/users/breiler/followers","following_url":"https://api.github.com/users/breiler/following{/other_user}","gists_url":"https://api.github.com/users/breiler/gists{/gist_id}","starred_url":"https://api.github.com/users/breiler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/breiler/subscriptions","organizations_url":"https://api.github.com/users/breiler/orgs","repos_url":"https://api.github.com/users/breiler/repos","events_url":"https://api.github.com/users/breiler/events{/privacy}","received_events_url":"https://api.github.com/users/breiler/received_events","type":"User","site_admin":false},"repo":{"id":119799653,"node_id":"MDEwOlJlcG9zaXRvcnkxMTk3OTk2NTM=","name":"Universal-G-Code-Sender","full_name":"breiler/Universal-G-Code-Sender","owner":{"login":"breiler","id":8962024,"node_id":"MDQ6VXNlcjg5NjIwMjQ=","avatar_url":"https://avatars0.githubusercontent.com/u/8962024?v=4","gravatar_id":"","url":"https://api.github.com/users/breiler","html_url":"https://github.com/breiler","followers_url":"https://api.github.com/users/breiler/followers","following_url":"https://api.github.com/users/breiler/following{/other_user}","gists_url":"https://api.github.com/users/breiler/gists{/gist_id}","starred_url":"https://api.github.com/users/breiler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/breiler/subscriptions","organizations_url":"https://api.github.com/users/breiler/orgs","repos_url":"https://api.github.com/users/breiler/repos","events_url":"https://api.github.com/users/breiler/events{/privacy}","received_events_url":"https://api.github.com/users/breiler/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/breiler/Universal-G-Code-Sender","description":"A Java based GRBL compatible cross-platform G-Code sender.","fork":true,"url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender","forks_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/forks","keys_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/keys{/key_id}","collaborators_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/teams","hooks_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/hooks","issue_events_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/issues/events{/number}","events_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/events","assignees_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/assignees{/user}","branches_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/branches{/branch}","tags_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/tags","blobs_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/git/refs{/sha}","trees_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/git/trees{/sha}","statuses_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/statuses/{sha}","languages_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/languages","stargazers_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/stargazers","contributors_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/contributors","subscribers_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/subscribers","subscription_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/subscription","commits_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/commits{/sha}","git_commits_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/git/commits{/sha}","comments_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/comments{/number}","issue_comment_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/issues/comments{/number}","contents_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/contents/{+path}","compare_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/compare/{base}...{head}","merges_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/merges","archive_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/downloads","issues_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/issues{/number}","pulls_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/pulls{/number}","milestones_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/milestones{/number}","notifications_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/labels{/name}","releases_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/releases{/id}","deployments_url":"https://api.github.com/repos/breiler/Universal-G-Code-Sender/deployments","created_at":"2018-02-01T07:27:52Z","updated_at":"2018-06-26T04:41:14Z","pushed_at":"2018-07-11T13:59:23Z","git_url":"git://github.com/breiler/Universal-G-Code-Sender.git","ssh_url":"git@github.com:breiler/Universal-G-Code-Sender.git","clone_url":"https://github.com/breiler/Universal-G-Code-Sender.git","svn_url":"https://github.com/breiler/Universal-G-Code-Sender","homepage":"http://winder.github.io/ugs_website/","size":48340,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"winder:master","ref":"master","sha":"afde06170b8e215e08314c65be0adba07cf2725e","user":{"login":"winder","id":125509,"node_id":"MDQ6VXNlcjEyNTUwOQ==","avatar_url":"https://avatars1.githubusercontent.com/u/125509?v=4","gravatar_id":"","url":"https://api.github.com/users/winder","html_url":"https://github.com/winder","followers_url":"https://api.github.com/users/winder/followers","following_url":"https://api.github.com/users/winder/following{/other_user}","gists_url":"https://api.github.com/users/winder/gists{/gist_id}","starred_url":"https://api.github.com/users/winder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/winder/subscriptions","organizations_url":"https://api.github.com/users/winder/orgs","repos_url":"https://api.github.com/users/winder/repos","events_url":"https://api.github.com/users/winder/events{/privacy}","received_events_url":"https://api.github.com/users/winder/received_events","type":"User","site_admin":false},"repo":{"id":4801382,"node_id":"MDEwOlJlcG9zaXRvcnk0ODAxMzgy","name":"Universal-G-Code-Sender","full_name":"winder/Universal-G-Code-Sender","owner":{"login":"winder","id":125509,"node_id":"MDQ6VXNlcjEyNTUwOQ==","avatar_url":"https://avatars1.githubusercontent.com/u/125509?v=4","gravatar_id":"","url":"https://api.github.com/users/winder","html_url":"https://github.com/winder","followers_url":"https://api.github.com/users/winder/followers","following_url":"https://api.github.com/users/winder/following{/other_user}","gists_url":"https://api.github.com/users/winder/gists{/gist_id}","starred_url":"https://api.github.com/users/winder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/winder/subscriptions","organizations_url":"https://api.github.com/users/winder/orgs","repos_url":"https://api.github.com/users/winder/repos","events_url":"https://api.github.com/users/winder/events{/privacy}","received_events_url":"https://api.github.com/users/winder/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/winder/Universal-G-Code-Sender","description":"A Java based GRBL compatible cross-platform G-Code sender.","fork":false,"url":"https://api.github.com/repos/winder/Universal-G-Code-Sender","forks_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/forks","keys_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/keys{/key_id}","collaborators_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/teams","hooks_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/hooks","issue_events_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/issues/events{/number}","events_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/events","assignees_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/assignees{/user}","branches_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/branches{/branch}","tags_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/tags","blobs_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/git/refs{/sha}","trees_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/git/trees{/sha}","statuses_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/statuses/{sha}","languages_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/languages","stargazers_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/stargazers","contributors_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/contributors","subscribers_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/subscribers","subscription_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/subscription","commits_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/commits{/sha}","git_commits_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/git/commits{/sha}","comments_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/comments{/number}","issue_comment_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/issues/comments{/number}","contents_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/contents/{+path}","compare_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/compare/{base}...{head}","merges_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/merges","archive_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/downloads","issues_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/issues{/number}","pulls_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/pulls{/number}","milestones_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/milestones{/number}","notifications_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/labels{/name}","releases_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/releases{/id}","deployments_url":"https://api.github.com/repos/winder/Universal-G-Code-Sender/deployments","created_at":"2012-06-26T22:30:07Z","updated_at":"2018-07-11T05:13:43Z","pushed_at":"2018-07-11T14:02:21Z","git_url":"git://github.com/winder/Universal-G-Code-Sender.git","ssh_url":"git@github.com:winder/Universal-G-Code-Sender.git","clone_url":"https://github.com/winder/Universal-G-Code-Sender.git","svn_url":"https://github.com/winder/Universal-G-Code-Sender","homepage":"http://winder.github.io/ugs_website/","size":48152,"stargazers_count":687,"watchers_count":687,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":381,"mirror_url":null,"archived":false,"open_issues_count":109,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":381,"open_issues":109,"watchers":687,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/winder/Universal-G-Code-Sender/pulls/1078"},"html":{"href":"https://github.com/winder/Universal-G-Code-Sender/pull/1078"},"issue":{"href":"https://api.github.com/repos/winder/Universal-G-Code-Sender/issues/1078"},"comments":{"href":"https://api.github.com/repos/winder/Universal-G-Code-Sender/issues/1078/comments"},"review_comments":{"href":"https://api.github.com/repos/winder/Universal-G-Code-Sender/pulls/1078/comments"},"review_comment":{"href":"https://api.github.com/repos/winder/Universal-G-Code-Sender/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/winder/Universal-G-Code-Sender/pulls/1078/commits"},"statuses":{"href":"https://api.github.com/repos/winder/Universal-G-Code-Sender/statuses/23815b4861cad1cd7c9989b96738815c3f13afbb"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"winder"}}