{"id":765,"date":"2016-09-03T17:32:34","date_gmt":"2016-09-03T08:32:34","guid":{"rendered":"http:\/\/jumbleat.com\/?p=765"},"modified":"2017-06-18T22:56:09","modified_gmt":"2017-06-18T13:56:09","slug":"how_to_use_u8glib_part1","status":"publish","type":"post","link":"https:\/\/jumbleat.com\/en\/2016\/09\/03\/how_to_use_u8glib_part1\/","title":{"rendered":"Use OLED with &#8220;u8glib&#8221; : <span class=\"sub_title\">part 1<\/span>"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u76ee\u6b21 [ Contents ]<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69d0c64b8a3dc\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #757575;color:#757575\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #757575;color:#757575\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69d0c64b8a3dc\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/jumbleat.com\/en\/2016\/09\/03\/how_to_use_u8glib_part1\/#u8glib\" >u8glib<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/jumbleat.com\/en\/2016\/09\/03\/how_to_use_u8glib_part1\/#Display\" >Display<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/jumbleat.com\/en\/2016\/09\/03\/how_to_use_u8glib_part1\/#Watch_sample_sketches\" >Watch sample sketches<\/a><\/li><\/ul><\/nav><\/div>\n<p><\/p>\n<section id=\"prolog\">\n<p>You maybe use a display when you want to check\u00a0the values without Serial Monitor. <!--more-->And perhaps it could\u00a0be <a href=\"https:\/\/www.amazon.co.jp\/gp\/product\/B00MQOMB46\/ref=as_li_tf_tl?ie=UTF8&amp;camp=247&amp;creative=1211&amp;creativeASIN=B00MQOMB46&amp;linkCode=as2&amp;tag=jumbleat-22\">LCD<\/a><img loading=\"lazy\" decoding=\"async\" style=\"border: none !important; margin: 0px !important;\" src=\"http:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=jumbleat-22&amp;l=as2&amp;o=9&amp;a=B00MQOMB46\" alt=\"\" width=\"1\" height=\"1\" border=\"0\" \/>. But you can have a another option. That is <a href=\"https:\/\/www.amazon.co.jp\/gp\/product\/B00XDY2SR8\/ref=as_li_tf_tl?ie=UTF8&amp;camp=247&amp;creative=1211&amp;creativeASIN=B00XDY2SR8&amp;linkCode=as2&amp;tag=jumbleat-22\">OLED<\/a><img loading=\"lazy\" decoding=\"async\" style=\"border: none !important; margin: 0px !important;\" src=\"http:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=jumbleat-22&amp;l=as2&amp;o=9&amp;a=B00XDY2SR8\" alt=\"\" width=\"1\" height=\"1\" border=\"0\" \/> which you can get in places like Amazon.\u00a0Quality is good enough, and price as well. One thing of the matter is it has difficulty because it is graphic type display.<\/p>\n<p>But you can use OLED graphic display by using &#8216;u8glib library&#8217;. I was confused at first, because this library has some habits.<\/p>\n<p>So I want to mention to the tips by this articles, as far as possible. At first, I apology to you if I had made wrong knowledge. Sorry.<\/p>\n<\/section>\n<section id=\"chap_1\">\n<h2 class=\"h2_HLine mtm mbs\"><span class=\"ez-toc-section\" id=\"u8glib\"><\/span>u8glib<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>&#8220;u8glib&#8221; is Arduino versatile library for graphic display.\u00a0Nowaday, You can get &#8220;u8glib&#8221; from Arduino IDE. Also you can download from <a href=\"https:\/\/github.com\/olikraus\/u8glib\" target=\"_blank\">GitHub<\/a>. Although there is new &#8220;version 2&#8221; on IDE installer. I use &#8220;version 1&#8221; in this article, because I have never use new one, sorry.<\/p>\n<\/section>\n<section id=\"chap_2\">\n<h2 class=\"h2_HLine mtm mbs\"><span class=\"ez-toc-section\" id=\"Display\"><\/span>Display<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>OLED is meant &#8220;organic light-emitting diode&#8221;. It&#8217;s very high luminance and beautiful.\u00a0So many electric parts shop sells it.\u00a0Probably it&#8217;s easy to find reasonable one.<\/p>\n<p>I got these at japanese Amazon market.<\/p>\n<p><a href=\"https:\/\/www.amazon.co.jp\/gp\/product\/B00XDY2SR8\/ref=as_li_tf_tl?ie=UTF8&amp;camp=247&amp;creative=1211&amp;creativeASIN=B00XDY2SR8&amp;linkCode=as2&amp;tag=jumbleat-22\">[GPG] I2C 128&#215;64 OLED Display<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-848 alignnone\" src=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/u8glib_OLED_package_I2c-300x210.jpg\" alt=\"u8glib_OLED_package_I2c\" width=\"300\" height=\"210\" srcset=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/u8glib_OLED_package_I2c-300x210.jpg 300w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/u8glib_OLED_package_I2c.jpg 500w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p class=\"mtl\">Also there is SPI display at different price.<\/p>\n<p><a href=\"https:\/\/www.amazon.co.jp\/gp\/product\/B017XH0WL4\/ref=as_li_tf_tl?ie=UTF8&amp;camp=247&amp;creative=1211&amp;creativeASIN=B017XH0WL4&amp;linkCode=as2&amp;tag=jumbleat-22\">EasyWordMall 3.3V-5V SPI white\u00a0OLED display 128&#215;64<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-849\" src=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/u8glib_OLED_package_SPI-300x210.jpg\" alt=\"u8glib_OLED_package_SPI\" width=\"300\" height=\"210\" srcset=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/u8glib_OLED_package_SPI-300x210.jpg 300w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/u8glib_OLED_package_SPI.jpg 500w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>Try find it at yourself on web.<\/p>\n<p>I2C and SPI are protocols used between devices. I recommend you SPI if you want faster refresh rate.\u00a0Otherwise I2C is convenient for fewer pins.<\/p>\n<p>There is video which I check the difference of transmit speed. Please check it.<\/p>\n<p><div class=\"jetpack-video-wrapper\"><iframe loading=\"lazy\" title=\"I2C vs SPI\" width=\"660\" height=\"371\" src=\"https:\/\/www.youtube.com\/embed\/Wz6Fzo3rsLM?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<\/p>\n<p>SPI has advantage for general use to compatibles. Because I2C display didn&#8217;t work on SAMD21 or Teensy. Or &#8220;version 2&#8221; might solve this problem, I don&#8217;t know. Anyway, I can take operation guarantee on Arduino UNO and promini.<\/p>\n<\/section>\n<section id=\"chap_3\">\n<h2 class=\"h2_HLine mtm mbs\"><span class=\"ez-toc-section\" id=\"Watch_sample_sketches\"><\/span>Watch sample sketches<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Let&#8217;s watch samples to operation check, first.<\/p>\n<p><a href=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/simple_wiring_u8g_SPI_breadboard.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-787 size-large\" src=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/simple_wiring_u8g_SPI_breadboard-1024x512.png\" alt=\"simple_wiring_u8g_SPI_breadboard\" width=\"660\" height=\"330\" srcset=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/simple_wiring_u8g_SPI_breadboard.png 1024w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/simple_wiring_u8g_SPI_breadboard-300x150.png 300w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/simple_wiring_u8g_SPI_breadboard-768x384.png 768w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><\/a><\/p>\n<p>This is illustration for wiring. Please check allowable voltage of your display. This wiring is specified to 5 voltage work.<\/p>\n<p>Connect SDA pin and SCL pin if you use I2C display instead.<\/p>\n<p>Then install &#8220;u8glib&#8221; library to your IDE if you haven&#8217;t it yet.<\/p>\n<p><a href=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/u8glib_install.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-789 size-large\" src=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/u8glib_install-1024x291.jpg\" alt=\"u8glib_install\" width=\"660\" height=\"188\" srcset=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/u8glib_install.jpg 1024w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/u8glib_install-300x85.jpg 300w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/u8glib_install-768x218.jpg 768w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><\/a><\/p>\n<p>Open the sample sketch &#8220;GraphicTest&#8221;.<\/p>\n<p><a href=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/lib_sample_sketch.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-788 size-medium\" src=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/lib_sample_sketch-239x300.jpg\" alt=\"lib_sample_sketch\" width=\"239\" height=\"300\" srcset=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/lib_sample_sketch-239x300.jpg 239w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/lib_sample_sketch-768x964.jpg 768w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/lib_sample_sketch.jpg 816w\" sizes=\"auto, (max-width: 239px) 100vw, 239px\" \/><\/a><\/p>\n<p>You need to change on the sketch. It does not work as it is.<\/p>\n<p>Check codes at the beginning. There are lots of code for each setting.\u00a0You have to remove &#8216;\/\/&#8217; mark. It depends on your display.<\/p>\n<p><a href=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/lib_sample_sketch_define.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-791 size-large\" src=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/lib_sample_sketch_define-1024x726.jpg\" alt=\"lib_sample_sketch_define\" width=\"660\" height=\"468\" srcset=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/lib_sample_sketch_define.jpg 1024w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/lib_sample_sketch_define-300x213.jpg 300w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/lib_sample_sketch_define-768x545.jpg 768w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><\/a><\/p>\n<p>My SPI is, for example,<br \/>\n \/\/U8GLIB_SSD1306_128X64 u8g(4, 5, 6, 7);<\/p>\n<p>For\u00a0I2C,<br \/>\n \/\/U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0);<\/p>\n<p>or,<br \/>\n \/\/U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_NO_ACK|U8G_I2C_OPT_FAST);<\/p>\n<p>Then you can run the sketch.\u00a0I couldn&#8217;t figure out this style and it took several time.<\/p>\n<p>You know how to watch those sample sketches now. Try other samples.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-798\" src=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/u8glib_sample_disp-300x150.jpg\" alt=\"u8glib_sample_disp\" width=\"300\" height=\"150\" srcset=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/u8glib_sample_disp-300x150.jpg 300w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/u8glib_sample_disp.jpg 600w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<\/section>\n<section id=\"epilog\">\n<p class=\"mts\">Next, I will mentioned to how to draw graphics.<br \/>\n<a href=\"https:\/\/jumbleat.com\/2016\/09\/03\/how_to_use_u8glib_part2\/\"><strong><span style=\"color: #3366ff;\">Part2<\/span><\/strong><\/a><\/p>\n<\/section>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Sorry, this entry is only available in \u65e5\u672c\u8a9e. For the sake of viewer convenience, the content is shown below in  &hellip; <a href=\"https:\/\/jumbleat.com\/en\/2016\/09\/03\/how_to_use_u8glib_part1\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Use OLED with &#8220;u8glib&#8221; : <span class=\"sub_title\">part 1<\/span><\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":792,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[5,8],"tags":[80,75,82,77,73,74,76,79,81],"class_list":["post-765","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-electric","tag-draw","tag-graphic-display","tag-oled","tag-screen","tag-u8glib","tag-74","tag-76","tag-79","tag-el"],"jetpack_featured_media_url":"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/09\/e_catch_u8glib_p1.jpg","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7JALB-cl","jetpack_likes_enabled":false,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/posts\/765","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/comments?post=765"}],"version-history":[{"count":4,"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/posts\/765\/revisions"}],"predecessor-version":[{"id":6826,"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/posts\/765\/revisions\/6826"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/media\/792"}],"wp:attachment":[{"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/media?parent=765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/categories?post=765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/tags?post=765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}