Example 6: WakeOnTap

After having learned the basics about driving an E-paper screen let’s have a look at the integrated accelerometer. One of its nice features is the supported Tap detection. This allows you to trigger an interrupt, setting a GPIO pin HIGH which can be detected by your micro controller. This setup allows you to add a cheap feedback loop to your projects by implementing a kind of single touch emulation.

Accelerometer: Tap detection

The following sketch shows you who to detect a finger tap and increase a counter based on the users input.

Demo

Demo of different update modes

Sketch

SYSTEM_MODE(SEMI_AUTOMATIC);
STARTUP(System.enableFeature(FEATURE_RETAINED_MEMORY));

#define EPD_RST     A0
#define EPD_BUSY    A1
#define EPD_CS      A2
#define ACC_CS      D6

#include "Adafruit_GFX.h"
#include "PL_microEPD.h"

PL_microEPD display(EPD_CS, EPD_RST, EPD_BUSY);
BO_BMA250   accel(ACC_CS);
retained int i = 0;

void setup() {
    SPI.begin();
    SPI.setBitOrder(MSBFIRST);
    SPI.setDataMode(SPI_MODE0);
    SPI.setClockDivider(SPI_CLOCK_DIV4);

    i+=1;
    display.begin(false);
    display.setTextSize(6);
    display.setCursor(0,4);
    display.print(i);
    display.drawCircle(170, 36, 40, EPD_LGRAY);
    display.drawCircle(170, 36, 45, EPD_LGRAY);
    display.drawCircle(170, 36, 50, EPD_LGRAY);
    display.drawCircle(170, 36, 55, EPD_LGRAY);
    display.drawCircle(170, 36, 70, EPD_LGRAY);
    display.drawCircle(170, 36, 75, EPD_LGRAY);
    display.drawCircle(0, 36, 135, EPD_LGRAY);
    display.drawCircle(0, 36, 120, EPD_LGRAY);
    display.drawCircle(0, 36, 95, EPD_LGRAY);
    display.setTextSize(1);
    display.setCursor(0, 52);
    display.print("Please dbl-tap to wakeup& increase the counter!");
    display.update();

    accel.begin();
    accel.activateTapOnInt1();
}

void loop() {
    System.sleep(SLEEP_MODE_DEEP, 3600);
}