Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
# gratis

## Notes for mrwastl/gratis-branch

This branch adds basic support for Teensy 3.1/3.2 and ESP32.

### Teensy 3.1/3.2
Default IO layout is defined in EPD_PINOUT/EPD_PINOUT_Teensy.h.

Pin numbers can be assigned individually when calling the constructor.

### ESP32
Default IO layout is defined in EPD_PINOUT/EPD_PINOUT_ESP32.h.

Pin numbers and PWM channel ID (EPD_V110_G1 only) can be assigned individually when calling the constructor.

SPI channel ID and SPI pin numbers can only be changed in EPD_PINOUT_ESP32.h, a more flexible handling would require
some API changes.


### Tests

As I just own an EPD_V110_G1 module (2.7") I can only test this one. All other combinations are tested if compilation is successful.





## Original README of repaper/gratis-branch below

## Fast Update notes, July 2017

The update rate for Partial Update is determined by the temperature dependent stage time.
Expand Down
88 changes: 50 additions & 38 deletions Sketches/libraries/EPD_FLASH/EPD_FLASH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
#define Delay_us(us) delayMicroseconds(us)


#ifndef ESP32
#define SPI_OBJECT SPI
#else
#include "EPD_PINOUT_ESP32.h"
#define SPI_OBJECT esp32_spi
#endif


// FLASH MX25V8005 8Mbit flash chip command set (50MHz max clock)
enum {
EPD_FLASH_WREN = 0x06,
Expand Down Expand Up @@ -84,27 +92,31 @@ void EPD_FLASH_Class::end(void) {

// configure the SPI for EPD_FLASH access
void EPD_FLASH_Class::spi_setup(void) {
SPI.begin();
#ifndef ESP32
SPI_OBJECT.begin();
#else
SPI_OBJECT.begin(Pin_SPI_SCK, Pin_SPI_MISO, Pin_SPI_MOSI);
#endif
digitalWrite(this->EPD_FLASH_CS, HIGH);

SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE3);
SPI.setClockDivider(SPI_CLOCK_DIV4);
SPI_OBJECT.setBitOrder(MSBFIRST);
SPI_OBJECT.setDataMode(SPI_MODE3);
SPI_OBJECT.setClockDivider(SPI_CLOCK_DIV4);

Delay_us(10);

SPI.transfer(EPD_FLASH_NOP); // flush the SPI buffer
SPI.transfer(EPD_FLASH_NOP); // ..
SPI.transfer(EPD_FLASH_NOP); // ..
SPI_OBJECT.transfer(EPD_FLASH_NOP); // flush the SPI buffer
SPI_OBJECT.transfer(EPD_FLASH_NOP); // ..
SPI_OBJECT.transfer(EPD_FLASH_NOP); // ..
Delay_us(10);
}

// shutdown SPI after EPD_FLASH access
void EPD_FLASH_Class::spi_teardown(void) {
Delay_us(10);
digitalWrite(this->EPD_FLASH_CS, HIGH);
SPI.transfer(EPD_FLASH_NOP); // flush the SPI buffer
SPI.end();
SPI_OBJECT.transfer(EPD_FLASH_NOP); // flush the SPI buffer
SPI_OBJECT.end();
}

// return true if the chip is supported
Expand All @@ -127,10 +139,10 @@ void EPD_FLASH_Class::info(uint8_t *maufacturer, uint16_t *device) {
Delay_us(50);
digitalWrite(this->EPD_FLASH_CS, LOW);
Delay_us(10);
SPI.transfer(EPD_FLASH_RDID);
*maufacturer = SPI.transfer(EPD_FLASH_NOP);
uint8_t id_high = SPI.transfer(EPD_FLASH_NOP);
uint8_t id_low = SPI.transfer(EPD_FLASH_NOP);
SPI_OBJECT.transfer(EPD_FLASH_RDID);
*maufacturer = SPI_OBJECT.transfer(EPD_FLASH_NOP);
uint8_t id_high = SPI_OBJECT.transfer(EPD_FLASH_NOP);
uint8_t id_low = SPI_OBJECT.transfer(EPD_FLASH_NOP);
*device = (id_high << 8) | id_low;
this->spi_teardown();
}
Expand All @@ -141,13 +153,13 @@ void EPD_FLASH_Class::read(void *buffer, uint32_t address, uint16_t length) {

digitalWrite(this->EPD_FLASH_CS, LOW);
Delay_us(10);
SPI.transfer(EPD_FLASH_FAST_READ);
SPI.transfer(address >> 16);
SPI.transfer(address >> 8);
SPI.transfer(address);
SPI.transfer(EPD_FLASH_NOP); // read dummy byte
SPI_OBJECT.transfer(EPD_FLASH_FAST_READ);
SPI_OBJECT.transfer(address >> 16);
SPI_OBJECT.transfer(address >> 8);
SPI_OBJECT.transfer(address);
SPI_OBJECT.transfer(EPD_FLASH_NOP); // read dummy byte
for (uint8_t *p = (uint8_t *)buffer; length != 0; --length) {
*p++ = SPI.transfer(EPD_FLASH_NOP);
*p++ = SPI_OBJECT.transfer(EPD_FLASH_NOP);
}
this->spi_teardown();
}
Expand All @@ -162,10 +174,10 @@ void EPD_FLASH_Class::wait_for_ready(void) {
bool EPD_FLASH_Class::is_busy(void) {
digitalWrite(this->EPD_FLASH_CS, LOW);
Delay_us(10);
SPI.transfer(EPD_FLASH_RDSR);
bool busy = 0 != (EPD_FLASH_WIP & SPI.transfer(EPD_FLASH_NOP));
SPI_OBJECT.transfer(EPD_FLASH_RDSR);
bool busy = 0 != (EPD_FLASH_WIP & SPI_OBJECT.transfer(EPD_FLASH_NOP));
digitalWrite(this->EPD_FLASH_CS, HIGH);
SPI.transfer(EPD_FLASH_NOP);
SPI_OBJECT.transfer(EPD_FLASH_NOP);
Delay_us(10);
return busy;
}
Expand All @@ -176,7 +188,7 @@ void EPD_FLASH_Class::write_enable(void) {

digitalWrite(this->EPD_FLASH_CS, LOW);
Delay_us(10);
SPI.transfer(EPD_FLASH_WREN);
SPI_OBJECT.transfer(EPD_FLASH_WREN);
this->spi_teardown();
}

Expand All @@ -187,7 +199,7 @@ void EPD_FLASH_Class::write_disable(void) {

digitalWrite(this->EPD_FLASH_CS, LOW);
Delay_us(10);
SPI.transfer(EPD_FLASH_WRDI);
SPI_OBJECT.transfer(EPD_FLASH_WRDI);
this->spi_teardown();
}

Expand All @@ -197,12 +209,12 @@ void EPD_FLASH_Class::write(uint32_t address, const void *buffer, uint16_t lengt

digitalWrite(this->EPD_FLASH_CS, LOW);
Delay_us(10);
SPI.transfer(EPD_FLASH_PP);
SPI.transfer(address >> 16);
SPI.transfer(address >> 8);
SPI.transfer(address);
SPI_OBJECT.transfer(EPD_FLASH_PP);
SPI_OBJECT.transfer(address >> 16);
SPI_OBJECT.transfer(address >> 8);
SPI_OBJECT.transfer(address);
for (const uint8_t *p = (const uint8_t *)buffer; length != 0; --length) {
SPI.transfer(*p++);
SPI_OBJECT.transfer(*p++);
}
this->spi_teardown();
}
Expand All @@ -214,13 +226,13 @@ void EPD_FLASH_Class::write_from_progmem(uint32_t address, PROGMEM const void *b

digitalWrite(this->EPD_FLASH_CS, LOW);
Delay_us(10);
SPI.transfer(EPD_FLASH_PP);
SPI.transfer(address >> 16);
SPI.transfer(address >> 8);
SPI.transfer(address);
SPI_OBJECT.transfer(EPD_FLASH_PP);
SPI_OBJECT.transfer(address >> 16);
SPI_OBJECT.transfer(address >> 8);
SPI_OBJECT.transfer(address);
for (PROGMEM const uint8_t *p = (PROGMEM const uint8_t *)buffer; length != 0; ++p, --length) {
uint8_t the_byte = pgm_read_byte_near(p);
SPI.transfer(the_byte);
SPI_OBJECT.transfer(the_byte);
}
this->spi_teardown();
}
Expand All @@ -232,9 +244,9 @@ void EPD_FLASH_Class::sector_erase(uint32_t address) {

digitalWrite(this->EPD_FLASH_CS, LOW);
Delay_us(10);
SPI.transfer(EPD_FLASH_SE);
SPI.transfer(address >> 16);
SPI.transfer(address >> 8);
SPI.transfer(address);
SPI_OBJECT.transfer(EPD_FLASH_SE);
SPI_OBJECT.transfer(address >> 16);
SPI_OBJECT.transfer(address >> 8);
SPI_OBJECT.transfer(address);
this->spi_teardown();
}
7 changes: 6 additions & 1 deletion Sketches/libraries/EPD_PINOUT/EPD_PINOUT.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2013-2015 Pervasive Displays, Inc.
// Copyright 2016-2017 Wolfgang Astleitner (mrwastl@users.sourceforge.net)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,7 +18,11 @@

#include <EPD_PANELS.h>

#if defined(ENERGIA)
#if defined(CORE_TEENSY)
#include <EPD_PINOUT_Teensy.h>
#elif defined(ESP32)
#include <EPD_PINOUT_ESP32.h>
#elif defined(ENERGIA)
#include <EPD_PINOUT_Energia.h>
#else
#include <EPD_PINOUT_Arduino.h>
Expand Down
51 changes: 51 additions & 0 deletions Sketches/libraries/EPD_PINOUT/EPD_PINOUT_ESP32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2013-2015 Pervasive Displays, Inc.
// Copyright 2017 Wolfgang Astleitner (mrwastl@users.sourceforge.net)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language
// governing permissions and limitations under the License.

#if !defined(EPD_PINOUT_ESP32_H)
#define EPD_PINOUT_ESP32_H 1

// ESP32 IO layout
const int Pin_TEMPERATURE = A6 /* A6 == 34 */;
const int Pin_PANEL_ON = 21;
const int Pin_BORDER = 27;
const int Pin_DISCHARGE = 22;
const int Pin_RESET = 25;
const int Pin_BUSY = 33;
const int Pin_EPD_CS = 32;
const int Pin_EPD_FLASH_CS = 17;

// PWM: for V110 only
const int Pin_PWM = 26;
const int Pin_PWM_Channel = 0;

// customisable SPI
const int Pin_SPI_MISO = 12;
const int Pin_SPI_MOSI = 13;
const int Pin_SPI_SCK = 14;
const int Pin_SPI_Channel = 2;
// set SPI frequency to 40 MHz (max. freq. for COG driver)
// will be reduced to 20 MHz because of SPI_CLOCK_DIV2 (see SPI_on())
const uint32_t ESP32_SPI_Frequency = 40000000;


// the following are defined for completeness but not used or required
// for driving the display
const int Pin_SW2 = 2;
const int Pin_RED_LED = 4;

// SPI object for both EPD_FLASH and EPD_V???_G?-classes
static SPIClass esp32_spi(Pin_SPI_Channel);

#endif
38 changes: 38 additions & 0 deletions Sketches/libraries/EPD_PINOUT/EPD_PINOUT_Teensy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2013-2015 Pervasive Displays, Inc.
// Copyright 2016-2017 Wolfgang Astleitner (mrwastl@users.sourceforge.net)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language
// governing permissions and limitations under the License.

#if !defined(EPD_PINOUT_TEENSY_H)
#define EPD_PINOUT_TEENSY_H 1

// pinout is taken from:
// https://forum.pjrc.com/threads/25793-2-7-inch-ePaper-on-Teensy-does-not-compile-Adafruit_GFX#post53636

// Teensy 3.1/3.2 IO layout
const int Pin_TEMPERATURE = A0;
const int Pin_PANEL_ON = 2;
const int Pin_BORDER = 3;
const int Pin_DISCHARGE = 4;
const int Pin_PWM = 5;
const int Pin_RESET = 6;
const int Pin_BUSY = 7;
const int Pin_EPD_CS = 8;
const int Pin_EPD_FLASH_CS = 9;

// the following are defined for completeness but not used or required
// for driving the display
const int Pin_SW2 = 0;
const int Pin_RED_LED = 1;

#endif
Loading