{"id":770,"date":"2014-10-30T09:44:28","date_gmt":"2014-10-30T09:44:28","guid":{"rendered":"http:\/\/ofalcao.pt\/blog\/?p=770"},"modified":"2014-10-30T09:44:28","modified_gmt":"2014-10-30T09:44:28","slug":"sbrick-remote-control-2","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2014\/sbrick-remote-control-2","title":{"rendered":"SBrick Remote Control"},"content":{"rendered":"<p>A fast incursion in Python and Tkinter (a very easy GUI library for those like me who abuse from Google-Copy-Paste) so I can play with <a title=\"Vengit SBrick\" href=\"http:\/\/www.sbrick.com\/\">SBrick<\/a> from my Ubuntu laptop without the command line:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-730\" src=\"https:\/\/i0.wp.com\/ofalcao.pt\/blog\/wp-content\/uploads\/2014\/10\/SBrick-RemoteControl.png?resize=254%2C201\" alt=\"SBrick-RemoteControl\" width=\"254\" height=\"201\" \/><\/p>\n<div class=\"jetpack-video-wrapper\"><iframe loading=\"lazy\" title=\"SBrick RemoteControl v01\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/wBU7oMKKVT8?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/div>\n<pre>#!\/usr\/bin\/env python \r\n\r\nfrom Tkinter import *\r\nfrom time import sleep\r\nfrom subprocess import call\r\n\r\ndef quit():\r\n  global Window\r\n  Window.destroy()\r\n\r\n  return;\r\n\r\ndef STOP():\r\n\r\n  call(\"gatttool -b 00:07:80:7F:28:E1 -i hci0 --char-write --handle=0x0025 --value=0002\",shell=True)\r\n  call(\"gatttool -b 00:07:80:7F:28:E1 -i hci0 --char-write --handle=0x0025 --value=0003\",shell=True)\r\n  return\r\n\r\ndef NORTH():\r\n\r\n  time=scale.get()\r\n  call(\"gatttool -b 00:07:80:7F:28:E1 -i hci0 --char-write --handle=0x0025 --value=010301FF\",shell=True)\r\n  call(\"gatttool -b 00:07:80:7F:28:E1 -i hci0 --char-write --handle=0x0025 --value=010200FF\",shell=True)\r\n  sleep(time)\r\n  STOP()\r\n  return\r\n\r\ndef SOUTH():\r\n\r\n  time=scale.get()\r\n  call(\"gatttool -b 00:07:80:7F:28:E1 -i hci0 --char-write --handle=0x0025 --value=010300FF\",shell=True)\r\n  call(\"gatttool -b 00:07:80:7F:28:E1 -i hci0 --char-write --handle=0x0025 --value=010201FF\",shell=True)\r\n  print(\"Backward\")\r\n  sleep(time)\r\n  STOP()\r\n  return\r\n\r\ndef EAST():\r\n\r\n  time=scale.get()\r\n  call(\"gatttool -b 00:07:80:7F:28:E1 -i hci0 --char-write --handle=0x0025 --value=010301FF\",shell=True)\r\n  call(\"gatttool -b 00:07:80:7F:28:E1 -i hci0 --char-write --handle=0x0025 --value=010201FF\",shell=True)\r\n  print(\"RIGHT\")\r\n  sleep(time)\r\n  STOP()\r\n  return\r\n\r\ndef WEST():\r\n\r\n  time=scale.get()\r\n  call(\"gatttool -b 00:07:80:7F:28:E1 -i hci0 --char-write --handle=0x0025 --value=010200FF\",shell=True)\r\n  call(\"gatttool -b 00:07:80:7F:28:E1 -i hci0 --char-write --handle=0x0025 --value=010300FF\",shell=True)\r\n  sleep(time)\r\n  STOP()\r\n  return\r\n\r\n\r\nWindow = Tk()\r\nWindow.title(\"SBrick Remote Control v0.1\")\r\n\r\nB_North = Button(text = \"N\", command = NORTH)\r\nB_North.grid(row=0, column=1)\r\n\r\nB_West = Button(text = \"W\", command = WEST)\r\nB_West.grid(row=1, column=0)\r\n\r\nB_STOP = Button(text = \"STOP\", command = STOP)\r\nB_STOP.grid(row=1, column=1)\r\n\r\nB_East = Button(text = \"E\", command = EAST)\r\nB_East.grid(row=1, column=2)\r\n\r\nB_South = Button(text = \"S\", command = SOUTH)\r\nB_South.grid(row=2, column=1)\r\n\r\nscale = Scale(Window, from_=0.125, to=2.5, digits=3, resolution=0.125, orient=HORIZONTAL, length=250, label=\"Time\")\r\nscale.grid(row=3,column=0,columnspan=3)\r\n\r\nB_QUIT = Button(text = \"QUIT\", command = quit)\r\nB_QUIT.grid(row=4, column=1, )\r\n\r\nmainloop()<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A fast incursion in Python and Tkinter (a very easy GUI library for those like me who abuse from Google-Copy-Paste) so I can play with SBrick from my Ubuntu laptop without the command line: #!\/usr\/bin\/env python from Tkinter import * from time import sleep from subprocess import call def quit(): global Window Window.destroy() return; def &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2014\/sbrick-remote-control-2\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;SBrick Remote Control&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[141],"tags":[227,149,144],"series":[],"class_list":["post-770","post","type-post","status-publish","format-standard","hentry","category-sem-categoria-en","tag-linux-en","tag-power-functions-en","tag-sbrick-en"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2Mhyv-cq","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/comments?post=770"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/770\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=770"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}