{"id":486,"date":"2014-08-10T00:26:00","date_gmt":"2014-08-09T23:26:00","guid":{"rendered":"http:\/\/ofalcao.pt\/blog\/?p=486"},"modified":"2014-08-10T00:26:00","modified_gmt":"2014-08-09T23:26:00","slug":"ev3dev-usando-o-lcd-do-ev3","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2014\/ev3dev-usando-o-lcd-do-ev3","title":{"rendered":"ev3dev &#8211; usando o LCD do EV3"},"content":{"rendered":"<p>Usando o ev3dev h\u00e1 duas formas de aceder ao LCD do LEGO Mindstorms EV3:<\/p>\n<ul>\n<li>modo de texto: terminal via \/dev\/tty0<\/li>\n<li>modo gr\u00e1fico: framebuffer via \/dev\/fb0<\/li>\n<\/ul>\n<p>Ambos os modos est\u00e3o ainda a sofrer desenvolvimentos mas o segundo modo \u00e9 seguramente o mais complexo pelo que fico-me por enquanto s\u00f3 pelo modo de texto.<\/p>\n<p>Assim para escrever qualquer coisa basta por exemplo redireccionar o comando echo para \/dev\/tty0:<\/p>\n<pre>echo \"Hello world!\" &gt; \/dev\/tty0<\/pre>\n<p>J\u00e1 \u00e9 qualquer coisa mas para limpar o ecran sem ter de enviar v\u00e1rios &#8220;echo&#8221; existem formas melhores. Sendo um terminal tty convencional, a maioria dos comandos para terminal devem funcionar (inclusive algumas sequencias de escape). Experimentei o tput:<\/p>\n<p>Para limpar o ecran:<\/p>\n<pre>tput clear &gt; \/dev\/tty0<\/pre>\n<p>Para posicionar o cursor:<\/p>\n<pre>tput cup linha coluna &gt; \/dev\/tty0<\/pre>\n<p>(tput cup 0 0 envia para o canto superior esquerdo e j\u00e1 agora com tput cols ficamos a saber que o LCD tem 44 colunas)<\/p>\n<p>Para escrever branco sobre negro:<\/p>\n<pre>tput smso &gt; \/dev\/tty0<\/pre>\n<p>Para voltar ao negro sobre branco:<\/p>\n<pre>tput rmso &gt; \/dev\/tty0<\/pre>\n<p>Muito bem, j\u00e1 escrevo o que quiser em qualquer lado do ecran&#8230; mas a fonte \u00e9 t\u00e3o pequena que s\u00f3 com uma lupa \u00e9 que se l\u00ea. Como aumentar o texto?<\/p>\n<p>A primeira hip\u00f3tese que me ocorreu foi instalar o figlet que usa caracteres ASCII para fingir fontes maiores:<\/p>\n<pre>apt-get install figlet\nfiglet -f banner \"Teste\" &gt; \/dev\/tty0\nfiglet -f big \"Teste\" &gt; \/dev\/tty0<\/pre>\n<p><a href=\"https:\/\/i0.wp.com\/151.236.52.166\/blog\/wp-content\/uploads\/2014\/08\/teste01.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-497\" src=\"https:\/\/i0.wp.com\/151.236.52.166\/blog\/wp-content\/uploads\/2014\/08\/teste01-1024x576.jpg?resize=584%2C328\" alt=\"teste01\" width=\"584\" height=\"328\" srcset=\"https:\/\/i0.wp.com\/ofalcao.pt\/blog\/wp-content\/uploads\/2014\/08\/teste01.jpg?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/ofalcao.pt\/blog\/wp-content\/uploads\/2014\/08\/teste01.jpg?resize=300%2C168&amp;ssl=1 300w, https:\/\/i0.wp.com\/ofalcao.pt\/blog\/wp-content\/uploads\/2014\/08\/teste01.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/ofalcao.pt\/blog\/wp-content\/uploads\/2014\/08\/teste01.jpg?w=1680&amp;ssl=1 1680w\" sizes=\"auto, (max-width: 584px) 85vw, 584px\" \/><\/a>mas \u00e9 uma forma um bocado coxa. O melhor mesmo \u00e9 poder trocar o tamanho dos caracteres e para isso existe o comando &#8220;setfont&#8221; que felizmente j\u00e1 existe no ev3dev e disponibiliza umas quantas fontes em &#8220;\/usr\/share\/consolefonts\/&#8221;, vejamos s\u00f3 quantas h\u00e1 na variante Lat15 (que serve \u00e0 maioria das linguas ocidentais incluindo a nossa):<\/p>\n<pre>root@ev3dev:~# ls \/usr\/share\/consolefonts\/Lat15*\n\/usr\/share\/consolefonts\/Lat15-Fixed13.psf.gz\n\/usr\/share\/consolefonts\/Lat15-Fixed14.psf.gz\n\/usr\/share\/consolefonts\/Lat15-Fixed15.psf.gz\n\/usr\/share\/consolefonts\/Lat15-Fixed16.psf.gz\n\/usr\/share\/consolefonts\/Lat15-Fixed18.psf.gz\n\/usr\/share\/consolefonts\/Lat15-Terminus12x6.psf.gz\n\/usr\/share\/consolefonts\/Lat15-Terminus14.psf.gz\n\/usr\/share\/consolefonts\/Lat15-Terminus16.psf.gz\n\/usr\/share\/consolefonts\/Lat15-Terminus20x10.psf.gz\n\/usr\/share\/consolefonts\/Lat15-Terminus22x11.psf.gz\n\/usr\/share\/consolefonts\/Lat15-Terminus24x12.psf.gz\n\/usr\/share\/consolefonts\/Lat15-Terminus28x14.psf.gz\n\/usr\/share\/consolefonts\/Lat15-Terminus32x16.psf.gz\n\/usr\/share\/consolefonts\/Lat15-TerminusBold14.psf.gz\n\/usr\/share\/consolefonts\/Lat15-TerminusBold16.psf.gz\n\/usr\/share\/consolefonts\/Lat15-TerminusBold20x10.psf.gz\n\/usr\/share\/consolefonts\/Lat15-TerminusBold22x11.psf.gz\n\/usr\/share\/consolefonts\/Lat15-TerminusBold24x12.psf.gz\n\/usr\/share\/consolefonts\/Lat15-TerminusBold28x14.psf.gz\n\/usr\/share\/consolefonts\/Lat15-TerminusBold32x16.psf.gz\n\/usr\/share\/consolefonts\/Lat15-TerminusBoldVGA14.psf.gz\n\/usr\/share\/consolefonts\/Lat15-TerminusBoldVGA16.psf.gz\n\/usr\/share\/consolefonts\/Lat15-TomThumb4x6.psf.gz\n\/usr\/share\/consolefonts\/Lat15-VGA14.psf.gz\n\/usr\/share\/consolefonts\/Lat15-VGA16.psf.gz\n\/usr\/share\/consolefonts\/Lat15-VGA28x16.psf.gz\n\/usr\/share\/consolefonts\/Lat15-VGA32x16.psf.gz\n\/usr\/share\/consolefonts\/Lat15-VGA8.psf.gz<\/pre>\n<p>Bold e 32&#215;16 parece-me bem por isso:<\/p>\n<pre>tput clear &gt; \/dev\/tty0\nsetfont \/usr\/share\/consolefonts\/Lat7-TerminusBold32x16.psf.gz\necho \"Hello World\" &gt; \/dev\/tty0<\/pre>\n<p><a href=\"https:\/\/i0.wp.com\/151.236.52.166\/blog\/wp-content\/uploads\/2014\/08\/helloworld.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-498\" src=\"https:\/\/i0.wp.com\/151.236.52.166\/blog\/wp-content\/uploads\/2014\/08\/helloworld.jpg?resize=840%2C473\" alt=\"helloworld\" width=\"840\" height=\"473\" srcset=\"https:\/\/i0.wp.com\/ofalcao.pt\/blog\/wp-content\/uploads\/2014\/08\/helloworld.jpg?w=1920&amp;ssl=1 1920w, https:\/\/i0.wp.com\/ofalcao.pt\/blog\/wp-content\/uploads\/2014\/08\/helloworld.jpg?resize=300%2C168&amp;ssl=1 300w, https:\/\/i0.wp.com\/ofalcao.pt\/blog\/wp-content\/uploads\/2014\/08\/helloworld.jpg?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/ofalcao.pt\/blog\/wp-content\/uploads\/2014\/08\/helloworld.jpg?w=1680&amp;ssl=1 1680w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>Os 11 caracteres de &#8220;Hello World&#8221; encheram uma linha (onde antes, com a fonte default, cabiam 44). Pelo menos j\u00e1 n\u00e3o \u00e9 precisa a lupa.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Usando o ev3dev h\u00e1 duas formas de aceder ao LCD do LEGO Mindstorms EV3: modo de texto: terminal via \/dev\/tty0 modo gr\u00e1fico: framebuffer via \/dev\/fb0 Ambos os modos est\u00e3o ainda a sofrer desenvolvimentos mas o segundo modo \u00e9 seguramente o mais complexo pelo que fico-me por enquanto s\u00f3 pelo modo de texto. Assim para escrever &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2014\/ev3dev-usando-o-lcd-do-ev3\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;ev3dev &#8211; usando o LCD do EV3&#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":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[16,18,19],"tags":[58,205,72,112,113],"series":[],"class_list":["post-486","post","type-post","status-publish","format-standard","hentry","category-geek","category-lego","category-lego-mindstorms","tag-ev3","tag-ev3dev","tag-lcd","tag-terminal","tag-texto"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2Mhyv-7Q","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/486","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=486"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/486\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=486"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}