{"id":1678,"date":"2014-10-29T09:10:19","date_gmt":"2014-10-29T09:10:19","guid":{"rendered":"http:\/\/bitmap2lcd.com\/blog\/?p=1678"},"modified":"2014-10-29T09:10:19","modified_gmt":"2014-10-29T09:10:19","slug":"code-example-displaying-a-bitmap-on-graphic-lcd","status":"publish","type":"post","link":"https:\/\/bitmap2lcd.com\/blog\/code-example-displaying-a-bitmap-on-graphic-lcd\/","title":{"rendered":"Code example : Displaying a bitmap on Graphic LCD"},"content":{"rendered":"<h3><span style=\"color: #808080;\"><strong><em>Bitmap2LCD is a tool for programming small Graphic LCDs in embedded systems and a programmable graphic and text processing tool.<\/em><\/strong><\/span><\/h3>\n<h3>Code example : Displaying a bitmap on a Graphic LCD<\/h3>\n<p><em><span style=\"color: #000000;\">Example for an Atmel AVR Microcontroller + a monochrome 128 x 64 Dot Matrix GLCD + using a KS0108 GLCD Controller Library.<\/span><\/em><\/p>\n<p>&nbsp;<\/p>\n<h6><span style=\"color: #808080;\">#include &lt;avr\/io.h&gt;<\/span><br \/>\n<span style=\"color: #808080;\"> #include &#8220;C:\\Users\\BE\\GLCD Lib\\KS0108.c&#8221;<\/span><br \/>\n<span style=\"color: #808080;\"> #include &#8220;C:\\Users\\BE\\GLCD Lib\\KS0108-AVR.c&#8221;<\/span><br \/>\n<span style=\"color: #808080;\"> #include &#8220;C:\\Users\\BE\\Documents\\Bitmap2LCD Project\\Output Files\\NewBitmap.h&#8221;<\/span><\/h6>\n<h6><span style=\"color: #808080;\">void LoadBitmap(const uint8_t *bitmap)<\/span><br \/>\n<span style=\"color: #808080;\"> {<\/span><br \/>\n<span style=\"color: #808080;\"> uint8_t i, j;<\/span><\/h6>\n<h6><span style=\"color: #808080;\">for(i=0; i&lt;64; i+=8)<\/span><\/h6>\n<h6><span style=\"color: #808080;\">for(j=0; j&lt;128; j++)<\/span><br \/>\n<span style=\"color: #808080;\"> {<\/span><br \/>\n<span style=\"color: #808080;\"> GLCD_GoTo(j, i);<\/span><br \/>\n<span style=\"color: #808080;\"> GLCD_WriteData(pgm_read_byte(bitmap++));<\/span><\/h6>\n<h6><span style=\"color: #808080;\">}<\/span><br \/>\n<span style=\"color: #808080;\"> }<\/span><\/h6>\n<h6><span style=\"color: #808080;\">int main(void)<\/span><br \/>\n<span style=\"color: #808080;\"> {<\/span><br \/>\n<span style=\"color: #808080;\"> while(1)<\/span><br \/>\n<span style=\"color: #808080;\"> {<\/span><br \/>\n<span style=\"color: #808080;\"> LoadBitmap(NewBitmap);<\/span><br \/>\n<span style=\"color: #808080;\"> }<\/span><br \/>\n<span style=\"color: #808080;\"> }<\/span><\/h6>\n<p>&nbsp;<\/p>\n<p><strong>Newbitmap.h<br \/>\n<\/strong><\/p>\n<p><em>The 128 x 64 pixels bitmap converted to data array<\/em><\/p>\n<h6><span style=\"color: #808080;\">#include &lt;avr\/pgmspace.h&gt; <\/span><br \/>\n<span style=\"color: #808080;\">\u00a0 <\/span><br \/>\n<span style=\"color: #808080;\">\u00a0const uint8_t\u00a0 NewBitmap [] = { <\/span><br \/>\n<span style=\"color: #808080;\">\u00a0 <\/span><br \/>\n<span style=\"color: #808080;\">\u00a00x20 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x02,<\/span><br \/>\n<span style=\"color: #808080;\">\u00a00x10 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x04,<\/span><\/h6>\n<h6><span style=\"color: #808080;\">&#8230;\u00a0 Bitmap 1024 Data bytes in Total<br \/>\n<\/span><\/h6>\n<h6><span style=\"color: #808080;\">0x80 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00,<\/span><br \/>\n<span style=\"color: #808080;\">\u00a00x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00<\/span><br \/>\n<span style=\"color: #808080;\">};<\/span><\/h6>\n<p>&nbsp;<\/p>\n\t<div class=\"quickshare-container\">\r\n\t<ul class=\"quickshare-genericons quickshare-effect-round quickshare-effect-expand quickshare-small\">\r\n\t\t<li class=\"quickshare-share\"><\/li> \r\n\t\t<li><a href=\"https:\/\/facebook.com\/sharer.php?u=https%3A%2F%2Fbitmap2lcd.com%2Fblog%2Fcode-example-displaying-a-bitmap-on-graphic-lcd%2F&amp;t=Code+example+%3A+Displaying+a+bitmap+on+Graphic+LCD+<+Bitmap2LCD+Software+Tool+Blog+%3A%3A+about+GLCD+displays+and+Programming\" target=\"_blank\" title=\"Share on Facebook\"><span class=\"quickshare-facebook\">Facebook<\/span><\/a><\/li>\t\t<li><a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fbitmap2lcd.com%2Fblog%2Fcode-example-displaying-a-bitmap-on-graphic-lcd%2F&amp;text=Code+example+%3A+Displaying+a+bitmap+on+Graphic+LCD+<+Bitmap2LCD+Software+Tool+Blog+%3A%3A+about+GLCD+displays+and+Programming\" target=\"_blank\" title=\"Share on Twitter\"><span class=\"quickshare-twitter\">Twitter<\/span><\/a><\/li>\t\t<li><a href=\"http:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Fbitmap2lcd.com%2Fblog%2Fcode-example-displaying-a-bitmap-on-graphic-lcd%2F&amp;media=&amp;description=Bitmap2LCD+is+a+tool+for+programming+small+Graphic+LCDs+in+embedded+systems+and+a+programmable+graphic+and+text+processing+tool.+Code+example+%3A+Displaying+a+bitmap+on+a+Graphic+LCD+Example+for+an+Atmel+AVR+Microcontroller+%2B+a+monochrome+128%26hellip%3B\" target=\"_blank\" title=\"Share on Pinterest\"><span class=\"quickshare-pinterest\">Pinterest<\/span><\/a><\/li>\t\t<li><a href=\"http:\/\/linkedin.com\/shareArticle?mini=true&amp;url=https%3A%2F%2Fbitmap2lcd.com%2Fblog%2Fcode-example-displaying-a-bitmap-on-graphic-lcd%2F&amp;title=Code+example+%3A+Displaying+a+bitmap+on+Graphic+LCD&amp;source=Bitmap2LCD+Software+Tool+Blog+%3A%3A+about+GLCD+displays+and+Programming&amp;summary=Bitmap2LCD+is+a+tool+for+programming+small+Graphic+LCDs+in+embedded+systems+and+a+programmable+graphic+and+text+processing+tool.+Code+example+%3A+Displaying+a+bitmap+on+a+Graphic+LCD+Example+for+an+Atmel+AVR+Microcontroller+%2B+a+monochrome+128%26hellip%3B\" title=\"Share on Linkedin\" target=\"_blank\"><span class=\"quickshare-linkedin\">Linkedin<\/span><\/a><\/li>\t\t<li><a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fbitmap2lcd.com%2Fblog%2Fcode-example-displaying-a-bitmap-on-graphic-lcd%2F\" target=\"_blank\" title=\"Share on Google+\"><span class=\"quickshare-googleplus\">Google+<\/span><\/a><\/li>\t\t\t\t\t\t\t\t<li><a href=\"mailto:?subject=Bitmap2LCD+Software+Tool+Blog+%3A%3A+about+GLCD+displays+and+Programming:+Code+example+%3A+Displaying+a+bitmap+on+Graphic+LCD&amp;body=https%3A%2F%2Fbitmap2lcd.com%2Fblog%2Fcode-example-displaying-a-bitmap-on-graphic-lcd%2F\" target=\"_blank\" title=\"Share via Email\"><span class=\"quickshare-email\">Email<\/span><\/a><\/li>\t<\/ul>\r\n\t<\/div>\r\n","protected":false},"excerpt":{"rendered":"<p>Bitmap2LCD is a tool for programming small Graphic LCDs in embedded systems and a programmable graphic and text processing tool. Code example : Displaying a bitmap on a Graphic LCD Example for an Atmel AVR Microcontroller + a monochrome 128 x 64 Dot Matrix GLCD + using a KS0108 GLCD Controller Library. &nbsp; #include &lt;avr\/io.h&gt; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[50,91],"tags":[565,567,566,563,564,568,569,570],"class_list":["post-1678","post","type-post","status-publish","format-standard","hentry","category-convert-a-bitmap-to-glcd","category-about-bitmap2lcd","tag-atmel-avr-and-glcd","tag-avr-code-example","tag-display-a-bitmap","tag-display-bitmap-glcd","tag-draw-bitmap-on-graphic-lcd","tag-how-to-display-a-bitmap","tag-loadbitmap","tag-pgm_read_byte"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/bitmap2lcd.com\/blog\/wp-json\/wp\/v2\/posts\/1678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bitmap2lcd.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bitmap2lcd.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bitmap2lcd.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bitmap2lcd.com\/blog\/wp-json\/wp\/v2\/comments?post=1678"}],"version-history":[{"count":7,"href":"https:\/\/bitmap2lcd.com\/blog\/wp-json\/wp\/v2\/posts\/1678\/revisions"}],"predecessor-version":[{"id":1685,"href":"https:\/\/bitmap2lcd.com\/blog\/wp-json\/wp\/v2\/posts\/1678\/revisions\/1685"}],"wp:attachment":[{"href":"https:\/\/bitmap2lcd.com\/blog\/wp-json\/wp\/v2\/media?parent=1678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bitmap2lcd.com\/blog\/wp-json\/wp\/v2\/categories?post=1678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bitmap2lcd.com\/blog\/wp-json\/wp\/v2\/tags?post=1678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}