{"id":336,"date":"2017-12-23T11:38:02","date_gmt":"2017-12-23T11:38:02","guid":{"rendered":"http:\/\/ceptimus.co.uk\/?p=336"},"modified":"2017-12-23T11:38:02","modified_gmt":"2017-12-23T11:38:02","slug":"e-paper-display-module-driven-by-arduino","status":"publish","type":"post","link":"https:\/\/ceptimus.co.uk\/index.php\/2017\/12\/23\/e-paper-display-module-driven-by-arduino\/","title":{"rendered":"E-paper display module driven by Arduino"},"content":{"rendered":"<p>These E-paper displays work well and look nice.\u00a0 At the time of writing you can get the 1.54 &#8211; inch size (200 x 200 pixels) from Banggood, but there are other sizes in the same range and my code should work with the bigger ones too.\u00a0 I have one on order to test.\u00a0 Search on eBay for Waveshare E-paper module.\u00a0 I&#8217;ve not tried the three colour (black, red, white) modules yet &#8211; those will need a tweak to the sketch.<\/p>\n<p>Edit (January 8th) have now received the larger 4.2 &#8211; inch 400 x 300 pixel module and this WON&#8217;T work with my code without considerable modification.\u00a0 The official Waveshare code doesn&#8217;t support partial refresh for this larger module at all.\u00a0 There is a <a href=\"https:\/\/github.com\/ZinggJM\/GxEPD\">library by ZinggJM<\/a> on GitHub that does support partial update but warns that it&#8217;s not official and could conceivably damage the display.\u00a0 I&#8217;ll look at it soon&#8230;\u00a0 (end of edit).<\/p>\n<p><iframe loading=\"lazy\" title=\"E-paper display - improved Arduino circuit\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/ZyCFZLZkgoU?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><\/p>\n<p>A naked AtMega 328 Arduino doesn&#8217;t really have enough RAM to drive these displays properly: even the 1.54 &#8211; inch display has a 5000 &#8211; byte display area and the display memory is write only.\u00a0 The AtMega 328 only has 2k of RAM so it can&#8217;t contain a memory buffer for the full screen and this makes graphics difficult.\u00a0 I overcame this problem by adding a serial RAM chip, 23LC1024, and using that as a paged memory display buffer.<\/p>\n<p>The display is 3.3V device and 5V signals may kill it!\u00a0 Best solution is to use a 3.3V Arduino.\u00a0 You can get the Pro Mini ones that work at 3.3V (and should have an 8MHz crystal).\u00a0 If you&#8217;re using a 5V Arduino, make sure to use some voltage level converters &#8211; you can get them in four or eight channel versions from Banggood or eBay.<\/p>\n<p>Here&#8217;s the circuit.<\/p>\n<p><a href=\"https:\/\/ceptimus.co.uk\/wp-content\/uploads\/2017\/12\/ePaperCircuit.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-338 aligncenter\" src=\"https:\/\/ceptimus.co.uk\/wp-content\/uploads\/2017\/12\/ePaperCircuit-300x208.jpg\" alt=\"\" width=\"551\" height=\"382\" \/><\/a><\/p>\n<p>I&#8217;ve attached the sketch.\u00a0 To use the &#8220;driver&#8221; in your own sketches just copy the ePaper.h and ePaper.cpp files to the same folder as your .ino file.\u00a0 Then you need a<\/p>\n<p>#include &#8220;ePaper.h&#8221;<\/p>\n<p>in your .ino file which then makes the following commands available:<\/p>\n<p>ePaper::start();\u00a0 Call from your setup() function before using any other ePaper commands<\/p>\n<p>ePaper::clearBuffer(true);\u00a0 Clears the display buffer to all white.\u00a0 Use false to clear it to all black.<\/p>\n<p>ePaper::displayFrame();\u00a0 Actually refreshes the display so you can see it.\u00a0 Normally you would do a bunch of other graphics operations (below) to create a display in the buffer before displaying it.<\/p>\n<p>ePaper::text(x,\u00a0 y,\u00a0 &#8220;string&#8221;,\u00a0 false);\u00a0 Displays string with top left at (x, y) using black text on a white background.\u00a0 Use true to display white text on black background.<\/p>\n<p>ePaper::textSmall(x, y, &#8220;string&#8221;, false); Same as ::text but using a smaller font.<\/p>\n<p>ePaper::pixel(x, y, false); Draws a black pixel at (x, y).\u00a0 Use true for a white pixel.<\/p>\n<p>ePaper::line(x1, y1, x2, y2, false); Draws a black straight line from (x1, y1) to (x2, y2).<\/p>\n<p>ePaper::rectangle(x1, y1, x2, y2, false); Draws a black rectangle outline using vertical and horizontal lines where (x1, y1) and (x2, y2) are the coordinates of diagonally opposite corners.<\/p>\n<p>ePaper::filledRectangle(x1, y1, x2, y2, false); Same as ::rectangle but the rectangle is solid black (or white if true is used) instead of just an outline.<\/p>\n<p>ePaper::circle(x1, y1, radius, false); Draws a circle outline in black with specified radius centred at (x1, y1);<\/p>\n<p>ePaper::filledCircle(x1, y1, radius, false); Same as ::circle, but filled.<\/p>\n<p>ePaper::fullUpdateMode();\u00a0 This sets the display so that ::displayFrame() does a complete update &#8211; this takes longer and causes the display to &#8220;flash&#8221;<\/p>\n<p>ePaper::partialUpdateMode(); This sets the display so that ::displayFrame() works faster and without &#8220;flashing&#8221;.\u00a0 The drawback is that with thousands of updates, perhaps spread over several days, the display isn&#8217;t as clear and may show greys in some areas rather than black or white.\u00a0 You should arrange your sketch to switch to fullUpdateMode and then do a displayFrame once occasionally to prevent this from happening.\u00a0 I normally do fullUpdateMode the first time when creating a fresh &#8220;page&#8221; and then use partialUpdateMode while updating\/animating that page.<\/p>\n<p>ePaper::sleep();\u00a0 This puts the display into very low power mode where the display should not then disappear even if the power is turned off.\u00a0 Recommended that your sketch does this if if doesn&#8217;t need to update the display for some time.<\/p>\n<p>ePaper::wake();\u00a0 Wakes from sleep.<\/p>\n<p>Here&#8217;s the sketch: <a href=\"https:\/\/ceptimus.co.uk\/ePaperDemo.zip\" target=\"_blank\" rel=\"noopener\">https:\/\/ceptimus.co.uk\/ePaperDemo.zip<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>These E-paper displays work well and look nice.\u00a0 At the time of writing you can get the 1.54 &#8211; inch size (200 x 200 pixels) from Banggood, but there are other sizes in the same range and my code should work with the bigger ones too.\u00a0 I have one on order to test.\u00a0 Search on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-336","post","type-post","status-publish","format-standard","hentry","category-arduino","category-programming"],"_links":{"self":[{"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=336"}],"version-history":[{"count":0,"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/336\/revisions"}],"wp:attachment":[{"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/categories?post=336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ceptimus.co.uk\/index.php\/wp-json\/wp\/v2\/tags?post=336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}