Coder Social home page Coder Social logo

epdisplay's Introduction

EPDisplay

Sofware controller for e-paper Display 1.54" B/W 200x200 WaveShare for Arduino.

To initialize the display use the using EPD = EPDisplay<200, 200>; directive.
To start using the display call EPD::wake(), EPD::clear().
To begin drawing use EPD::displayPartBaseWhiteImage() while to refresh the display use EPD::displayPartFrame().
Don't forget to call EPD::sleep() after usage to set deep-sleep mode.

Bitmaps

Bitmaps are stored in the bitmap data structure as a 1-dimensional array of bytes, along with width (in pixels, divisible by 8) and height (not restricted). That is problematic because 1 byte corresponds to 8 pixels hence pictures can only be drawn x-aligned and every padding bit will override the existing pixels on the screen so keep that in mind.

There is a Deno Javascript file resources/png2bitmap.js that is able to convert (RGBA or RGBA color space, 8-bit depth) .png pictures into header files that can be directly included and used in the code.

#include "epdisplay.hpp"
#include "bitmaps/casper.hpp"

/// e-Paper Display 1.54" 200x200 W / B Waveshare
using EPD = EPDisplay<200, 200>;

void setup() {

	EPD::wake();
	EPD::clear();
	EPD::displayPartBaseImage();

	EPD::draw(casper_BITMAP, 8, 8);
	EPD::draw<2>(casper_BITMAP, 32, 32); // scale 2x
	EPD::draw<3>(casper_BITMAP, 72, 72); // scale 3x

	EPD::displayPartFrame();
	EPD::sleep();

}

void loop() { }

Fonts

Fonts are stored in the (monospaced) font data structure along with real width and height (without padding, in pixels) and vertical and horizontal spacing. The padded width is calculated automatically.

Courier New (8pt, 12pt, 16pt, 20pt and 24pt) is provided here.

The text bitmap data needs to contain the following characters with this specific order, to minimize PROGMEM space:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
"#$%&'?!*+,-./0123456789:;

As you can see it resembles chunks of ASCII but with the difference being the ? and ! characters in place of ( and ).

Text can be drawn using the EPD::text method which calulates line-width and wraps when necessary as well as when it finds \n LF.

#include "epdisplay.hpp"
#include "fonts/Courier_New/Courier_New.hpp"

/// e-Paper Display 1.54" 200x200 W / B Waveshare
using EPD = EPDisplay<200, 200>;

void setup() {

	EPD::wake();
	EPD::clear();
	EPD::displayPartBaseImage();

	EPD::text("Hello World!", 0, 0, Courier_New(20));

	EPD::displayPartFrame();
	EPD::sleep();

}

void loop() { }

epdisplay's People

Contributors

cristian-5 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.