Skip to content

Commit

Permalink
chore: reorganize examples; wireless_paper.md
Browse files Browse the repository at this point in the history
  • Loading branch information
todd-herbert committed Feb 14, 2024
1 parent bc2d951 commit e9d55e3
Show file tree
Hide file tree
Showing 17 changed files with 269 additions and 8 deletions.
45 changes: 39 additions & 6 deletions docs/WirelessPaper/wireless_paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Only the board's E-Ink display falls within the scope of this library.
- [Getting Started](#getting-started)
- [Arduino IDE](#arduino-ide)
- [PlatformIO](#platformio)
- [Using the library](#using-the-library)
- [Things to know](#things-to-know)
- [`VExtOn()`](#vexton)
- [Deep Sleep](#deep-sleep)
Expand Down Expand Up @@ -44,12 +45,6 @@ This may take some time.

![](ArduinoIDE/select_board.jpg)

You should now be able to upload the the "wireless_paper" example from *File > Examples > heltec-eink-modules > wireless_paper*. The process may be slow, when compiling for the first time.

Make sure to select your [display model](/docs/README.md#wireless-paper) first, at the top of the sketch.

Most of the other examples will also run on the Wireless Paper board, so long as you select the correct display model.

### PlatformIO

Add the following entry to your `platformio.ini` file
Expand All @@ -62,6 +57,44 @@ framework = arduino
lib_deps = https://github.com/todd-herbert/heltec-eink-modules
```

## Using the library

Check out the examples, such as *File > Examples > heltec-eink-modules > WirelessPaper > basic* <br />
Make sure to select your [display model](/docs/README.md#wireless-paper) first, at the top of the sketch.

The upload process will be slow when compiling for the first time. Saving your sketch allows the IDE to re-use much of the old code, without recompiling.

**Here's a rough idea:**
```cpp
#include <heltec-eink-modules.h>

// Pick your display model:

// DEPG0213BNS800 display; // (Red Tab)
// LCMEN2R13EFC1 display; // (Green Tab, V1.1)

void setup() {
display.landscape();

display.print("Hello, World!");
display.update();

delay(2000);

display.clearMemory();
display.printCenter("Centered Text");
display.update();

delay(2000);

display.clear();
}

void loop() {

}
```

## Things to know

### `VExtOn()`
Expand Down
88 changes: 88 additions & 0 deletions examples/Wireless Paper/basic/basic.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include <heltec-eink-modules.h>

// Pick your panel - https://github.com/todd-herbert/heltec-eink-modules#supported-displays
// ---------------

// -- "Wireless Paper" boards only --

// DEPG0213BNS800 display; // (Red Tab)
// LCMEN2R13EFC1 display; // (Green Tab)


// DEMO: Wireless Paper - Basic
// --------------------
// This example is only for Heltec's "Wireless Paper" all-in-one boards.
// A simple sketch to get you going

#include "Fonts/FreeSans9pt7b.h"
#include "Fonts/FreeSansBold9pt7b.h"

void setup() {
display.print("Hello, world!");
display.update();

delay(4000);
display.clearMemory(); // Start a new drawing

display.landscape();
display.setFont( &FreeSans9pt7b );
display.printCenter("In the middle.");
display.update();

delay(4000);
display.clearMemory(); // Start a new drawing

display.setCursor(5, 20); // Text Cursor - x:5 y:20
display.println("Here's a normal update.");
display.update();

delay(2000); // Pause to read

display.fastmodeOn();
display.println("Here's fastmode,");
display.update();
display.println("aka Partial Refresh.");
display.update();

delay(2000); // Pause to read

display.fastmodeOff();
display.setFont( &FreeSansBold9pt7b ); // Change to bold font
display.println();
display.println("Don't use too often!");
display.update();

delay(4000);
display.clear(); // Physically clear the screen

display.fastmodeOn();
display.setFont( NULL ); // Default Font
display.printCenter("How about a spot?", 0, -40); // 40px above center
display.update();

delay(2000);

display.fastmodeOff();
display.fillCircle(
display.bounds.full.centerX(), // X: center screen
display.bounds.full.centerY(), // Y: center screen
10, // Radius: 10px
BLACK // Color: black
);
display.update();

delay(2000);

// Here's a convenient trick:
FullBounds f = display.bounds.full;

display.drawCircle(f.centerX(), f.centerY(), 5, WHITE); // Draw a smaller white circle inside, giving a "ring" shape
display.update();

delay(10000);
display.clear(); // Physically clear the screen, ready for your next masterpiece
}

void loop() {

}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
// #include <RadioLib.h>


// DEMO: Wireless Paper
// DEMO: Wireless Paper Hardware
// --------------------
// This example is only for Heltec's "Wireless Paper" all-in-one boards.
// A basic demonstration that the onboard hardware does work with this display library.
//
// This example does not demonstrate *good technique* for using the wireless hardware.
// Please refer to each libraries own documentation before using them in your project.
// Please refer to each library's own documentation before using them in your project.


// For Wifi Demo
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
140 changes: 140 additions & 0 deletions examples/text/text.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#include <heltec-eink-modules.h>

// Find your wiring - https://github.com/todd-herbert/heltec-eink-modules#wiring
// ----------------

#define PIN_DC 2
#define PIN_CS 4
#define PIN_BUSY 5

// "Wireless Paper" boards: skip this, your wiring is pre-set


// Pick your panel - https://github.com/todd-herbert/heltec-eink-modules#supported-displays
// ---------------

// -- SPI Displays --

// DEPG0150BNS810 display( PIN_DC, PIN_CS, PIN_BUSY ); // 1.54" - Mono
// DEPG0154BNS800 display( PIN_DC, PIN_CS, PIN_BUSY); // 1.54" - Mono
// GDEP015OC1 display( PIN_DC, PIN_CS, PIN_BUSY); // 1.54" - Mono
// DEPG0213RWS800 display( PIN_DC, PIN_CS, PIN_BUSY ); // 2.13" - 3 Color Red
// QYEG0213RWS800 display( PIN_DC, PIN_CS, PIN_BUSY ); // 2.13" - 3 Color Red
// DEPG0290BNS75A display( PIN_DC, PIN_CS, PIN_BUSY ); // 2.9" - Mono
// DEPG0290BNS800 display( PIN_DC, PIN_CS, PIN_BUSY ); // 2.9" - Mono
// GDE029A1 display( PIN_DC, PIN_CS, PIN_BUSY ); // 2.9" - Mono

// -- "Wireless Paper" --

// DEPG0213BNS800 display; // (Red Tab)
// LCMEN2R13EFC1 display; // (Green Tab)


// DEMO: Text
// ------------------
// A few examples of text, to get you started

// Include a font (for later)
#include "Fonts/FreeSerif9pt7b.h"

void setup() {

// Nothing fancy
DRAW (display) {
display.print("Hello, World!");
}

// Pause to read
delay(4000);

// --------------------------------

display.setRotation(90); // Rotate 90deg clocklwise - more room
display.setFont( & FreeSerif9pt7b ); // Set font - pass the address (&) of the font
display.setBackgroundColor(BLACK); // Background: BLACK
display.setTextColor(WHITE); // Text: WHITE
display.setCursor(5, 20); // Cursor to x:5 y:20 - think "word processor"

DRAW (display) {
display.println("black");
display.println("on");
display.println("white");
}

// Pause to read
delay(4000);

// --------------------------------

display.setFont( NULL ); // Font: back to default
display.setBackgroundColor(WHITE); // Background: WHITE
display.setTextColor(BLACK); // Text: BLACK

DRAW (display) {
display.setTextSize(3);
display.printCenter("Big"); // Centered

display.setTextSize(1);
display.printCenter("Small", 0, 30); // 30px below center
}

// Pause to read
delay(4000);

// --------------------------------

// Let's use the nice font again
display.setFont( &FreeSerif9pt7b );

char sample_text[] = "Measure!";

int offset_left;
int offset_top;
unsigned int text_width;
unsigned int text_height;

// If the cursor were placed at 0, 0:
// Where would the left and top edges be? (negative)
// How wide and how tall would the text be?
// Don't blame me, this is an AdafruitGFX method
display.getTextBounds(sample_text, 0, 0, &offset_left, &offset_top, &text_width, &text_height);

// Where to place cursor: for align bottom-right
unsigned int cursor_right = display.bounds.full.right() - (text_width + offset_left);
unsigned int cursor_bottom = display.bounds.full.bottom() - (text_height + offset_top);

// Where to place cursor: for align top-left
unsigned int cursor_left = 0 - offset_left;
unsigned int cursor_top = 0 - offset_top;

DRAW(display) {
// Move to bottom right, print text
display.setCursor(cursor_right, cursor_bottom);
display.print(sample_text);

// Move to top left, print text
display.setCursor(cursor_left, cursor_top);
display.print(sample_text);
}

// Pause
delay(4000);

// --------------------------------

// If you just want to align top-left, these is a lazier way:

char sample_text2[] = "Easier";

DRAW (display) {
display.setCursorTopLeft(sample_text2, 0, 0);
display.print(sample_text2);
}

delay(4000);
display.clear();
}

void loop() {

}

0 comments on commit e9d55e3

Please sign in to comment.