Actions (#17)
This commit is contained in:
parent
89030f082f
commit
918c98aba3
30 changed files with 1581 additions and 1492 deletions
46
.github/ISSUE_TEMPLATE.md
vendored
Normal file
46
.github/ISSUE_TEMPLATE.md
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
Thank you for opening an issue on an Adafruit Arduino library repository. To
|
||||
improve the speed of resolution please review the following guidelines and
|
||||
common troubleshooting steps below before creating the issue:
|
||||
|
||||
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
|
||||
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
|
||||
something isn't working as expected. In many cases the problem is a common issue
|
||||
that you will more quickly receive help from the forum community. GitHub issues
|
||||
are meant for known defects in the code. If you don't know if there is a defect
|
||||
in the code then start with troubleshooting on the forum first.
|
||||
|
||||
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
|
||||
check all of the steps and commands to run have been followed. Consult the
|
||||
forum if you're unsure or have questions about steps in a guide/tutorial.
|
||||
|
||||
- **For Arduino projects check these very common issues to ensure they don't apply**:
|
||||
|
||||
- For uploading sketches or communicating with the board make sure you're using
|
||||
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
|
||||
very hard to tell the difference between a data and charge cable! Try using the
|
||||
cable with other devices or swapping to another cable to confirm it is not
|
||||
the problem.
|
||||
|
||||
- **Be sure you are supplying adequate power to the board.** Check the specs of
|
||||
your board and plug in an external power supply. In many cases just
|
||||
plugging a board into your computer is not enough to power it and other
|
||||
peripherals.
|
||||
|
||||
- **Double check all soldering joints and connections.** Flakey connections
|
||||
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
|
||||
|
||||
- **Ensure you are using an official Arduino or Adafruit board.** We can't
|
||||
guarantee a clone board will have the same functionality and work as expected
|
||||
with this code and don't support them.
|
||||
|
||||
If you're sure this issue is a defect in the code and checked the steps above
|
||||
please fill in the following fields to provide enough troubleshooting information.
|
||||
You may delete the guideline and text above to just leave the following details:
|
||||
|
||||
- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
|
||||
|
||||
- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
|
||||
VERSION HERE**
|
||||
|
||||
- List the steps to reproduce the problem below (if possible attach a sketch or
|
||||
copy the sketch code in too): **LIST REPRO STEPS BELOW**
|
||||
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
|
||||
Before you open the request please review the following guidelines and tips to
|
||||
help it be more easily integrated:
|
||||
|
||||
- **Describe the scope of your change--i.e. what the change does and what parts
|
||||
of the code were modified.** This will help us understand any risks of integrating
|
||||
the code.
|
||||
|
||||
- **Describe any known limitations with your change.** For example if the change
|
||||
doesn't apply to a supported platform of the library please mention it.
|
||||
|
||||
- **Please run any tests or examples that can exercise your modified code.** We
|
||||
strive to not break users of the code and running tests/examples helps with this
|
||||
process.
|
||||
|
||||
Thank you again for contributing! We will try to test and integrate the change
|
||||
as soon as we can, but be aware we have many GitHub repositories to manage and
|
||||
can't immediately respond to every request. There is no need to bump or check in
|
||||
on a pull request (it will clutter the discussion of the request).
|
||||
|
||||
Also don't be worried if the request is closed or not integrated--sometimes the
|
||||
priorities of Adafruit's GitHub code (education, ease of use) might not match the
|
||||
priorities of the pull request. Don't fret, the open source community thrives on
|
||||
forks and GitHub makes it easy to keep your changes in a forked repo.
|
||||
|
||||
After reviewing the guidelines above you can delete this text from the pull request.
|
||||
32
.github/workflows/githubci.yml
vendored
Normal file
32
.github/workflows/githubci.yml
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
name: Arduino Library CI
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: adafruit/ci-arduino
|
||||
path: ci
|
||||
|
||||
- name: pre-install
|
||||
run: bash ci/actions_install.sh
|
||||
|
||||
- name: test platforms
|
||||
run: python3 ci/build_platform.py main_platforms cpb cpx
|
||||
|
||||
- name: clang
|
||||
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
|
||||
|
||||
- name: doxygen
|
||||
env:
|
||||
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
|
||||
PRETTYNAME : "Adafruit E-Paper Display Library"
|
||||
run: bash ci/doxy_gen_and_deploy.sh
|
||||
43
.travis.yml
43
.travis.yml
|
|
@ -1,43 +0,0 @@
|
|||
language: c
|
||||
sudo: false
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- ~/arduino_ide
|
||||
# Caches Arduino IDE + ESP32 platform
|
||||
- ~/.arduino15/packages/
|
||||
# Caches Arduino platforms
|
||||
git:
|
||||
depth: false
|
||||
quiet: true
|
||||
|
||||
# Blacklist
|
||||
branches:
|
||||
except:
|
||||
- gh-pages
|
||||
|
||||
env:
|
||||
global:
|
||||
- PRETTYNAME="Adafruit EPD Library"
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- python3
|
||||
- python3-pip
|
||||
- python3-setuptools
|
||||
|
||||
before_install:
|
||||
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
|
||||
|
||||
install:
|
||||
- pip3 install --user adafruit-nrfutil
|
||||
|
||||
script:
|
||||
- build_main_platforms
|
||||
- build_cplay_platforms
|
||||
|
||||
# Generate and deploy documentation
|
||||
after_success:
|
||||
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/library_check.sh)
|
||||
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh)
|
||||
252
Adafruit_EPD.cpp
252
Adafruit_EPD.cpp
|
|
@ -18,9 +18,10 @@
|
|||
*
|
||||
* @section dependencies Dependencies
|
||||
*
|
||||
* This library depends on <a href="https://github.com/adafruit/Adafruit-GFX-Library">
|
||||
* Adafruit_GFX</a> being present on your system. Please make sure you have
|
||||
* installed the latest version before using this library.
|
||||
* This library depends on <a
|
||||
* href="https://github.com/adafruit/Adafruit-GFX-Library"> Adafruit_GFX</a>
|
||||
* being present on your system. Please make sure you have installed the latest
|
||||
* version before using this library.
|
||||
*
|
||||
* @section author Author
|
||||
*
|
||||
|
|
@ -33,22 +34,24 @@
|
|||
*/
|
||||
|
||||
#ifdef __AVR__
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#elif defined(ESP8266) || defined(ESP32)
|
||||
#include <pgmspace.h>
|
||||
#include <pgmspace.h>
|
||||
#else
|
||||
#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) ///< read bytes from program memory
|
||||
#define pgm_read_byte(addr) \
|
||||
(*(const unsigned char *)(addr)) ///< read bytes from program memory
|
||||
#endif
|
||||
|
||||
#if !defined(__ARM_ARCH) && !defined(ENERGIA) && !defined(ESP8266) && !defined(ESP32) && !defined(__arc__)
|
||||
#include <util/delay.h>
|
||||
#if !defined(__ARM_ARCH) && !defined(ENERGIA) && !defined(ESP8266) && \
|
||||
!defined(ESP32) && !defined(__arc__)
|
||||
#include <util/delay.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <SPI.h>
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "Adafruit_EPD.h"
|
||||
#include "Adafruit_GFX.h"
|
||||
#include <SPI.h>
|
||||
|
||||
bool Adafruit_EPD::_isInTransaction = false;
|
||||
|
||||
|
|
@ -67,8 +70,10 @@ bool Adafruit_EPD::_isInTransaction = false;
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_EPD::Adafruit_EPD(int width, int height, int8_t spi_mosi, int8_t spi_clock, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t spi_miso, int8_t BUSY) : Adafruit_GFX(width, height),
|
||||
sram(spi_mosi, spi_miso, spi_clock, SRCS) {
|
||||
Adafruit_EPD::Adafruit_EPD(int width, int height, int8_t spi_mosi,
|
||||
int8_t spi_clock, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t SRCS, int8_t spi_miso, int8_t BUSY)
|
||||
: Adafruit_GFX(width, height), sram(spi_mosi, spi_miso, spi_clock, SRCS) {
|
||||
_cs_pin = CS;
|
||||
_reset_pin = RST;
|
||||
_dc_pin = DC;
|
||||
|
|
@ -101,8 +106,9 @@ sram(spi_mosi, spi_miso, spi_clock, SRCS) {
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_EPD::Adafruit_EPD(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY) : Adafruit_GFX(width, height),
|
||||
sram(SRCS) {
|
||||
Adafruit_EPD::Adafruit_EPD(int width, int height, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t BUSY)
|
||||
: Adafruit_GFX(width, height), sram(SRCS) {
|
||||
_cs_pin = CS;
|
||||
_reset_pin = RST;
|
||||
_dc_pin = DC;
|
||||
|
|
@ -125,8 +131,7 @@ sram(SRCS) {
|
|||
@brief default destructor
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_EPD::~Adafruit_EPD()
|
||||
{
|
||||
Adafruit_EPD::~Adafruit_EPD() {
|
||||
if (buffer1 != NULL) {
|
||||
free(buffer1);
|
||||
buffer1 = NULL;
|
||||
|
|
@ -144,8 +149,8 @@ Adafruit_EPD::~Adafruit_EPD()
|
|||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_EPD::begin(bool reset) {
|
||||
setBlackBuffer(0, true); // black defaults to inverted
|
||||
setColorBuffer(1, false); // red defaults to not inverted
|
||||
setBlackBuffer(0, true); // black defaults to inverted
|
||||
setColorBuffer(1, false); // red defaults to not inverted
|
||||
|
||||
if (use_sram) {
|
||||
sram.begin();
|
||||
|
|
@ -156,28 +161,28 @@ void Adafruit_EPD::begin(bool reset) {
|
|||
pinMode(_dc_pin, OUTPUT);
|
||||
pinMode(_cs_pin, OUTPUT);
|
||||
#ifdef HAVE_PORTREG
|
||||
csport = portOutputRegister(digitalPinToPort(_cs_pin));
|
||||
cspinmask = digitalPinToBitMask(_cs_pin);
|
||||
dcport = portOutputRegister(digitalPinToPort(_dc_pin));
|
||||
dcpinmask = digitalPinToBitMask(_dc_pin);
|
||||
csport = portOutputRegister(digitalPinToPort(_cs_pin));
|
||||
cspinmask = digitalPinToBitMask(_cs_pin);
|
||||
dcport = portOutputRegister(digitalPinToPort(_dc_pin));
|
||||
dcpinmask = digitalPinToBitMask(_dc_pin);
|
||||
#endif
|
||||
|
||||
csHigh();
|
||||
|
||||
if (!hwSPI){
|
||||
if (!hwSPI) {
|
||||
// set pins for software-SPI
|
||||
pinMode(_sid_pin, OUTPUT);
|
||||
pinMode(_sclk_pin, OUTPUT);
|
||||
#ifdef HAVE_PORTREG
|
||||
clkport = portOutputRegister(digitalPinToPort(_sclk_pin));
|
||||
clkpinmask = digitalPinToBitMask(_sclk_pin);
|
||||
mosiport = portOutputRegister(digitalPinToPort(_sid_pin));
|
||||
clkport = portOutputRegister(digitalPinToPort(_sclk_pin));
|
||||
clkpinmask = digitalPinToBitMask(_sclk_pin);
|
||||
mosiport = portOutputRegister(digitalPinToPort(_sid_pin));
|
||||
mosipinmask = digitalPinToBitMask(_sid_pin);
|
||||
#endif
|
||||
} else {
|
||||
SPI.begin();
|
||||
#ifndef SPI_HAS_TRANSACTION
|
||||
SPI.setClockDivider (4);
|
||||
SPI.setClockDivider(4);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -215,9 +220,9 @@ void Adafruit_EPD::hardwareReset(void) {
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@brief draw a single pixel on the screen
|
||||
@param x the x axis position
|
||||
@param y the y axis position
|
||||
@param color the color of the pixel
|
||||
@param x the x axis position
|
||||
@param y the y axis position
|
||||
@param color the color of the pixel
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_EPD::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||
|
|
@ -247,7 +252,7 @@ void Adafruit_EPD::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
|||
y = _HEIGHT - y - 1;
|
||||
break;
|
||||
}
|
||||
uint16_t addr = ( (uint32_t)(WIDTH - 1 - x) * (uint32_t)_HEIGHT + y)/8;
|
||||
uint16_t addr = ((uint32_t)(WIDTH - 1 - x) * (uint32_t)_HEIGHT + y) / 8;
|
||||
uint8_t c;
|
||||
if (use_sram) {
|
||||
if ((color == EPD_RED) || (color == EPD_GRAY)) {
|
||||
|
|
@ -258,7 +263,7 @@ void Adafruit_EPD::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
|||
c = sram.read8(addr);
|
||||
pBuf = &c;
|
||||
} else {
|
||||
if((color == EPD_RED) || (color == EPD_GRAY)) {
|
||||
if ((color == EPD_RED) || (color == EPD_GRAY)) {
|
||||
pBuf = color_buffer + addr;
|
||||
} else {
|
||||
pBuf = black_buffer + addr;
|
||||
|
|
@ -267,12 +272,12 @@ void Adafruit_EPD::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
|||
|
||||
if (((color == EPD_RED || color == EPD_GRAY) && colorInverted) ||
|
||||
((color == EPD_BLACK) && blackInverted)) {
|
||||
*pBuf &= ~(1 << (7 - y%8));
|
||||
*pBuf &= ~(1 << (7 - y % 8));
|
||||
} else if (((color == EPD_RED || color == EPD_GRAY) && !colorInverted) ||
|
||||
((color == EPD_BLACK) && !blackInverted)) {
|
||||
*pBuf |= (1 << (7 - y%8));
|
||||
((color == EPD_BLACK) && !blackInverted)) {
|
||||
*pBuf |= (1 << (7 - y % 8));
|
||||
} else if (color == EPD_INVERSE) {
|
||||
*pBuf ^= (1 << (7 - y%8));
|
||||
*pBuf ^= (1 << (7 - y % 8));
|
||||
}
|
||||
|
||||
if (use_sram) {
|
||||
|
|
@ -285,8 +290,7 @@ void Adafruit_EPD::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
|||
@brief Transfer the data stored in the buffer(s) to the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_EPD::display(void)
|
||||
{
|
||||
void Adafruit_EPD::display(void) {
|
||||
uint8_t c;
|
||||
|
||||
powerUp();
|
||||
|
|
@ -307,18 +311,18 @@ void Adafruit_EPD::display(void)
|
|||
c = writeRAMCommand(0);
|
||||
|
||||
dcHigh();
|
||||
for(uint16_t i=0; i<buffer1_size; i++){
|
||||
for (uint16_t i = 0; i < buffer1_size; i++) {
|
||||
c = SPItransfer(c);
|
||||
//Serial.print("0x"); Serial.print((byte)c, HEX); Serial.print(", ");
|
||||
//if (i % 32 == 31) Serial.println();
|
||||
// Serial.print("0x"); Serial.print((byte)c, HEX); Serial.print(", ");
|
||||
// if (i % 32 == 31) Serial.println();
|
||||
}
|
||||
csHigh();
|
||||
sram.csHigh();
|
||||
} else {
|
||||
//write image
|
||||
// write image
|
||||
writeRAMCommand(0);
|
||||
dcHigh();
|
||||
for(uint16_t i=0; i<buffer1_size; i++) {
|
||||
for (uint16_t i = 0; i < buffer1_size; i++) {
|
||||
SPItransfer(buffer1[i]);
|
||||
}
|
||||
csHigh();
|
||||
|
|
@ -348,7 +352,7 @@ void Adafruit_EPD::display(void)
|
|||
c = writeRAMCommand(1);
|
||||
|
||||
dcHigh();
|
||||
for(uint16_t i=0; i<buffer2_size; i++){
|
||||
for (uint16_t i = 0; i < buffer2_size; i++) {
|
||||
c = SPItransfer(c);
|
||||
}
|
||||
csHigh();
|
||||
|
|
@ -357,7 +361,7 @@ void Adafruit_EPD::display(void)
|
|||
writeRAMCommand(1);
|
||||
dcHigh();
|
||||
|
||||
for(uint16_t i=0; i<buffer2_size; i++){
|
||||
for (uint16_t i = 0; i < buffer2_size; i++) {
|
||||
SPItransfer(buffer2[i]);
|
||||
}
|
||||
csHigh();
|
||||
|
|
@ -368,7 +372,6 @@ void Adafruit_EPD::display(void)
|
|||
powerDown();
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Determine whether the black pixel data is the first or second buffer
|
||||
|
|
@ -376,23 +379,23 @@ void Adafruit_EPD::display(void)
|
|||
@param inverted Whether to invert the logical value
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_EPD::setBlackBuffer(int8_t index, bool inverted) {
|
||||
if (index == 0) {
|
||||
if (use_sram) {
|
||||
blackbuffer_addr = buffer1_addr;
|
||||
} else {
|
||||
black_buffer = buffer1;
|
||||
}
|
||||
}
|
||||
if (index == 1) {
|
||||
if (use_sram) {
|
||||
blackbuffer_addr = buffer2_addr;
|
||||
} else {
|
||||
black_buffer = buffer2;
|
||||
}
|
||||
}
|
||||
blackInverted = inverted;
|
||||
}
|
||||
void Adafruit_EPD::setBlackBuffer(int8_t index, bool inverted) {
|
||||
if (index == 0) {
|
||||
if (use_sram) {
|
||||
blackbuffer_addr = buffer1_addr;
|
||||
} else {
|
||||
black_buffer = buffer1;
|
||||
}
|
||||
}
|
||||
if (index == 1) {
|
||||
if (use_sram) {
|
||||
blackbuffer_addr = buffer2_addr;
|
||||
} else {
|
||||
black_buffer = buffer2;
|
||||
}
|
||||
}
|
||||
blackInverted = inverted;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
|
@ -401,66 +404,63 @@ void Adafruit_EPD::display(void)
|
|||
@param inverted Whether to invert the logical value
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_EPD::setColorBuffer(int8_t index, bool inverted) {
|
||||
if (index == 0) {
|
||||
if (use_sram) {
|
||||
colorbuffer_addr = buffer1_addr;
|
||||
} else {
|
||||
color_buffer = buffer1;
|
||||
}
|
||||
}
|
||||
if (index == 1) {
|
||||
if (use_sram) {
|
||||
colorbuffer_addr = buffer2_addr;
|
||||
} else {
|
||||
color_buffer = buffer2;
|
||||
}
|
||||
}
|
||||
colorInverted = inverted;
|
||||
}
|
||||
|
||||
void Adafruit_EPD::setColorBuffer(int8_t index, bool inverted) {
|
||||
if (index == 0) {
|
||||
if (use_sram) {
|
||||
colorbuffer_addr = buffer1_addr;
|
||||
} else {
|
||||
color_buffer = buffer1;
|
||||
}
|
||||
}
|
||||
if (index == 1) {
|
||||
if (use_sram) {
|
||||
colorbuffer_addr = buffer2_addr;
|
||||
} else {
|
||||
color_buffer = buffer2;
|
||||
}
|
||||
}
|
||||
colorInverted = inverted;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief clear all data buffers
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_EPD::clearBuffer()
|
||||
{
|
||||
void Adafruit_EPD::clearBuffer() {
|
||||
if (use_sram) {
|
||||
if (buffer1_size != 0) {
|
||||
if (blackInverted) {
|
||||
sram.erase(buffer1_addr, buffer1_size, 0xFF);
|
||||
sram.erase(buffer1_addr, buffer1_size, 0xFF);
|
||||
} else {
|
||||
sram.erase(buffer1_addr, buffer1_size, 0x00);
|
||||
sram.erase(buffer1_addr, buffer1_size, 0x00);
|
||||
}
|
||||
}
|
||||
if (buffer2_size != 0) {
|
||||
if (colorInverted) {
|
||||
sram.erase(buffer2_addr, buffer2_size, 0xFF);
|
||||
sram.erase(buffer2_addr, buffer2_size, 0xFF);
|
||||
} else {
|
||||
sram.erase(buffer2_addr, buffer2_size, 0x00);
|
||||
sram.erase(buffer2_addr, buffer2_size, 0x00);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (buffer1) {
|
||||
if (blackInverted) {
|
||||
memset(buffer1, 0xFF, buffer1_size);
|
||||
memset(buffer1, 0xFF, buffer1_size);
|
||||
} else {
|
||||
memset(buffer1, 0x00, buffer1_size);
|
||||
memset(buffer1, 0x00, buffer1_size);
|
||||
}
|
||||
}
|
||||
if (buffer2) {
|
||||
if (colorInverted) {
|
||||
memset(buffer2, 0xFF, buffer2_size);
|
||||
memset(buffer2, 0xFF, buffer2_size);
|
||||
} else {
|
||||
memset(buffer2, 0x00, buffer2_size);
|
||||
memset(buffer2, 0x00, buffer2_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief clear the display twice to remove any spooky ghost images
|
||||
|
|
@ -473,7 +473,6 @@ void Adafruit_EPD::clearDisplay() {
|
|||
display();
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief send an EPD command followed by data
|
||||
|
|
@ -482,8 +481,7 @@ void Adafruit_EPD::clearDisplay() {
|
|||
@param len the length of the data buffer
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_EPD::EPD_command(uint8_t c, const uint8_t *buf, uint16_t len)
|
||||
{
|
||||
void Adafruit_EPD::EPD_command(uint8_t c, const uint8_t *buf, uint16_t len) {
|
||||
EPD_command(c, false);
|
||||
EPD_data(buf, len);
|
||||
}
|
||||
|
|
@ -492,7 +490,8 @@ void Adafruit_EPD::EPD_command(uint8_t c, const uint8_t *buf, uint16_t len)
|
|||
/*!
|
||||
@brief send an EPD command with no data
|
||||
@param c the command to send
|
||||
@param end if true the cs pin will be pulled high following the transaction. If false the cs pin will remain low.
|
||||
@param end if true the cs pin will be pulled high following the transaction.
|
||||
If false the cs pin will remain low.
|
||||
@returns the data byte read over the SPI bus
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
|
@ -504,7 +503,8 @@ uint8_t Adafruit_EPD::EPD_command(uint8_t c, bool end) {
|
|||
|
||||
uint8_t data = SPItransfer(c);
|
||||
#ifdef EPD_DEBUG
|
||||
Serial.print("\nCommand: 0x"); Serial.print(c, HEX);
|
||||
Serial.print("\nCommand: 0x");
|
||||
Serial.print(c, HEX);
|
||||
Serial.print(" - ");
|
||||
#endif
|
||||
|
||||
|
|
@ -515,7 +515,6 @@ uint8_t Adafruit_EPD::EPD_command(uint8_t c, bool end) {
|
|||
return data;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief send data to the display
|
||||
|
|
@ -523,19 +522,19 @@ uint8_t Adafruit_EPD::EPD_command(uint8_t c, bool end) {
|
|||
@param len the length of the data buffer
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_EPD::EPD_data(const uint8_t *buf, uint16_t len)
|
||||
{
|
||||
void Adafruit_EPD::EPD_data(const uint8_t *buf, uint16_t len) {
|
||||
// SPI
|
||||
dcHigh();
|
||||
|
||||
|
||||
#ifdef EPD_DEBUG
|
||||
Serial.print("Data: ");
|
||||
#endif
|
||||
for (uint16_t i=0; i<len; i++) {
|
||||
for (uint16_t i = 0; i < len; i++) {
|
||||
SPItransfer(buf[i]);
|
||||
#ifdef EPD_DEBUG
|
||||
Serial.print("0x"); Serial.print(buf[i], HEX); Serial.print(", ");
|
||||
Serial.print("0x");
|
||||
Serial.print(buf[i], HEX);
|
||||
Serial.print(", ");
|
||||
#endif
|
||||
}
|
||||
#ifdef EPD_DEBUG
|
||||
|
|
@ -544,32 +543,28 @@ void Adafruit_EPD::EPD_data(const uint8_t *buf, uint16_t len)
|
|||
csHigh();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief send data to the display
|
||||
@param data the data byte to send
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_EPD::EPD_data(uint8_t data)
|
||||
{
|
||||
void Adafruit_EPD::EPD_data(uint8_t data) {
|
||||
// SPI
|
||||
csHigh();
|
||||
dcHigh();
|
||||
csLow();
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
Serial.print("Data: ");
|
||||
Serial.print("0x"); Serial.println(data, HEX);
|
||||
Serial.print("0x");
|
||||
Serial.println(data, HEX);
|
||||
#endif
|
||||
SPItransfer(data);
|
||||
|
||||
csHigh();
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief transfer a single byte over SPI.
|
||||
|
|
@ -578,30 +573,33 @@ void Adafruit_EPD::EPD_data(uint8_t data)
|
|||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_EPD::SPItransfer(uint8_t d) {
|
||||
//Serial.print("-> 0x"); Serial.println((byte)d, HEX);
|
||||
// Serial.print("-> 0x"); Serial.println((byte)d, HEX);
|
||||
|
||||
if (hwSPI) {
|
||||
if (singleByteTxns){
|
||||
if (singleByteTxns) {
|
||||
uint8_t b;
|
||||
csLow();
|
||||
b = SPI.transfer(d);
|
||||
csHigh();
|
||||
return b;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return SPI.transfer(d);
|
||||
} else {
|
||||
//TODO: return read data for software SPI
|
||||
for(uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
// TODO: return read data for software SPI
|
||||
for (uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
#ifdef HAVE_PORTREG
|
||||
*clkport &= ~clkpinmask;
|
||||
if(d & bit) *mosiport |= mosipinmask;
|
||||
else *mosiport &= ~mosipinmask;
|
||||
*clkport |= clkpinmask;
|
||||
if (d & bit)
|
||||
*mosiport |= mosipinmask;
|
||||
else
|
||||
*mosiport &= ~mosipinmask;
|
||||
*clkport |= clkpinmask;
|
||||
#else
|
||||
digitalWrite(_sclk_pin, LOW);
|
||||
if(d & bit) digitalWrite(_sid_pin, HIGH);
|
||||
else digitalWrite(_sid_pin, LOW);
|
||||
if (d & bit)
|
||||
digitalWrite(_sid_pin, HIGH);
|
||||
else
|
||||
digitalWrite(_sid_pin, LOW);
|
||||
digitalWrite(_sclk_pin, HIGH);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -614,8 +612,7 @@ uint8_t Adafruit_EPD::SPItransfer(uint8_t d) {
|
|||
@brief set chip select pin high
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_EPD::csHigh()
|
||||
{
|
||||
void Adafruit_EPD::csHigh() {
|
||||
#ifdef SPI_HAS_TRANSACTION
|
||||
SPI.endTransaction();
|
||||
_isInTransaction = false;
|
||||
|
|
@ -632,8 +629,7 @@ void Adafruit_EPD::csHigh()
|
|||
@brief set chip select pin low
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_EPD::csLow()
|
||||
{
|
||||
void Adafruit_EPD::csLow() {
|
||||
#ifdef SPI_HAS_TRANSACTION
|
||||
if (!_isInTransaction) {
|
||||
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
||||
|
|
@ -652,8 +648,7 @@ void Adafruit_EPD::csLow()
|
|||
@brief set data/command pin high
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_EPD::dcHigh()
|
||||
{
|
||||
void Adafruit_EPD::dcHigh() {
|
||||
#ifdef HAVE_PORTREG
|
||||
*dcport |= dcpinmask;
|
||||
#else
|
||||
|
|
@ -666,8 +661,7 @@ void Adafruit_EPD::dcHigh()
|
|||
@brief set data/command pin low
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_EPD::dcLow()
|
||||
{
|
||||
void Adafruit_EPD::dcLow() {
|
||||
#ifdef HAVE_PORTREG
|
||||
*dcport &= ~dcpinmask;
|
||||
#else
|
||||
|
|
|
|||
141
Adafruit_EPD.h
141
Adafruit_EPD.h
|
|
@ -21,9 +21,9 @@
|
|||
#define _Adafruit_EPD_H_
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
//#define EPD_DEBUG
|
||||
|
|
@ -31,45 +31,51 @@
|
|||
#define RAMBUFSIZE 64 ///< size of the ram buffer
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
typedef volatile RwReg PortReg; ///< a port register for fast access
|
||||
typedef uint32_t PortMask; ///< a port register mask for your pin
|
||||
#define HAVE_PORTREG
|
||||
typedef volatile RwReg PortReg; ///< a port register for fast access
|
||||
typedef uint32_t PortMask; ///< a port register mask for your pin
|
||||
#define HAVE_PORTREG
|
||||
#elif defined(ARDUINO_ARCH_SAMD)
|
||||
// not supported
|
||||
#elif defined(ESP8266) || defined(ESP32) || defined(ARDUINO_STM32_FEATHER) || defined(__arc__)
|
||||
typedef volatile uint32_t PortReg; ///< a port register for fast access
|
||||
typedef uint32_t PortMask; ///< a port register mask for your pin
|
||||
#elif defined(ESP8266) || defined(ESP32) || defined(ARDUINO_STM32_FEATHER) || \
|
||||
defined(__arc__)
|
||||
typedef volatile uint32_t PortReg; ///< a port register for fast access
|
||||
typedef uint32_t PortMask; ///< a port register mask for your pin
|
||||
#elif defined(__AVR__)
|
||||
typedef volatile uint8_t PortReg; ///< a port register for fast access
|
||||
typedef uint8_t PortMask; ///< a port register mask for your pin
|
||||
#define HAVE_PORTREG
|
||||
typedef volatile uint8_t PortReg; ///< a port register for fast access
|
||||
typedef uint8_t PortMask; ///< a port register mask for your pin
|
||||
#define HAVE_PORTREG
|
||||
#else
|
||||
// chances are its 32 bit so assume that
|
||||
typedef volatile uint32_t PortReg; ///< a port register for fast access
|
||||
typedef uint32_t PortMask; ///< a port register mask for your pin
|
||||
// chances are its 32 bit so assume that
|
||||
typedef volatile uint32_t PortReg; ///< a port register for fast access
|
||||
typedef uint32_t PortMask; ///< a port register mask for your pin
|
||||
#endif
|
||||
|
||||
#include "Adafruit_MCPSRAM.h"
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <SPI.h>
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief available EPD colors
|
||||
*/
|
||||
/**************************************************************************/
|
||||
enum {
|
||||
EPD_BLACK, ///< black color
|
||||
EPD_WHITE, ///< white color
|
||||
EPD_INVERSE, ///< invert color
|
||||
EPD_RED, ///< red color
|
||||
EPD_GRAY, ///< gray color ('red' on grayscale)
|
||||
EPD_DARK, ///< darker color
|
||||
EPD_LIGHT, ///< lighter color
|
||||
EPD_BLACK, ///< black color
|
||||
EPD_WHITE, ///< white color
|
||||
EPD_INVERSE, ///< invert color
|
||||
EPD_RED, ///< red color
|
||||
EPD_GRAY, ///< gray color ('red' on grayscale)
|
||||
EPD_DARK, ///< darker color
|
||||
EPD_LIGHT, ///< lighter color
|
||||
};
|
||||
|
||||
#define EPD_swap(a, b) { int16_t t = a; a = b; b = t; } ///< simple swap function
|
||||
#define EPD_swap(a, b) \
|
||||
{ \
|
||||
int16_t t = a; \
|
||||
a = b; \
|
||||
b = t; \
|
||||
} ///< simple swap function
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
|
@ -77,13 +83,15 @@ enum {
|
|||
*/
|
||||
/**************************************************************************/
|
||||
class Adafruit_EPD : public Adafruit_GFX {
|
||||
public:
|
||||
|
||||
Adafruit_EPD(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY = -1);
|
||||
Adafruit_EPD(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY = -1);
|
||||
public:
|
||||
Adafruit_EPD(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
|
||||
int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY = -1);
|
||||
Adafruit_EPD(int width, int height, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t SRCS, int8_t BUSY = -1);
|
||||
~Adafruit_EPD();
|
||||
|
||||
void begin(bool reset=true);
|
||||
void begin(bool reset = true);
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
void clearBuffer();
|
||||
void clearDisplay();
|
||||
|
|
@ -91,13 +99,14 @@ class Adafruit_EPD : public Adafruit_GFX {
|
|||
void setColorBuffer(int8_t index, bool inverted);
|
||||
void display(void);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Send the specific command to start writing to EPD display RAM
|
||||
@param index The index for which buffer to write (0 or 1 or tri-color displays)
|
||||
Ignored for monochrome displays.
|
||||
@returns The byte that is read from SPI at the same time as sending the command
|
||||
@param index The index for which buffer to write (0 or 1 or tri-color
|
||||
displays) Ignored for monochrome displays.
|
||||
@returns The byte that is read from SPI at the same time as sending the
|
||||
command
|
||||
*/
|
||||
/**************************************************************************/
|
||||
virtual uint8_t writeRAMCommand(uint8_t index) = 0;
|
||||
|
|
@ -133,61 +142,65 @@ class Adafruit_EPD : public Adafruit_GFX {
|
|||
virtual void powerDown(void) = 0;
|
||||
void hardwareReset(void);
|
||||
|
||||
int8_t _sid_pin, ///< sid pin
|
||||
_sclk_pin, ///< serial clock pin
|
||||
_dc_pin, ///< data/command pin
|
||||
_reset_pin, ///< reset pin
|
||||
_cs_pin, ///< chip select pin
|
||||
_busy_pin; ///< busy pin
|
||||
int8_t _sid_pin, ///< sid pin
|
||||
_sclk_pin, ///< serial clock pin
|
||||
_dc_pin, ///< data/command pin
|
||||
_reset_pin, ///< reset pin
|
||||
_cs_pin, ///< chip select pin
|
||||
_busy_pin; ///< busy pin
|
||||
static bool _isInTransaction; ///< true if SPI bus is in trasnfer state
|
||||
bool singleByteTxns; ///< if true CS will go high after every data byte transferred
|
||||
bool singleByteTxns; ///< if true CS will go high after every data byte
|
||||
///< transferred
|
||||
Adafruit_MCPSRAM sram; ///< the ram chip object if using off-chip ram
|
||||
|
||||
bool blackInverted; ///< is black channel inverted
|
||||
bool colorInverted; ///< is red channel inverted
|
||||
bool blackInverted; ///< is black channel inverted
|
||||
bool colorInverted; ///< is red channel inverted
|
||||
uint16_t buffer1_size; ///< size of the primary buffer
|
||||
uint16_t buffer2_size; ///< size of the secondary buffer
|
||||
uint8_t *buffer1; ///< the pointer to the primary buffer if using on-chip ram
|
||||
uint8_t *buffer2; ///< the pointer to the secondary buffer if using on-chip ram
|
||||
uint8_t *color_buffer; ///< the pointer to the color buffer if using on-chip ram
|
||||
uint8_t *black_buffer; ///< the pointer to the black buffer if using on-chip ram
|
||||
uint16_t buffer1_addr; ///< The SRAM address offsets for the primary buffer
|
||||
uint16_t buffer2_addr; ///< The SRAM address offsets for the secondary buffer
|
||||
uint16_t colorbuffer_addr; ///< The SRAM address offsets for the color buffer
|
||||
uint16_t blackbuffer_addr; ///< The SRAM address offsets for the black buffer
|
||||
uint8_t
|
||||
*buffer2; ///< the pointer to the secondary buffer if using on-chip ram
|
||||
uint8_t
|
||||
*color_buffer; ///< the pointer to the color buffer if using on-chip ram
|
||||
uint8_t
|
||||
*black_buffer; ///< the pointer to the black buffer if using on-chip ram
|
||||
uint16_t buffer1_addr; ///< The SRAM address offsets for the primary buffer
|
||||
uint16_t buffer2_addr; ///< The SRAM address offsets for the secondary buffer
|
||||
uint16_t colorbuffer_addr; ///< The SRAM address offsets for the color buffer
|
||||
uint16_t blackbuffer_addr; ///< The SRAM address offsets for the black buffer
|
||||
|
||||
void EPD_command(uint8_t c, const uint8_t *buf, uint16_t len);
|
||||
uint8_t EPD_command(uint8_t c, bool end=true);
|
||||
uint8_t EPD_command(uint8_t c, bool end = true);
|
||||
void EPD_data(const uint8_t *buf, uint16_t len);
|
||||
void EPD_data(uint8_t data);
|
||||
|
||||
uint8_t SPItransfer(uint8_t c);
|
||||
|
||||
bool use_sram; ///< true if we are using an SRAM chip as a framebuffer
|
||||
bool hwSPI; ///< true if using hardware SPI
|
||||
bool hwSPI; ///< true if using hardware SPI
|
||||
#ifdef HAVE_PORTREG
|
||||
PortReg *mosiport, ///< mosi port register
|
||||
*clkport, ///< serial clock port register
|
||||
*csport, ///< chip select port register
|
||||
*dcport; ///< data/command port register
|
||||
PortReg *mosiport, ///< mosi port register
|
||||
*clkport, ///< serial clock port register
|
||||
*csport, ///< chip select port register
|
||||
*dcport; ///< data/command port register
|
||||
PortMask mosipinmask, ///< mosi pin mask
|
||||
clkpinmask, ///< serial clock pin mask
|
||||
cspinmask, ///< chip select pin mask
|
||||
dcpinmask; ///< data / command pin mask
|
||||
clkpinmask, ///< serial clock pin mask
|
||||
cspinmask, ///< chip select pin mask
|
||||
dcpinmask; ///< data / command pin mask
|
||||
#endif
|
||||
void csLow();
|
||||
void csHigh();
|
||||
void dcHigh();
|
||||
void dcLow();
|
||||
void csLow();
|
||||
void csHigh();
|
||||
void dcHigh();
|
||||
void dcLow();
|
||||
};
|
||||
|
||||
/*
|
||||
#include "Adafruit_IL0376F.h"
|
||||
#include "Adafruit_IL0371.h"
|
||||
#include "Adafruit_IL0376F.h"
|
||||
*/
|
||||
#include "Adafruit_IL0373.h"
|
||||
#include "Adafruit_IL0398.h"
|
||||
#include "Adafruit_IL91874.h"
|
||||
#include "Adafruit_IL0373.h"
|
||||
#include "Adafruit_SSD1608.h"
|
||||
#include "Adafruit_SSD1675.h"
|
||||
#include "Adafruit_SSD1675B.h"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "Adafruit_EPD.h"
|
||||
#include "Adafruit_IL0373.h"
|
||||
#include "Adafruit_EPD.h"
|
||||
|
||||
#define BUSY_WAIT 500
|
||||
|
||||
|
|
@ -18,7 +18,10 @@
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL0373::Adafruit_IL0373(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY) : Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY){
|
||||
Adafruit_IL0373::Adafruit_IL0373(int width, int height, int8_t SID, int8_t SCLK,
|
||||
int8_t DC, int8_t RST, int8_t CS, int8_t SRCS,
|
||||
int8_t MISO, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
|
||||
|
||||
buffer1_size = ((uint32_t)width * (uint32_t)height) / 8;
|
||||
buffer2_size = buffer1_size;
|
||||
|
|
@ -48,7 +51,9 @@ Adafruit_IL0373::Adafruit_IL0373(int width, int height, int8_t SID, int8_t SCLK,
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL0373::Adafruit_IL0373(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY) : Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
Adafruit_IL0373::Adafruit_IL0373(int width, int height, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
buffer1_size = ((uint32_t)width * (uint32_t)height) / 8;
|
||||
buffer2_size = buffer1_size;
|
||||
|
||||
|
|
@ -68,11 +73,10 @@ Adafruit_IL0373::Adafruit_IL0373(int width, int height, int8_t DC, int8_t RST, i
|
|||
@brief wait for busy signal to end
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0373::busy_wait(void)
|
||||
{
|
||||
void Adafruit_IL0373::busy_wait(void) {
|
||||
if (_busy_pin >= 0) {
|
||||
while(!digitalRead(_busy_pin)) {
|
||||
delay(10); //wait for busy high
|
||||
while (!digitalRead(_busy_pin)) {
|
||||
delay(10); // wait for busy high
|
||||
}
|
||||
} else {
|
||||
delay(BUSY_WAIT);
|
||||
|
|
@ -85,12 +89,11 @@ void Adafruit_IL0373::busy_wait(void)
|
|||
@param reset if true the reset pin will be toggled.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0373::begin(bool reset)
|
||||
{
|
||||
void Adafruit_IL0373::begin(bool reset) {
|
||||
Adafruit_EPD::begin(reset);
|
||||
setBlackBuffer(0, true); // black defaults to inverted
|
||||
setColorBuffer(1, true); // red defaults to inverted
|
||||
|
||||
setBlackBuffer(0, true); // black defaults to inverted
|
||||
setColorBuffer(1, true); // red defaults to inverted
|
||||
|
||||
powerDown();
|
||||
}
|
||||
|
||||
|
|
@ -99,10 +102,9 @@ void Adafruit_IL0373::begin(bool reset)
|
|||
@brief signal the display to update
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0373::update()
|
||||
{
|
||||
void Adafruit_IL0373::update() {
|
||||
EPD_command(IL0373_DISPLAY_REFRESH);
|
||||
|
||||
|
||||
delay(100);
|
||||
|
||||
busy_wait();
|
||||
|
|
@ -116,8 +118,7 @@ void Adafruit_IL0373::update()
|
|||
@brief start up the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0373::powerUp()
|
||||
{
|
||||
void Adafruit_IL0373::powerUp() {
|
||||
uint8_t buf[5];
|
||||
|
||||
hardwareReset();
|
||||
|
|
@ -128,60 +129,60 @@ void Adafruit_IL0373::powerUp()
|
|||
buf[3] = 0x2b;
|
||||
buf[4] = 0x09;
|
||||
EPD_command(IL0373_POWER_SETTING, buf, 5);
|
||||
|
||||
|
||||
buf[0] = 0x17;
|
||||
buf[1] = 0x17;
|
||||
buf[2] = 0x17;
|
||||
EPD_command(IL0373_BOOSTER_SOFT_START, buf, 3);
|
||||
|
||||
EPD_command(IL0373_BOOSTER_SOFT_START, buf, 3);
|
||||
|
||||
EPD_command(IL0373_POWER_ON);
|
||||
busy_wait();
|
||||
delay(200);
|
||||
|
||||
|
||||
buf[0] = 0xCF;
|
||||
EPD_command(IL0373_PANEL_SETTING, buf, 1);
|
||||
|
||||
|
||||
buf[0] = 0x37;
|
||||
EPD_command(IL0373_CDI, buf, 1);
|
||||
|
||||
|
||||
buf[0] = 0x29;
|
||||
EPD_command(IL0373_PLL, buf, 1);
|
||||
|
||||
|
||||
buf[0] = HEIGHT & 0xFF;
|
||||
buf[1] = (WIDTH >> 8) & 0xFF;
|
||||
buf[2] = WIDTH & 0xFF;
|
||||
EPD_command(IL0373_RESOLUTION, buf, 3);
|
||||
|
||||
|
||||
buf[0] = 0x0A;
|
||||
EPD_command(IL0373_VCM_DC_SETTING, buf, 1);
|
||||
delay(20);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief wind down the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0373::powerDown() {
|
||||
//power off
|
||||
// power off
|
||||
uint8_t buf[4];
|
||||
|
||||
|
||||
buf[0] = 0x17;
|
||||
EPD_command(IL0373_CDI, buf, 1);
|
||||
|
||||
|
||||
buf[0] = 0x00;
|
||||
EPD_command(IL0373_VCM_DC_SETTING, buf, 0);
|
||||
|
||||
|
||||
EPD_command(IL0373_POWER_OFF);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Send the specific command to start writing to EPD display RAM
|
||||
@param index The index for which buffer to write (0 or 1 or tri-color displays)
|
||||
Ignored for monochrome displays.
|
||||
@returns The byte that is read from SPI at the same time as sending the command
|
||||
@param index The index for which buffer to write (0 or 1 or tri-color
|
||||
displays) Ignored for monochrome displays.
|
||||
@returns The byte that is read from SPI at the same time as sending the
|
||||
command
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_IL0373::writeRAMCommand(uint8_t index) {
|
||||
|
|
|
|||
|
|
@ -37,12 +37,14 @@
|
|||
*/
|
||||
/**************************************************************************/
|
||||
class Adafruit_IL0373 : public Adafruit_EPD {
|
||||
public:
|
||||
|
||||
Adafruit_IL0373(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY = -1);
|
||||
Adafruit_IL0373(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY = -1);
|
||||
public:
|
||||
Adafruit_IL0373(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
|
||||
int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY = -1);
|
||||
Adafruit_IL0373(int width, int height, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t SRCS, int8_t BUSY = -1);
|
||||
|
||||
void begin(bool reset=true);
|
||||
void begin(bool reset = true);
|
||||
void powerUp();
|
||||
void powerDown();
|
||||
void update();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "Adafruit_EPD.h"
|
||||
#include "Adafruit_IL0398.h"
|
||||
#include "Adafruit_EPD.h"
|
||||
|
||||
#define BUSY_WAIT 500
|
||||
|
||||
|
|
@ -18,10 +18,10 @@
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL0398::Adafruit_IL0398(int width, int height,
|
||||
int8_t SID, int8_t SCLK, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY) :
|
||||
Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
|
||||
Adafruit_IL0398::Adafruit_IL0398(int width, int height, int8_t SID, int8_t SCLK,
|
||||
int8_t DC, int8_t RST, int8_t CS, int8_t SRCS,
|
||||
int8_t MISO, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
|
||||
|
||||
buffer1_size = ((uint32_t)width * (uint32_t)height) / 8;
|
||||
buffer2_size = buffer1_size;
|
||||
|
|
@ -50,10 +50,9 @@ Adafruit_IL0398::Adafruit_IL0398(int width, int height,
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL0398::Adafruit_IL0398(int width, int height,
|
||||
int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t BUSY) :
|
||||
Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
Adafruit_IL0398::Adafruit_IL0398(int width, int height, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
|
||||
buffer1_size = ((uint32_t)width * (uint32_t)height) / 8;
|
||||
buffer2_size = buffer1_size;
|
||||
|
|
@ -74,18 +73,16 @@ Adafruit_IL0398::Adafruit_IL0398(int width, int height,
|
|||
@brief wait for busy signal to end
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0398::busy_wait(void)
|
||||
{
|
||||
void Adafruit_IL0398::busy_wait(void) {
|
||||
if (_busy_pin > -1) {
|
||||
do {
|
||||
EPD_command(IL0398_GETSTATUS);
|
||||
delay(10);
|
||||
} while (digitalRead(_busy_pin)); //wait for busy low
|
||||
} while (digitalRead(_busy_pin)); // wait for busy low
|
||||
delay(200);
|
||||
} else {
|
||||
delay(BUSY_WAIT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -94,11 +91,10 @@ void Adafruit_IL0398::busy_wait(void)
|
|||
@param reset if true the reset pin will be toggled.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0398::begin(bool reset)
|
||||
{
|
||||
void Adafruit_IL0398::begin(bool reset) {
|
||||
Adafruit_EPD::begin(reset);
|
||||
setBlackBuffer(0, true); // black defaults to inverted
|
||||
setColorBuffer(1, true); // red defaults to inverted
|
||||
setBlackBuffer(0, true); // black defaults to inverted
|
||||
setColorBuffer(1, true); // red defaults to inverted
|
||||
|
||||
setRotation(1);
|
||||
powerDown();
|
||||
|
|
@ -109,8 +105,7 @@ void Adafruit_IL0398::begin(bool reset)
|
|||
@brief signal the display to update
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0398::update()
|
||||
{
|
||||
void Adafruit_IL0398::update() {
|
||||
EPD_command(IL0398_DISPLAY_REFRESH);
|
||||
delay(100);
|
||||
|
||||
|
|
@ -125,8 +120,7 @@ void Adafruit_IL0398::update()
|
|||
@brief start up the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0398::powerUp()
|
||||
{
|
||||
void Adafruit_IL0398::powerUp() {
|
||||
uint8_t buf[4];
|
||||
|
||||
hardwareReset();
|
||||
|
|
@ -141,13 +135,13 @@ void Adafruit_IL0398::powerUp()
|
|||
|
||||
buf[0] = 0x0F;
|
||||
EPD_command(IL0398_PANEL_SETTING, buf, 1);
|
||||
|
||||
|
||||
buf[0] = (HEIGHT >> 8) & 0xFF;
|
||||
buf[1] = HEIGHT & 0xFF;
|
||||
buf[2] = (WIDTH >> 8) & 0xFF;
|
||||
buf[3] = WIDTH & 0xFF;
|
||||
EPD_command(IL0398_RESOLUTION, buf, 4);
|
||||
|
||||
|
||||
delay(20);
|
||||
}
|
||||
|
||||
|
|
@ -156,8 +150,7 @@ void Adafruit_IL0398::powerUp()
|
|||
@brief wind down the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0398::powerDown()
|
||||
{
|
||||
void Adafruit_IL0398::powerDown() {
|
||||
uint8_t buf[4];
|
||||
|
||||
// power off
|
||||
|
|
@ -170,15 +163,13 @@ void Adafruit_IL0398::powerDown()
|
|||
delay(100);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Send the specific command to start writing to EPD display RAM
|
||||
@param index The index for which buffer to write (0 or 1 or tri-color displays)
|
||||
Ignored for monochrome displays.
|
||||
@returns The byte that is read from SPI at the same time as sending the command
|
||||
@param index The index for which buffer to write (0 or 1 or tri-color
|
||||
displays) Ignored for monochrome displays.
|
||||
@returns The byte that is read from SPI at the same time as sending the
|
||||
command
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_IL0398::writeRAMCommand(uint8_t index) {
|
||||
|
|
|
|||
|
|
@ -52,18 +52,20 @@
|
|||
#define IL0398_POWERSAVING 0xE3
|
||||
#define IL0398_FORCETEMP 0xE5
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Class for interfacing with IL0398 EPD drivers
|
||||
*/
|
||||
/**************************************************************************/
|
||||
class Adafruit_IL0398 : public Adafruit_EPD {
|
||||
public:
|
||||
Adafruit_IL0398(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY = -1);
|
||||
Adafruit_IL0398(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY = -1);
|
||||
public:
|
||||
Adafruit_IL0398(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
|
||||
int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY = -1);
|
||||
Adafruit_IL0398(int width, int height, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t SRCS, int8_t BUSY = -1);
|
||||
|
||||
void begin(bool reset=true);
|
||||
void begin(bool reset = true);
|
||||
void powerUp();
|
||||
void update();
|
||||
void powerDown();
|
||||
|
|
|
|||
|
|
@ -1,63 +1,41 @@
|
|||
#include "Adafruit_EPD.h"
|
||||
#include "Adafruit_IL91874.h"
|
||||
#include "Adafruit_EPD.h"
|
||||
|
||||
#define BUSY_WAIT 500
|
||||
|
||||
const unsigned char lut_vcomDC[] =
|
||||
{
|
||||
0x00, 0x00,
|
||||
0x00, 0x1A, 0x1A, 0x00, 0x00, 0x01,
|
||||
0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08,
|
||||
0x00, 0x0E, 0x01, 0x0E, 0x01, 0x10,
|
||||
0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08,
|
||||
0x00, 0x04, 0x10, 0x00, 0x00, 0x05,
|
||||
0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A,
|
||||
0x00, 0x23, 0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
const unsigned char lut_vcomDC[] = {
|
||||
0x00, 0x00, 0x00, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x0A,
|
||||
0x00, 0x00, 0x08, 0x00, 0x0E, 0x01, 0x0E, 0x01, 0x10, 0x00, 0x0A,
|
||||
0x0A, 0x00, 0x00, 0x08, 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, 0x00,
|
||||
0x03, 0x0E, 0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01};
|
||||
|
||||
//R21H
|
||||
const unsigned char lut_ww[] ={
|
||||
0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01,
|
||||
0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08,
|
||||
0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10,
|
||||
0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08,
|
||||
0x00, 0x04, 0x10, 0x00, 0x00, 0x05,
|
||||
0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A,
|
||||
0x00, 0x23, 0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
// R21H
|
||||
const unsigned char lut_ww[] = {
|
||||
0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x40, 0x0A, 0x0A, 0x00, 0x00,
|
||||
0x08, 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, 0x80, 0x0A, 0x0A, 0x00,
|
||||
0x00, 0x08, 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, 0x00, 0x03, 0x0E,
|
||||
0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01};
|
||||
|
||||
//R22H r
|
||||
const unsigned char lut_bw[] ={
|
||||
0xA0, 0x1A, 0x1A, 0x00, 0x00, 0x01,
|
||||
0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08,
|
||||
0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10,
|
||||
0x90, 0x0A, 0x0A, 0x00, 0x00, 0x08,
|
||||
0xB0, 0x04, 0x10, 0x00, 0x00, 0x05,
|
||||
0xB0, 0x03, 0x0E, 0x00, 0x00, 0x0A,
|
||||
0xC0, 0x23, 0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
// R22H r
|
||||
const unsigned char lut_bw[] = {
|
||||
0xA0, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x0A, 0x00, 0x00,
|
||||
0x08, 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, 0x90, 0x0A, 0x0A, 0x00,
|
||||
0x00, 0x08, 0xB0, 0x04, 0x10, 0x00, 0x00, 0x05, 0xB0, 0x03, 0x0E,
|
||||
0x00, 0x00, 0x0A, 0xC0, 0x23, 0x00, 0x00, 0x00, 0x01};
|
||||
|
||||
//R23H w
|
||||
const unsigned char lut_bb[] ={
|
||||
0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01,
|
||||
0x40, 0x0A, 0x0A, 0x00, 0x00, 0x08,
|
||||
0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10,
|
||||
0x80, 0x0A, 0x0A, 0x00, 0x00, 0x08,
|
||||
0x00, 0x04, 0x10, 0x00, 0x00, 0x05,
|
||||
0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A,
|
||||
0x00, 0x23, 0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
// R23H w
|
||||
const unsigned char lut_bb[] = {
|
||||
0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x40, 0x0A, 0x0A, 0x00, 0x00,
|
||||
0x08, 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, 0x80, 0x0A, 0x0A, 0x00,
|
||||
0x00, 0x08, 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, 0x00, 0x03, 0x0E,
|
||||
0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01};
|
||||
|
||||
//R24H b
|
||||
const unsigned char lut_wb[] ={
|
||||
0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01,
|
||||
0x20, 0x0A, 0x0A, 0x00, 0x00, 0x08,
|
||||
0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10,
|
||||
0x10, 0x0A, 0x0A, 0x00, 0x00, 0x08,
|
||||
0x00, 0x04, 0x10, 0x00, 0x00, 0x05,
|
||||
0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A,
|
||||
0x00, 0x23, 0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
// R24H b
|
||||
const unsigned char lut_wb[] = {
|
||||
0x90, 0x1A, 0x1A, 0x00, 0x00, 0x01, 0x20, 0x0A, 0x0A, 0x00, 0x00,
|
||||
0x08, 0x84, 0x0E, 0x01, 0x0E, 0x01, 0x10, 0x10, 0x0A, 0x0A, 0x00,
|
||||
0x00, 0x08, 0x00, 0x04, 0x10, 0x00, 0x00, 0x05, 0x00, 0x03, 0x0E,
|
||||
0x00, 0x00, 0x0A, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01};
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
|
@ -74,10 +52,11 @@ const unsigned char lut_wb[] ={
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL91874::Adafruit_IL91874(int width, int height,
|
||||
int8_t SID, int8_t SCLK, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY) :
|
||||
Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
|
||||
Adafruit_IL91874::Adafruit_IL91874(int width, int height, int8_t SID,
|
||||
int8_t SCLK, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
|
||||
|
||||
buffer1_size = ((uint32_t)width * (uint32_t)height) / 8;
|
||||
buffer2_size = buffer1_size;
|
||||
|
|
@ -106,10 +85,9 @@ Adafruit_IL91874::Adafruit_IL91874(int width, int height,
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL91874::Adafruit_IL91874(int width, int height,
|
||||
int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t BUSY) :
|
||||
Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
Adafruit_IL91874::Adafruit_IL91874(int width, int height, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
|
||||
buffer1_size = ((uint32_t)width * (uint32_t)height) / 8;
|
||||
buffer2_size = buffer1_size;
|
||||
|
|
@ -123,18 +101,17 @@ Adafruit_IL91874::Adafruit_IL91874(int width, int height,
|
|||
buffer1 = (uint8_t *)malloc(buffer1_size);
|
||||
buffer2 = (uint8_t *)malloc(buffer2_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief wait for busy signal to end
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL91874::busy_wait(void)
|
||||
{
|
||||
void Adafruit_IL91874::busy_wait(void) {
|
||||
if (_busy_pin >= 0) {
|
||||
while (!digitalRead(_busy_pin)) {
|
||||
delay(1); //wait for busy low
|
||||
delay(1); // wait for busy low
|
||||
}
|
||||
} else {
|
||||
delay(BUSY_WAIT);
|
||||
|
|
@ -147,14 +124,13 @@ void Adafruit_IL91874::busy_wait(void)
|
|||
@param reset if true the reset pin will be toggled.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL91874::begin(bool reset)
|
||||
{
|
||||
void Adafruit_IL91874::begin(bool reset) {
|
||||
singleByteTxns = true;
|
||||
Adafruit_EPD::begin(reset);
|
||||
|
||||
setBlackBuffer(0, true); // black defaults to inverted
|
||||
setColorBuffer(1, false); // red defaults to not inverted
|
||||
|
||||
setColorBuffer(1, false); // red defaults to not inverted
|
||||
|
||||
powerDown();
|
||||
}
|
||||
|
||||
|
|
@ -163,10 +139,9 @@ void Adafruit_IL91874::begin(bool reset)
|
|||
@brief signal the display to update
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL91874::update()
|
||||
{
|
||||
void Adafruit_IL91874::update() {
|
||||
EPD_command(IL91874_DISPLAY_REFRESH);
|
||||
|
||||
|
||||
busy_wait();
|
||||
if (_busy_pin <= -1) {
|
||||
delay(16000);
|
||||
|
|
@ -178,8 +153,7 @@ void Adafruit_IL91874::update()
|
|||
@brief start up the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL91874::powerUp()
|
||||
{
|
||||
void Adafruit_IL91874::powerUp() {
|
||||
uint8_t buf[5];
|
||||
|
||||
hardwareReset();
|
||||
|
|
@ -190,7 +164,7 @@ void Adafruit_IL91874::powerUp()
|
|||
|
||||
buf[0] = 0xAF;
|
||||
EPD_command(IL91874_PANEL_SETTING, buf, 1);
|
||||
|
||||
|
||||
buf[0] = 0x3a;
|
||||
EPD_command(IL91874_PLL, buf, 1);
|
||||
|
||||
|
|
@ -200,44 +174,44 @@ void Adafruit_IL91874::powerUp()
|
|||
buf[3] = 0x2b;
|
||||
buf[4] = 0x09;
|
||||
EPD_command(IL91874_POWER_SETTING, buf, 5);
|
||||
|
||||
|
||||
buf[0] = 0x07;
|
||||
buf[1] = 0x07;
|
||||
buf[2] = 0x017;
|
||||
EPD_command(IL91874_BOOSTER_SOFT_START, buf, 3);
|
||||
|
||||
|
||||
buf[0] = 0x60;
|
||||
buf[1] = 0xA5;
|
||||
EPD_command(0xF8, buf, 2);
|
||||
|
||||
|
||||
buf[0] = 0x89;
|
||||
buf[1] = 0xA5;
|
||||
EPD_command(0xF8, buf, 2);
|
||||
|
||||
|
||||
buf[0] = 0x90;
|
||||
buf[1] = 0x00;
|
||||
EPD_command(0xF8, buf, 2);
|
||||
|
||||
|
||||
buf[0] = 0x93;
|
||||
buf[1] = 0x2A;
|
||||
EPD_command(0xF8, buf, 2);
|
||||
|
||||
|
||||
buf[0] = 0x73;
|
||||
buf[1] = 0x41;
|
||||
EPD_command(0xF8, buf, 2);
|
||||
|
||||
|
||||
buf[0] = 0x12;
|
||||
EPD_command(IL91874_VCM_DC_SETTING, buf, 1);
|
||||
|
||||
buf[0] = 0x87;
|
||||
EPD_command(IL91874_CDI, buf, 1);
|
||||
|
||||
|
||||
EPD_command(IL91874_LUT1, lut_vcomDC, 44);
|
||||
EPD_command(IL91874_LUTWW, lut_ww, 42);
|
||||
EPD_command(IL91874_LUTBW, lut_bw, 42);
|
||||
EPD_command(IL91874_LUTWB, lut_wb, 42);
|
||||
EPD_command(IL91874_LUTBB, lut_bb, 42);
|
||||
|
||||
|
||||
buf[0] = (HEIGHT >> 8) & 0xFF;
|
||||
buf[1] = HEIGHT & 0xFF;
|
||||
buf[2] = (WIDTH >> 8) & 0xFF;
|
||||
|
|
@ -253,14 +227,13 @@ void Adafruit_IL91874::powerUp()
|
|||
@brief wind down the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL91874::powerDown()
|
||||
{
|
||||
//power off
|
||||
void Adafruit_IL91874::powerDown() {
|
||||
// power off
|
||||
uint8_t buf[1];
|
||||
|
||||
EPD_command(IL91874_POWER_OFF);
|
||||
busy_wait();
|
||||
|
||||
|
||||
// Only deep sleep if we can get out of it
|
||||
if (_reset_pin >= 0) {
|
||||
buf[0] = 0xA5;
|
||||
|
|
@ -271,9 +244,10 @@ void Adafruit_IL91874::powerDown()
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Send the specific command to start writing to EPD display RAM
|
||||
@param index The index for which buffer to write (0 or 1 or tri-color displays)
|
||||
Ignored for monochrome displays.
|
||||
@returns The byte that is read from SPI at the same time as sending the command
|
||||
@param index The index for which buffer to write (0 or 1 or tri-color
|
||||
displays) Ignored for monochrome displays.
|
||||
@returns The byte that is read from SPI at the same time as sending the
|
||||
command
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_IL91874::writeRAMCommand(uint8_t index) {
|
||||
|
|
@ -296,5 +270,3 @@ uint8_t Adafruit_IL91874::writeRAMCommand(uint8_t index) {
|
|||
void Adafruit_IL91874::setRAMAddress(uint16_t x, uint16_t y) {
|
||||
// on this chip we do nothing
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,12 +37,14 @@
|
|||
*/
|
||||
/**************************************************************************/
|
||||
class Adafruit_IL91874 : public Adafruit_EPD {
|
||||
public:
|
||||
public:
|
||||
Adafruit_IL91874(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
|
||||
int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY = -1);
|
||||
Adafruit_IL91874(int width, int height, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t SRCS, int8_t BUSY = -1);
|
||||
|
||||
Adafruit_IL91874(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY = -1);
|
||||
Adafruit_IL91874(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY = -1);
|
||||
|
||||
void begin(bool reset=true);
|
||||
void begin(bool reset = true);
|
||||
void powerUp();
|
||||
void update();
|
||||
void powerDown();
|
||||
|
|
|
|||
|
|
@ -7,31 +7,30 @@
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Class constructor when using software SPI
|
||||
@param mosi master out slave in pin
|
||||
@param miso master in slave out pin
|
||||
@param sck serial clock pin
|
||||
@param cs chip select pin
|
||||
@param mosi master out slave in pin
|
||||
@param miso master in slave out pin
|
||||
@param sck serial clock pin
|
||||
@param cs chip select pin
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_MCPSRAM::Adafruit_MCPSRAM(int8_t mosi, int8_t miso, int8_t sck, int8_t cs)
|
||||
{
|
||||
_mosi = mosi;
|
||||
_miso = miso;
|
||||
_sck = sck;
|
||||
_cs = cs;
|
||||
hwSPI = false;
|
||||
Adafruit_MCPSRAM::Adafruit_MCPSRAM(int8_t mosi, int8_t miso, int8_t sck,
|
||||
int8_t cs) {
|
||||
_mosi = mosi;
|
||||
_miso = miso;
|
||||
_sck = sck;
|
||||
_cs = cs;
|
||||
hwSPI = false;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Class constructor when using hardware SPI
|
||||
@param cs chip select pin
|
||||
@param cs chip select pin
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_MCPSRAM::Adafruit_MCPSRAM(int8_t cs)
|
||||
{
|
||||
_cs = cs;
|
||||
hwSPI = true;
|
||||
Adafruit_MCPSRAM::Adafruit_MCPSRAM(int8_t cs) {
|
||||
_cs = cs;
|
||||
hwSPI = true;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -39,321 +38,339 @@ Adafruit_MCPSRAM::Adafruit_MCPSRAM(int8_t cs)
|
|||
@brief begin communication with the SRAM chip
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_MCPSRAM::begin()
|
||||
{
|
||||
pinMode(_cs, OUTPUT);
|
||||
void Adafruit_MCPSRAM::begin() {
|
||||
pinMode(_cs, OUTPUT);
|
||||
#ifdef HAVE_PORTREG
|
||||
csport = portOutputRegister(digitalPinToPort(_cs));
|
||||
cspinmask = digitalPinToBitMask(_cs);
|
||||
csport = portOutputRegister(digitalPinToPort(_cs));
|
||||
cspinmask = digitalPinToBitMask(_cs);
|
||||
#endif
|
||||
csHigh();
|
||||
csHigh();
|
||||
|
||||
if (!hwSPI){
|
||||
// set pins for software-SPI
|
||||
pinMode(_mosi, OUTPUT);
|
||||
pinMode(_sck, OUTPUT);
|
||||
if (!hwSPI) {
|
||||
// set pins for software-SPI
|
||||
pinMode(_mosi, OUTPUT);
|
||||
pinMode(_sck, OUTPUT);
|
||||
#ifdef HAVE_PORTREG
|
||||
clkport = portOutputRegister(digitalPinToPort(_sck));
|
||||
clkpinmask = digitalPinToBitMask(_sck);
|
||||
mosiport = portOutputRegister(digitalPinToPort(_mosi));
|
||||
mosipinmask = digitalPinToBitMask(_mosi);
|
||||
misoport = portOutputRegister(digitalPinToPort(_miso));
|
||||
misopinmask = digitalPinToBitMask(_miso);
|
||||
clkport = portOutputRegister(digitalPinToPort(_sck));
|
||||
clkpinmask = digitalPinToBitMask(_sck);
|
||||
mosiport = portOutputRegister(digitalPinToPort(_mosi));
|
||||
mosipinmask = digitalPinToBitMask(_mosi);
|
||||
misoport = portOutputRegister(digitalPinToPort(_miso));
|
||||
misopinmask = digitalPinToBitMask(_miso);
|
||||
#endif
|
||||
}
|
||||
if (hwSPI) {
|
||||
SPI.begin();
|
||||
#ifndef SPI_HAS_TRANSACTION
|
||||
SPI.setClockDivider(4);
|
||||
#endif
|
||||
}
|
||||
|
||||
csLow();
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (hwSPI) {
|
||||
(void)SPI.transfer(0xFF);
|
||||
} else {
|
||||
for (uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
#ifdef HAVE_PORTREG
|
||||
*clkport &= ~clkpinmask;
|
||||
if (0xFF & bit)
|
||||
*mosiport |= mosipinmask;
|
||||
else
|
||||
*mosiport &= ~mosipinmask;
|
||||
*clkport |= clkpinmask;
|
||||
#else
|
||||
digitalWrite(_sck, LOW);
|
||||
if (0xFF & bit)
|
||||
digitalWrite(_mosi, HIGH);
|
||||
else
|
||||
digitalWrite(_mosi, LOW);
|
||||
digitalWrite(_sck, HIGH);
|
||||
#endif
|
||||
}
|
||||
if (hwSPI){
|
||||
SPI.begin();
|
||||
#ifndef SPI_HAS_TRANSACTION
|
||||
SPI.setClockDivider (4);
|
||||
#endif
|
||||
}
|
||||
|
||||
csLow();
|
||||
|
||||
for(int i=0; i<3; i++){
|
||||
if(hwSPI) {
|
||||
(void)SPI.transfer(0xFF);
|
||||
} else {
|
||||
for(uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
#ifdef HAVE_PORTREG
|
||||
*clkport &= ~clkpinmask;
|
||||
if(0xFF & bit) *mosiport |= mosipinmask;
|
||||
else *mosiport &= ~mosipinmask;
|
||||
*clkport |= clkpinmask;
|
||||
#else
|
||||
digitalWrite(_sck, LOW);
|
||||
if(0xFF & bit) digitalWrite(_mosi, HIGH);
|
||||
else digitalWrite(_mosi, LOW);
|
||||
digitalWrite(_sck, HIGH);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
csHigh();
|
||||
|
||||
csHigh();
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief write data to the specific address
|
||||
@param addr the address to write to
|
||||
@param buf the data buffer to write
|
||||
@param num the number of bytes to write
|
||||
@param reg pass MCPSRAM_WRSR if you are writing the status register, MCPSRAM_WRITE if you are writing data. Defaults to MCPSRAM_WRITE.
|
||||
@param addr the address to write to
|
||||
@param buf the data buffer to write
|
||||
@param num the number of bytes to write
|
||||
@param reg pass MCPSRAM_WRSR if you are writing the status
|
||||
register, MCPSRAM_WRITE if you are writing data. Defaults to MCPSRAM_WRITE.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_MCPSRAM::write(uint16_t addr, uint8_t *buf, uint16_t num, uint8_t reg)
|
||||
{
|
||||
csLow();
|
||||
void Adafruit_MCPSRAM::write(uint16_t addr, uint8_t *buf, uint16_t num,
|
||||
uint8_t reg) {
|
||||
csLow();
|
||||
|
||||
//write command and address
|
||||
uint8_t cmdbuf[3];
|
||||
cmdbuf[0] = reg;
|
||||
cmdbuf[1] = (addr >> 8);
|
||||
cmdbuf[2] = addr & 0xFF;
|
||||
|
||||
for(int i=0; i<3; i++){
|
||||
// write command and address
|
||||
uint8_t cmdbuf[3];
|
||||
cmdbuf[0] = reg;
|
||||
cmdbuf[1] = (addr >> 8);
|
||||
cmdbuf[2] = addr & 0xFF;
|
||||
|
||||
uint8_t d = cmdbuf[i];
|
||||
|
||||
if(hwSPI) {
|
||||
(void)SPI.transfer(d);
|
||||
} else {
|
||||
for(uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
uint8_t d = cmdbuf[i];
|
||||
|
||||
if (hwSPI) {
|
||||
(void)SPI.transfer(d);
|
||||
} else {
|
||||
for (uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
#ifdef HAVE_PORTREG
|
||||
*clkport &= ~clkpinmask;
|
||||
if(d & bit) *mosiport |= mosipinmask;
|
||||
else *mosiport &= ~mosipinmask;
|
||||
*clkport |= clkpinmask;
|
||||
*clkport &= ~clkpinmask;
|
||||
if (d & bit)
|
||||
*mosiport |= mosipinmask;
|
||||
else
|
||||
*mosiport &= ~mosipinmask;
|
||||
*clkport |= clkpinmask;
|
||||
#else
|
||||
digitalWrite(_sck, LOW);
|
||||
if(d & bit) digitalWrite(_mosi, HIGH);
|
||||
else digitalWrite(_mosi, LOW);
|
||||
digitalWrite(_sck, HIGH);
|
||||
digitalWrite(_sck, LOW);
|
||||
if (d & bit)
|
||||
digitalWrite(_mosi, HIGH);
|
||||
else
|
||||
digitalWrite(_mosi, LOW);
|
||||
digitalWrite(_sck, HIGH);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (reg != MCPSRAM_WRITE)
|
||||
break;
|
||||
}
|
||||
if(reg != MCPSRAM_WRITE) break;
|
||||
}
|
||||
|
||||
//write buffer of data
|
||||
for(int i=0; i<num; i++){
|
||||
// write buffer of data
|
||||
for (int i = 0; i < num; i++) {
|
||||
|
||||
uint8_t d = buf[i];
|
||||
|
||||
if(hwSPI) {
|
||||
(void)SPI.transfer(d);
|
||||
} else {
|
||||
for(uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
uint8_t d = buf[i];
|
||||
|
||||
if (hwSPI) {
|
||||
(void)SPI.transfer(d);
|
||||
} else {
|
||||
for (uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
#ifdef HAVE_PORTREG
|
||||
*clkport &= ~clkpinmask;
|
||||
readt |= mosipinmask;
|
||||
readt &= ~mosipinmask;
|
||||
readask;
|
||||
*clkport &= ~clkpinmask;
|
||||
readt |= mosipinmask;
|
||||
readt &= ~mosipinmask;
|
||||
readask;
|
||||
#elseread
|
||||
digitalWrite(_sck, LOW);
|
||||
if(d & bit) digitalWrite(_mosi, HIGH);
|
||||
else digitalWrite(_mosi, LOW);
|
||||
digitalWrite(_sck, HIGH);
|
||||
digitalWrite(_sck, LOW);
|
||||
if (d & bit)
|
||||
digitalWrite(_mosi, HIGH);
|
||||
else
|
||||
digitalWrite(_mosi, LOW);
|
||||
digitalWrite(_sck, HIGH);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
csHigh();
|
||||
|
||||
csHigh();
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief read data at the specific address
|
||||
@param addr the address to read from
|
||||
@param buf the data buffer to read into
|
||||
@param num the number of bytes to read
|
||||
@param reg pass MCPSRAM_RDSR if you are reading the status register, MCPSRAM_READ if you are reading data. Defaults to MCPSRAM_READ.
|
||||
@param addr the address to read from
|
||||
@param buf the data buffer to read into
|
||||
@param num the number of bytes to read
|
||||
@param reg pass MCPSRAM_RDSR if you are reading the status
|
||||
register, MCPSRAM_READ if you are reading data. Defaults to MCPSRAM_READ.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_MCPSRAM::read(uint16_t addr, uint8_t *buf, uint16_t num, uint8_t reg)
|
||||
{
|
||||
void Adafruit_MCPSRAM::read(uint16_t addr, uint8_t *buf, uint16_t num,
|
||||
uint8_t reg) {
|
||||
|
||||
csLow();
|
||||
csLow();
|
||||
|
||||
//write command and address
|
||||
uint8_t cmdbuf[3];
|
||||
cmdbuf[0] = reg;
|
||||
cmdbuf[1] = (addr >> 8);
|
||||
cmdbuf[2] = addr & 0xFF;
|
||||
for(int i=0; i<3; i++){
|
||||
// write command and address
|
||||
uint8_t cmdbuf[3];
|
||||
cmdbuf[0] = reg;
|
||||
cmdbuf[1] = (addr >> 8);
|
||||
cmdbuf[2] = addr & 0xFF;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
uint8_t d = cmdbuf[i];
|
||||
|
||||
if(hwSPI) {
|
||||
(void)SPI.transfer(d);
|
||||
} else {
|
||||
for(uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
uint8_t d = cmdbuf[i];
|
||||
|
||||
if (hwSPI) {
|
||||
(void)SPI.transfer(d);
|
||||
} else {
|
||||
for (uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
#ifdef HAVE_PORTREG
|
||||
*clkport &= ~clkpinmask;
|
||||
if(d & bit) *mosiport |= mosipinmask;
|
||||
else *mosiport &= ~mosipinmask;
|
||||
*clkport |= clkpinmask;
|
||||
*clkport &= ~clkpinmask;
|
||||
if (d & bit)
|
||||
*mosiport |= mosipinmask;
|
||||
else
|
||||
*mosiport &= ~mosipinmask;
|
||||
*clkport |= clkpinmask;
|
||||
#else
|
||||
digitalWrite(_sck, LOW);
|
||||
if(d & bit) digitalWrite(_mosi, HIGH);
|
||||
else digitalWrite(_mosi, LOW);
|
||||
digitalWrite(_sck, HIGH);
|
||||
digitalWrite(_sck, LOW);
|
||||
if (d & bit)
|
||||
digitalWrite(_mosi, HIGH);
|
||||
else
|
||||
digitalWrite(_mosi, LOW);
|
||||
digitalWrite(_sck, HIGH);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (reg != MCPSRAM_READ)
|
||||
break;
|
||||
}
|
||||
|
||||
// read data into buffer
|
||||
for (int i = 0; i < num; i++) {
|
||||
|
||||
if (hwSPI) {
|
||||
buf[i] = SPI.transfer(0x00);
|
||||
} else {
|
||||
for (uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
#ifdef HAVE_PORTREG
|
||||
*clkport &= ~clkpinmask;
|
||||
*clkport |= clkpinmask;
|
||||
buf[i] = (buf[i] << 1) | = *misoport & misoport;
|
||||
#else
|
||||
digitalWrite(_sck, LOW);
|
||||
digitalWrite(_sck, HIGH);
|
||||
|
||||
buf[i] = (buf[i] << 1) | digitalRead(_miso);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
if(reg != MCPSRAM_READ) break;
|
||||
}
|
||||
|
||||
//read data into buffer
|
||||
for(int i=0; i<num; i++){
|
||||
|
||||
if(hwSPI) {
|
||||
buf[i] = SPI.transfer(0x00);
|
||||
} else {
|
||||
for(uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
#ifdef HAVE_PORTREG
|
||||
*clkport &= ~clkpinmask;
|
||||
*clkport |= clkpinmask;
|
||||
buf[i] = (buf[i] << 1) | = *misoport & misoport;
|
||||
#else
|
||||
digitalWrite(_sck, LOW);
|
||||
digitalWrite(_sck, HIGH);
|
||||
|
||||
buf[i] = (buf[i] << 1) | digitalRead(_miso);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
csHigh();
|
||||
csHigh();
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief 1 byte of data at the specified address
|
||||
@param addr the address to read data at
|
||||
@param reg MCPSRAM_READ if reading data, MCPSRAM_RDSR if reading a status register.
|
||||
@returns the read data byte.
|
||||
@param addr the address to read data at
|
||||
@param reg MCPSRAM_READ if reading data, MCPSRAM_RDSR if reading
|
||||
a status register.
|
||||
@returns the read data byte.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_MCPSRAM::read8(uint16_t addr, uint8_t reg)
|
||||
{
|
||||
uint8_t c;
|
||||
this->read(addr, &c, 1, reg);
|
||||
return c;
|
||||
uint8_t Adafruit_MCPSRAM::read8(uint16_t addr, uint8_t reg) {
|
||||
uint8_t c;
|
||||
this->read(addr, &c, 1, reg);
|
||||
return c;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief read 2 bytes of data at the specified address
|
||||
@param addr the address to read
|
||||
@returns the read data bytes as a 16 bit unsigned integer.
|
||||
@param addr the address to read
|
||||
@returns the read data bytes as a 16 bit unsigned integer.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint16_t Adafruit_MCPSRAM::read16(uint16_t addr)
|
||||
{
|
||||
uint8_t b[2];
|
||||
this->read(addr, b, 2);
|
||||
return ((uint16_t)b[0] << 8) | b[1];
|
||||
uint16_t Adafruit_MCPSRAM::read16(uint16_t addr) {
|
||||
uint8_t b[2];
|
||||
this->read(addr, b, 2);
|
||||
return ((uint16_t)b[0] << 8) | b[1];
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief write 1 byte of data at the specified address.
|
||||
@param addr the address to write to
|
||||
@param val the value to write
|
||||
@param reg MCPSRAM_WRITE if writing data, MCPSRAM_WRSR if writing a status register.
|
||||
@param addr the address to write to
|
||||
@param val the value to write
|
||||
@param reg MCPSRAM_WRITE if writing data, MCPSRAM_WRSR if
|
||||
writing a status register.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_MCPSRAM::write8(uint16_t addr, uint8_t val, uint8_t reg)
|
||||
{
|
||||
this->write(addr, &val, 1, reg);
|
||||
void Adafruit_MCPSRAM::write8(uint16_t addr, uint8_t val, uint8_t reg) {
|
||||
this->write(addr, &val, 1, reg);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief write 2 bytes of data at the specified address.
|
||||
@param addr the address to write to
|
||||
@param val the value to write
|
||||
@param addr the address to write to
|
||||
@param val the value to write
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_MCPSRAM::write16(uint16_t addr, uint16_t val)
|
||||
{
|
||||
uint8_t b[2];
|
||||
b[0] = (val >> 8);
|
||||
b[1] = (val);
|
||||
this->write(addr, b, 2);
|
||||
void Adafruit_MCPSRAM::write16(uint16_t addr, uint16_t val) {
|
||||
uint8_t b[2];
|
||||
b[0] = (val >> 8);
|
||||
b[1] = (val);
|
||||
this->write(addr, b, 2);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief erase a block of data.
|
||||
@param addr the address to start the erase at
|
||||
@param length the number of bytes to fill
|
||||
@param val the value to set the data to.
|
||||
@param addr the address to start the erase at
|
||||
@param length the number of bytes to fill
|
||||
@param val the value to set the data to.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_MCPSRAM::erase(uint16_t addr, uint16_t length, uint8_t val)
|
||||
{
|
||||
csLow();
|
||||
//write command and address
|
||||
uint8_t cmdbuf[3];
|
||||
cmdbuf[0] = MCPSRAM_WRITE;
|
||||
cmdbuf[1] = (addr >> 8);
|
||||
cmdbuf[2] = addr & 0xFF;
|
||||
|
||||
for(int i=0; i<3; i++){
|
||||
void Adafruit_MCPSRAM::erase(uint16_t addr, uint16_t length, uint8_t val) {
|
||||
csLow();
|
||||
// write command and address
|
||||
uint8_t cmdbuf[3];
|
||||
cmdbuf[0] = MCPSRAM_WRITE;
|
||||
cmdbuf[1] = (addr >> 8);
|
||||
cmdbuf[2] = addr & 0xFF;
|
||||
|
||||
uint8_t d = cmdbuf[i];
|
||||
|
||||
if(hwSPI) {
|
||||
(void)SPI.transfer(d);
|
||||
} else {
|
||||
for(uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
#ifdef HAVE_PORTREG
|
||||
*clkport &= ~clkpinmask;
|
||||
if(d & bit) *mosiport |= mosipinmask;
|
||||
else *mosiport &= ~mosipinmask;
|
||||
*clkport |= clkpinmask;
|
||||
#else
|
||||
digitalWrite(_sck, LOW);
|
||||
if(d & bit) digitalWrite(_mosi, HIGH);
|
||||
else digitalWrite(_mosi, LOW);
|
||||
digitalWrite(_sck, HIGH);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
//write buffer of data
|
||||
for(uint16_t i=0; i<length; i++){
|
||||
uint8_t d = cmdbuf[i];
|
||||
|
||||
uint8_t d = val;
|
||||
|
||||
if(hwSPI) {
|
||||
(void)SPI.transfer(d);
|
||||
} else {
|
||||
for(uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
#ifdef HAVE_PORTREG
|
||||
*clkport &= ~clkpinmask;
|
||||
if(d & bit) *mosiport |= mosipinmask;
|
||||
else *mosiport &= ~mosipinmask;
|
||||
*clkport |= clkpinmask;
|
||||
#else
|
||||
digitalWrite(_sck, LOW);
|
||||
if(d & bit) digitalWrite(_mosi, HIGH);
|
||||
else digitalWrite(_mosi, LOW);
|
||||
digitalWrite(_sck, HIGH);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
csHigh();
|
||||
if (hwSPI) {
|
||||
(void)SPI.transfer(d);
|
||||
} else {
|
||||
for (uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
#ifdef HAVE_PORTREG
|
||||
*clkport &= ~clkpinmask;
|
||||
if (d & bit)
|
||||
*mosiport |= mosipinmask;
|
||||
else
|
||||
*mosiport &= ~mosipinmask;
|
||||
*clkport |= clkpinmask;
|
||||
#else
|
||||
digitalWrite(_sck, LOW);
|
||||
if (d & bit)
|
||||
digitalWrite(_mosi, HIGH);
|
||||
else
|
||||
digitalWrite(_mosi, LOW);
|
||||
digitalWrite(_sck, HIGH);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// write buffer of data
|
||||
for (uint16_t i = 0; i < length; i++) {
|
||||
|
||||
uint8_t d = val;
|
||||
|
||||
if (hwSPI) {
|
||||
(void)SPI.transfer(d);
|
||||
} else {
|
||||
for (uint8_t bit = 0x80; bit; bit >>= 1) {
|
||||
#ifdef HAVE_PORTREG
|
||||
*clkport &= ~clkpinmask;
|
||||
if (d & bit)
|
||||
*mosiport |= mosipinmask;
|
||||
else
|
||||
*mosiport &= ~mosipinmask;
|
||||
*clkport |= clkpinmask;
|
||||
#else
|
||||
digitalWrite(_sck, LOW);
|
||||
if (d & bit)
|
||||
digitalWrite(_mosi, HIGH);
|
||||
else
|
||||
digitalWrite(_mosi, LOW);
|
||||
digitalWrite(_sck, HIGH);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
csHigh();
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -361,15 +378,14 @@ void Adafruit_MCPSRAM::erase(uint16_t addr, uint16_t length, uint8_t val)
|
|||
@brief set chip select pin high
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_MCPSRAM::csHigh()
|
||||
{
|
||||
void Adafruit_MCPSRAM::csHigh() {
|
||||
#ifdef SPI_HAS_TRANSACTION
|
||||
SPI.endTransaction();
|
||||
SPI.endTransaction();
|
||||
#endif
|
||||
#ifdef HAVE_PORTREG
|
||||
*csport |= cspinmask;
|
||||
*csport |= cspinmask;
|
||||
#else
|
||||
digitalWrite(_cs, HIGH);
|
||||
digitalWrite(_cs, HIGH);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -378,14 +394,13 @@ void Adafruit_MCPSRAM::csHigh()
|
|||
@brief set chip select pin low
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_MCPSRAM::csLow()
|
||||
{
|
||||
void Adafruit_MCPSRAM::csLow() {
|
||||
#ifdef SPI_HAS_TRANSACTION
|
||||
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
||||
#endif
|
||||
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
||||
#endif
|
||||
#ifdef HAVE_PORTREG
|
||||
*csport &= ~cspinmask;
|
||||
*csport &= ~cspinmask;
|
||||
#else
|
||||
digitalWrite(_cs, LOW);
|
||||
digitalWrite(_cs, LOW);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
#define MCPSRAM_READ 0x03 ///< read command
|
||||
#define MCPSRAM_READ 0x03 ///< read command
|
||||
#define MCPSRAM_WRITE 0x02 ///< write command
|
||||
#define MCPSRAM_RDSR 0x05 ///< read status register command
|
||||
#define MCPSRAM_WRSR 0x01 ///< write status register command
|
||||
#define MCPSRAM_RDSR 0x05 ///< read status register command
|
||||
#define MCPSRAM_WRSR 0x01 ///< write status register command
|
||||
|
||||
#define K640_SEQUENTIAL_MODE (1 << 6) ///< put ram chip in sequential mode
|
||||
|
||||
|
|
@ -13,31 +13,33 @@
|
|||
*/
|
||||
/**************************************************************************/
|
||||
class Adafruit_MCPSRAM {
|
||||
public:
|
||||
Adafruit_MCPSRAM(int8_t mosi, int8_t miso, int8_t sck, int8_t cs);
|
||||
Adafruit_MCPSRAM(int8_t cs);
|
||||
~Adafruit_MCPSRAM() {}
|
||||
|
||||
void begin();
|
||||
|
||||
void write(uint16_t addr, uint8_t *buf, uint16_t num, uint8_t reg = MCPSRAM_WRITE);
|
||||
void read(uint16_t addr, uint8_t *buf, uint16_t num, uint8_t reg = MCPSRAM_READ);
|
||||
void erase(uint16_t addr, uint16_t length, uint8_t val = 0x00);
|
||||
|
||||
uint8_t read8(uint16_t addr, uint8_t reg = MCPSRAM_READ);
|
||||
uint16_t read16(uint16_t addr);
|
||||
|
||||
void write8(uint16_t addr, uint8_t val, uint8_t reg = MCPSRAM_WRITE);
|
||||
void write16(uint16_t addr, uint16_t val);
|
||||
|
||||
void csHigh();
|
||||
void csLow();
|
||||
|
||||
private:
|
||||
boolean hwSPI; ///< true if using hardware SPI
|
||||
public:
|
||||
Adafruit_MCPSRAM(int8_t mosi, int8_t miso, int8_t sck, int8_t cs);
|
||||
Adafruit_MCPSRAM(int8_t cs);
|
||||
~Adafruit_MCPSRAM() {}
|
||||
|
||||
void begin();
|
||||
|
||||
void write(uint16_t addr, uint8_t *buf, uint16_t num,
|
||||
uint8_t reg = MCPSRAM_WRITE);
|
||||
void read(uint16_t addr, uint8_t *buf, uint16_t num,
|
||||
uint8_t reg = MCPSRAM_READ);
|
||||
void erase(uint16_t addr, uint16_t length, uint8_t val = 0x00);
|
||||
|
||||
uint8_t read8(uint16_t addr, uint8_t reg = MCPSRAM_READ);
|
||||
uint16_t read16(uint16_t addr);
|
||||
|
||||
void write8(uint16_t addr, uint8_t val, uint8_t reg = MCPSRAM_WRITE);
|
||||
void write16(uint16_t addr, uint16_t val);
|
||||
|
||||
void csHigh();
|
||||
void csLow();
|
||||
|
||||
private:
|
||||
boolean hwSPI; ///< true if using hardware SPI
|
||||
#ifdef HAVE_PORTREG
|
||||
PortReg *mosiport, *clkport, *csport, *misoport;
|
||||
PortMask mosipinmask, clkpinmask, cspinmask, misopinmask;
|
||||
PortReg *mosiport, *clkport, *csport, *misoport;
|
||||
PortMask mosipinmask, clkpinmask, cspinmask, misopinmask;
|
||||
#endif
|
||||
int8_t _cs, _mosi, _miso, _sck;
|
||||
int8_t _cs, _mosi, _miso, _sck;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
#include "Adafruit_EPD.h"
|
||||
#include "Adafruit_SSD1608.h"
|
||||
#include "Adafruit_EPD.h"
|
||||
|
||||
#define BUSY_WAIT 500
|
||||
|
||||
const unsigned char LUT_DATA[30]= {
|
||||
0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, 0x66, 0x69,
|
||||
0x69, 0x59, 0x58, 0x99, 0x99, 0x88, 0x00, 0x00, 0x00, 0x00,
|
||||
0xF8, 0xB4, 0x13, 0x51, 0x35, 0x51, 0x51, 0x19, 0x01, 0x00
|
||||
};
|
||||
const unsigned char LUT_DATA[30] = {
|
||||
0x02, 0x02, 0x01, 0x11, 0x12, 0x12, 0x22, 0x22, 0x66, 0x69,
|
||||
0x69, 0x59, 0x58, 0x99, 0x99, 0x88, 0x00, 0x00, 0x00, 0x00,
|
||||
0xF8, 0xB4, 0x13, 0x51, 0x35, 0x51, 0x51, 0x19, 0x01, 0x00};
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
|
@ -24,10 +23,11 @@ const unsigned char LUT_DATA[30]= {
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_SSD1608::Adafruit_SSD1608(int width, int height,
|
||||
int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t SRCS, int8_t MISO, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
|
||||
Adafruit_SSD1608::Adafruit_SSD1608(int width, int height, int8_t SID,
|
||||
int8_t SCLK, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
|
||||
|
||||
if ((width % 8) != 0) {
|
||||
width += 8 - (width % 8);
|
||||
|
|
@ -59,8 +59,9 @@ Adafruit_SSD1608::Adafruit_SSD1608(int width, int height,
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_SSD1608::Adafruit_SSD1608(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
Adafruit_SSD1608::Adafruit_SSD1608(int width, int height, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
|
||||
if ((height % 8) != 0) {
|
||||
height += 8 - (height % 8);
|
||||
|
|
@ -83,10 +84,9 @@ Adafruit_SSD1608::Adafruit_SSD1608(int width, int height, int8_t DC, int8_t RST,
|
|||
@brief wait for busy signal to end
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SSD1608::busy_wait(void)
|
||||
{
|
||||
void Adafruit_SSD1608::busy_wait(void) {
|
||||
if (_busy_pin >= 0) {
|
||||
while(digitalRead(_busy_pin)) { //wait for busy low
|
||||
while (digitalRead(_busy_pin)) { // wait for busy low
|
||||
delay(10);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -100,24 +100,21 @@ void Adafruit_SSD1608::busy_wait(void)
|
|||
@param reset if true the reset pin will be toggled.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SSD1608::begin(bool reset)
|
||||
{
|
||||
void Adafruit_SSD1608::begin(bool reset) {
|
||||
Adafruit_EPD::begin(reset);
|
||||
setBlackBuffer(0, true); // black defaults to inverted
|
||||
setColorBuffer(0, true); // no secondary buffer, so we'll just reuse index 0
|
||||
|
||||
setBlackBuffer(0, true); // black defaults to inverted
|
||||
setColorBuffer(0, true); // no secondary buffer, so we'll just reuse index 0
|
||||
|
||||
delay(100);
|
||||
powerDown();
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief signal the display to update
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SSD1608::update()
|
||||
{
|
||||
void Adafruit_SSD1608::update() {
|
||||
uint8_t buf[1];
|
||||
|
||||
// display update sequence
|
||||
|
|
@ -134,8 +131,7 @@ void Adafruit_SSD1608::update()
|
|||
@brief start up the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SSD1608::powerUp()
|
||||
{
|
||||
void Adafruit_SSD1608::powerUp() {
|
||||
uint8_t buf[5];
|
||||
|
||||
hardwareReset();
|
||||
|
|
@ -151,7 +147,7 @@ void Adafruit_SSD1608::powerUp()
|
|||
buf[1] = (HEIGHT - 1) >> 8;
|
||||
buf[2] = 0x00;
|
||||
EPD_command(SSD1608_DRIVER_CONTROL, buf, 3);
|
||||
|
||||
|
||||
// Set dummy line period
|
||||
buf[0] = 0x1B;
|
||||
EPD_command(SSD1608_WRITE_DUMMY, buf, 1);
|
||||
|
|
@ -166,7 +162,7 @@ void Adafruit_SSD1608::powerUp()
|
|||
|
||||
// Set ram X start/end postion
|
||||
buf[0] = 0x00;
|
||||
buf[1] = WIDTH/8 - 1;
|
||||
buf[1] = WIDTH / 8 - 1;
|
||||
EPD_command(SSD1608_SET_RAMXPOS, buf, 2);
|
||||
|
||||
// Set ram Y start/end postion
|
||||
|
|
@ -182,7 +178,6 @@ void Adafruit_SSD1608::powerUp()
|
|||
|
||||
EPD_command(SSD1608_WRITE_LUT, LUT_DATA, 30);
|
||||
|
||||
|
||||
/*
|
||||
// border color
|
||||
buf[0] = 0x03;
|
||||
|
|
@ -204,7 +199,7 @@ void Adafruit_SSD1608::powerUp()
|
|||
buf[0] = 0;
|
||||
EPD_command(SSD1608_SET_RAMXCOUNT, buf, 1);
|
||||
|
||||
// set RAM y address count;
|
||||
// set RAM y address count;
|
||||
buf[0] = HEIGHT - 1;
|
||||
buf[1] = (HEIGHT - 1) >> 8;
|
||||
EPD_command(SSD1608_SET_RAMYCOUNT, buf, 2);
|
||||
|
|
@ -229,9 +224,10 @@ void Adafruit_SSD1608::powerDown(void) {
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Send the specific command to start writing to EPD display RAM
|
||||
@param index The index for which buffer to write (0 or 1 or tri-color displays)
|
||||
Ignored for monochrome displays.
|
||||
@returns The byte that is read from SPI at the same time as sending the command
|
||||
@param index The index for which buffer to write (0 or 1 or tri-color
|
||||
displays) Ignored for monochrome displays.
|
||||
@returns The byte that is read from SPI at the same time as sending the
|
||||
command
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_SSD1608::writeRAMCommand(uint8_t index) {
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@
|
|||
#define SSD1608_MASTER_ACTIVATE 0x20
|
||||
#define SSD1608_DISP_CTRL1 0x21
|
||||
#define SSD1608_DISP_CTRL2 0x22
|
||||
#define SSD1608_WRITE_RAM 0x24
|
||||
#define SSD1608_READ_RAM 0x25
|
||||
#define SSD1608_VCOM_SENSE 0x28
|
||||
#define SSD1608_VCOM_DURATION 0x29
|
||||
#define SSD1608_WRITE_VCOM 0x2C
|
||||
#define SSD1608_WRITE_RAM 0x24
|
||||
#define SSD1608_READ_RAM 0x25
|
||||
#define SSD1608_VCOM_SENSE 0x28
|
||||
#define SSD1608_VCOM_DURATION 0x29
|
||||
#define SSD1608_WRITE_VCOM 0x2C
|
||||
#define SSD1608_READ_OTP 0x2D
|
||||
#define SSD1608_WRITE_LUT 0x32
|
||||
#define SSD1608_WRITE_DUMMY 0x3A
|
||||
|
|
@ -37,8 +37,7 @@
|
|||
#define SSD1608_SET_RAMYPOS 0x45
|
||||
#define SSD1608_SET_RAMXCOUNT 0x4E
|
||||
#define SSD1608_SET_RAMYCOUNT 0x4F
|
||||
#define SSD1608_NOP 0xFF
|
||||
|
||||
#define SSD1608_NOP 0xFF
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
|
@ -46,16 +45,18 @@
|
|||
*/
|
||||
/**************************************************************************/
|
||||
class Adafruit_SSD1608 : public Adafruit_EPD {
|
||||
public:
|
||||
public:
|
||||
Adafruit_SSD1608(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
|
||||
int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY = -1);
|
||||
Adafruit_SSD1608(int width, int height, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t SRCS, int8_t BUSY = -1);
|
||||
|
||||
Adafruit_SSD1608(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY = -1);
|
||||
Adafruit_SSD1608(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY = -1);
|
||||
|
||||
void begin(bool reset=true);
|
||||
void begin(bool reset = true);
|
||||
void powerUp();
|
||||
void powerDown();
|
||||
void update();
|
||||
|
||||
|
||||
protected:
|
||||
uint8_t writeRAMCommand(uint8_t index);
|
||||
void setRAMAddress(uint16_t x, uint16_t y);
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
#include "Adafruit_EPD.h"
|
||||
#include "Adafruit_SSD1675.h"
|
||||
#include "Adafruit_EPD.h"
|
||||
|
||||
#define BUSY_WAIT 500
|
||||
|
||||
const unsigned char LUT_DATA[]= {
|
||||
0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT0: BB: VS 0 ~7
|
||||
0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT1: BW: VS 0 ~7
|
||||
0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT2: WB: VS 0 ~7
|
||||
0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT3: WW: VS 0 ~7
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00, //LUT4: VCOM: VS 0 ~7
|
||||
|
||||
0x03,0x03,0x00,0x00,0x02, // TP0 A~D RP0
|
||||
0x09,0x09,0x00,0x00,0x02, // TP1 A~D RP1
|
||||
0x03,0x03,0x00,0x00,0x02, // TP2 A~D RP2
|
||||
0x00,0x00,0x00,0x00,0x00, // TP3 A~D RP3
|
||||
0x00,0x00,0x00,0x00,0x00, // TP4 A~D RP4
|
||||
0x00,0x00,0x00,0x00,0x00, // TP5 A~D RP5
|
||||
0x00,0x00,0x00,0x00,0x00, // TP6 A~D RP6
|
||||
|
||||
0x15,0x41,0xA8,0x32,0x30,0x0A,
|
||||
const unsigned char LUT_DATA[] = {
|
||||
0x80, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, // LUT0: BB: VS 0 ~7
|
||||
0x10, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, // LUT1: BW: VS 0 ~7
|
||||
0x80, 0x60, 0x40, 0x00, 0x00, 0x00, 0x00, // LUT2: WB: VS 0 ~7
|
||||
0x10, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, // LUT3: WW: VS 0 ~7
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // LUT4: VCOM: VS 0 ~7
|
||||
|
||||
0x03, 0x03, 0x00, 0x00, 0x02, // TP0 A~D RP0
|
||||
0x09, 0x09, 0x00, 0x00, 0x02, // TP1 A~D RP1
|
||||
0x03, 0x03, 0x00, 0x00, 0x02, // TP2 A~D RP2
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, // TP3 A~D RP3
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, // TP4 A~D RP4
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, // TP5 A~D RP5
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, // TP6 A~D RP6
|
||||
|
||||
0x15, 0x41, 0xA8, 0x32, 0x30, 0x0A,
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -36,11 +36,11 @@ const unsigned char LUT_DATA[]= {
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_SSD1675::Adafruit_SSD1675(int width, int height,
|
||||
int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t SRCS, int8_t MISO, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY)
|
||||
{
|
||||
Adafruit_SSD1675::Adafruit_SSD1675(int width, int height, int8_t SID,
|
||||
int8_t SCLK, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
|
||||
if ((height % 8) != 0) {
|
||||
height += 8 - (height % 8);
|
||||
}
|
||||
|
|
@ -73,8 +73,9 @@ Adafruit_SSD1675::Adafruit_SSD1675(int width, int height,
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_SSD1675::Adafruit_SSD1675(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
Adafruit_SSD1675::Adafruit_SSD1675(int width, int height, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
if ((height % 8) != 0) {
|
||||
height += 8 - (height % 8);
|
||||
}
|
||||
|
|
@ -98,10 +99,9 @@ Adafruit_SSD1675::Adafruit_SSD1675(int width, int height, int8_t DC, int8_t RST,
|
|||
@brief wait for busy signal to end
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SSD1675::busy_wait(void)
|
||||
{
|
||||
void Adafruit_SSD1675::busy_wait(void) {
|
||||
if (_busy_pin >= 0) {
|
||||
while(digitalRead(_busy_pin)) { //wait for busy low
|
||||
while (digitalRead(_busy_pin)) { // wait for busy low
|
||||
delay(10);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -115,23 +115,20 @@ void Adafruit_SSD1675::busy_wait(void)
|
|||
@param reset if true the reset pin will be toggled.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SSD1675::begin(bool reset)
|
||||
{
|
||||
void Adafruit_SSD1675::begin(bool reset) {
|
||||
Adafruit_EPD::begin(reset);
|
||||
setBlackBuffer(0, true); // black defaults to inverted
|
||||
setColorBuffer(0, true); // no secondary buffer, so we'll just reuse index 0
|
||||
setBlackBuffer(0, true); // black defaults to inverted
|
||||
setColorBuffer(0, true); // no secondary buffer, so we'll just reuse index 0
|
||||
|
||||
powerDown();
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief signal the display to update
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SSD1675::update()
|
||||
{
|
||||
void Adafruit_SSD1675::update() {
|
||||
uint8_t buf[1];
|
||||
|
||||
// display update sequence
|
||||
|
|
@ -151,8 +148,7 @@ void Adafruit_SSD1675::update()
|
|||
@brief start up the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SSD1675::powerUp()
|
||||
{
|
||||
void Adafruit_SSD1675::powerUp() {
|
||||
uint8_t buf[5];
|
||||
|
||||
hardwareReset();
|
||||
|
|
@ -172,7 +168,7 @@ void Adafruit_SSD1675::powerUp()
|
|||
EPD_command(SSD1675_SET_DIGITALBLOCK, buf, 1);
|
||||
|
||||
// driver output control
|
||||
buf[0] = 0xFA; // 250-1
|
||||
buf[0] = 0xFA; // 250-1
|
||||
buf[1] = 0x01;
|
||||
buf[2] = 0x00;
|
||||
EPD_command(SSD1675_DRIVER_CONTROL, buf, 3);
|
||||
|
|
@ -183,11 +179,11 @@ void Adafruit_SSD1675::powerUp()
|
|||
|
||||
// Set ram X start/end postion
|
||||
buf[0] = 0x00;
|
||||
buf[1] = 0x0F; // (15+1) * 8 = 128
|
||||
buf[1] = 0x0F; // (15+1) * 8 = 128
|
||||
EPD_command(SSD1675_SET_RAMXPOS, buf, 2);
|
||||
|
||||
// Set ram Y start/end postion
|
||||
buf[0] = 0x00; // 0xF9-->(249+1)=250
|
||||
buf[0] = 0x00; // 0xF9-->(249+1)=250
|
||||
buf[1] = 0x00;
|
||||
buf[2] = 0xF9;
|
||||
buf[3] = 0x00;
|
||||
|
|
@ -210,7 +206,7 @@ void Adafruit_SSD1675::powerUp()
|
|||
buf[1] = LUT_DATA[72];
|
||||
buf[2] = LUT_DATA[73];
|
||||
EPD_command(SSD1675_SOURCE_VOLTAGE, buf, 3);
|
||||
|
||||
|
||||
// Set dummy line period
|
||||
buf[0] = LUT_DATA[74];
|
||||
EPD_command(SSD1675_WRITE_DUMMY, buf, 1);
|
||||
|
|
@ -225,7 +221,7 @@ void Adafruit_SSD1675::powerUp()
|
|||
buf[0] = 0;
|
||||
EPD_command(SSD1675_SET_RAMXCOUNT, buf, 1);
|
||||
|
||||
// set RAM y address count to 0X127;
|
||||
// set RAM y address count to 0X127;
|
||||
buf[0] = 0xF9;
|
||||
buf[1] = 0;
|
||||
EPD_command(SSD1675_SET_RAMYCOUNT, buf, 2);
|
||||
|
|
@ -233,14 +229,12 @@ void Adafruit_SSD1675::powerUp()
|
|||
busy_wait();
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief wind down the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SSD1675::powerDown()
|
||||
{
|
||||
void Adafruit_SSD1675::powerDown() {
|
||||
uint8_t buf[1];
|
||||
// Only deep sleep if we can get out of it
|
||||
if (_reset_pin >= 0) {
|
||||
|
|
@ -257,9 +251,10 @@ void Adafruit_SSD1675::powerDown()
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Send the specific command to start writing to EPD display RAM
|
||||
@param index The index for which buffer to write (0 or 1 or tri-color displays)
|
||||
Ignored for monochrome displays.
|
||||
@returns The byte that is read from SPI at the same time as sending the command
|
||||
@param index The index for which buffer to write (0 or 1 or tri-color
|
||||
displays) Ignored for monochrome displays.
|
||||
@returns The byte that is read from SPI at the same time as sending the
|
||||
command
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_SSD1675::writeRAMCommand(uint8_t index) {
|
||||
|
|
|
|||
|
|
@ -35,18 +35,20 @@
|
|||
#define SSD1675_SET_ANALOGBLOCK 0x74
|
||||
#define SSD1675_SET_DIGITALBLOCK 0x7E
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Class for interfacing with SSD1675 EPD drivers
|
||||
*/
|
||||
/**************************************************************************/
|
||||
class Adafruit_SSD1675 : public Adafruit_EPD {
|
||||
public:
|
||||
Adafruit_SSD1675(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY = -1);
|
||||
Adafruit_SSD1675(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY = -1);
|
||||
public:
|
||||
Adafruit_SSD1675(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
|
||||
int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY = -1);
|
||||
Adafruit_SSD1675(int width, int height, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t SRCS, int8_t BUSY = -1);
|
||||
|
||||
void begin(bool reset=true);
|
||||
void begin(bool reset = true);
|
||||
void powerUp();
|
||||
void update();
|
||||
void powerDown();
|
||||
|
|
|
|||
|
|
@ -1,29 +1,24 @@
|
|||
#include "Adafruit_EPD.h"
|
||||
#include "Adafruit_SSD1675B.h"
|
||||
#include "Adafruit_EPD.h"
|
||||
|
||||
#define BUSY_WAIT 500
|
||||
|
||||
#define SSD1675B_USELUT
|
||||
|
||||
const unsigned char LUT_DATA[]= {
|
||||
0xA0, 0x90, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x50, 0x90, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xA0, 0x90, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x50, 0x90, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x0F, 0x0F, 0x00, 0x00, 0x00,
|
||||
0x0F, 0x0F, 0x00, 0x00, 0x03,
|
||||
0x0F, 0x0F, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x15, 0x41, 0xA8, 0x32, 0x50, 0x2C, 0x0B,
|
||||
const unsigned char LUT_DATA[] = {
|
||||
0xA0, 0x90, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x50, 0x90, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xA0, 0x90, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x50, 0x90, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x03,
|
||||
0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x15, 0x41, 0xA8, 0x32, 0x50, 0x2C, 0x0B,
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -41,11 +36,11 @@ const unsigned char LUT_DATA[]= {
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_SSD1675B::Adafruit_SSD1675B(int width, int height,
|
||||
int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t SRCS, int8_t MISO, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY)
|
||||
{
|
||||
Adafruit_SSD1675B::Adafruit_SSD1675B(int width, int height, int8_t SID,
|
||||
int8_t SCLK, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
|
||||
if ((height % 8) != 0) {
|
||||
height += 8 - (height % 8);
|
||||
}
|
||||
|
|
@ -78,8 +73,10 @@ Adafruit_SSD1675B::Adafruit_SSD1675B(int width, int height,
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_SSD1675B::Adafruit_SSD1675B(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
Adafruit_SSD1675B::Adafruit_SSD1675B(int width, int height, int8_t DC,
|
||||
int8_t RST, int8_t CS, int8_t SRCS,
|
||||
int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
if ((height % 8) != 0) {
|
||||
height += 8 - (height % 8);
|
||||
}
|
||||
|
|
@ -103,10 +100,9 @@ Adafruit_SSD1675B::Adafruit_SSD1675B(int width, int height, int8_t DC, int8_t RS
|
|||
@brief wait for busy signal to end
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SSD1675B::busy_wait(void)
|
||||
{
|
||||
void Adafruit_SSD1675B::busy_wait(void) {
|
||||
if (_busy_pin >= 0) {
|
||||
while(digitalRead(_busy_pin)) { //wait for busy low
|
||||
while (digitalRead(_busy_pin)) { // wait for busy low
|
||||
delay(10);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -120,23 +116,20 @@ void Adafruit_SSD1675B::busy_wait(void)
|
|||
@param reset if true the reset pin will be toggled.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SSD1675B::begin(bool reset)
|
||||
{
|
||||
void Adafruit_SSD1675B::begin(bool reset) {
|
||||
Adafruit_EPD::begin(reset);
|
||||
setBlackBuffer(0, true); // black defaults to inverted
|
||||
setColorBuffer(0, true); // no secondary buffer, so we'll just reuse index 0
|
||||
setBlackBuffer(0, true); // black defaults to inverted
|
||||
setColorBuffer(0, true); // no secondary buffer, so we'll just reuse index 0
|
||||
|
||||
powerDown();
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief signal the display to update
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SSD1675B::update()
|
||||
{
|
||||
void Adafruit_SSD1675B::update() {
|
||||
uint8_t buf[1];
|
||||
|
||||
// display update sequence
|
||||
|
|
@ -156,8 +149,7 @@ void Adafruit_SSD1675B::update()
|
|||
@brief start up the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SSD1675B::powerUp()
|
||||
{
|
||||
void Adafruit_SSD1675B::powerUp() {
|
||||
uint8_t buf[5];
|
||||
|
||||
hardwareReset();
|
||||
|
|
@ -179,8 +171,8 @@ void Adafruit_SSD1675B::powerUp()
|
|||
#endif
|
||||
|
||||
// driver output control
|
||||
buf[0] = WIDTH-1;
|
||||
buf[1] = (WIDTH-1) >> 8;
|
||||
buf[0] = WIDTH - 1;
|
||||
buf[1] = (WIDTH - 1) >> 8;
|
||||
buf[2] = 0x00;
|
||||
EPD_command(SSD1675B_DRIVER_CONTROL, buf, 3);
|
||||
|
||||
|
|
@ -196,8 +188,8 @@ void Adafruit_SSD1675B::powerUp()
|
|||
// Set ram Y start/end postion
|
||||
buf[0] = 0x00;
|
||||
buf[1] = 0x00;
|
||||
buf[2] = WIDTH-1;
|
||||
buf[3] = (WIDTH-1) >> 8;
|
||||
buf[2] = WIDTH - 1;
|
||||
buf[3] = (WIDTH - 1) >> 8;
|
||||
EPD_command(SSD1675B_SET_RAMYPOS, buf, 4);
|
||||
|
||||
// border color
|
||||
|
|
@ -218,7 +210,7 @@ void Adafruit_SSD1675B::powerUp()
|
|||
buf[1] = LUT_DATA[102];
|
||||
buf[2] = LUT_DATA[103];
|
||||
EPD_command(SSD1675B_SOURCE_VOLTAGE, buf, 3);
|
||||
|
||||
|
||||
// Set dummy line period
|
||||
buf[0] = LUT_DATA[105];
|
||||
EPD_command(SSD1675B_WRITE_DUMMY, buf, 1);
|
||||
|
|
@ -234,22 +226,20 @@ void Adafruit_SSD1675B::powerUp()
|
|||
buf[0] = 0;
|
||||
EPD_command(SSD1675_SET_RAMXCOUNT, buf, 1);
|
||||
|
||||
// set RAM y address count to max
|
||||
buf[0] = WIDTH-1;
|
||||
buf[1] = (WIDTH-1) >> 8;
|
||||
// set RAM y address count to max
|
||||
buf[0] = WIDTH - 1;
|
||||
buf[1] = (WIDTH - 1) >> 8;
|
||||
EPD_command(SSD1675_SET_RAMYCOUNT, buf, 2);
|
||||
|
||||
busy_wait();
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief wind down the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_SSD1675B::powerDown()
|
||||
{
|
||||
void Adafruit_SSD1675B::powerDown() {
|
||||
uint8_t buf[1];
|
||||
// Only deep sleep if we can get out of it
|
||||
if (_reset_pin >= 0) {
|
||||
|
|
@ -266,9 +256,10 @@ void Adafruit_SSD1675B::powerDown()
|
|||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Send the specific command to start writing to EPD display RAM
|
||||
@param index The index for which buffer to write (0 or 1 or tri-color displays)
|
||||
Ignored for monochrome displays.
|
||||
@returns The byte that is read from SPI at the same time as sending the command
|
||||
@param index The index for which buffer to write (0 or 1 or tri-color
|
||||
displays) Ignored for monochrome displays.
|
||||
@returns The byte that is read from SPI at the same time as sending the
|
||||
command
|
||||
*/
|
||||
/**************************************************************************/
|
||||
uint8_t Adafruit_SSD1675B::writeRAMCommand(uint8_t index) {
|
||||
|
|
@ -296,7 +287,7 @@ void Adafruit_SSD1675B::setRAMAddress(uint16_t x, uint16_t y) {
|
|||
EPD_command(SSD1675_SET_RAMXCOUNT, buf, 1);
|
||||
|
||||
// Set RAM Y address counter
|
||||
buf[0] = WIDTH-1;
|
||||
buf[1] = (WIDTH-1) >> 8;
|
||||
buf[0] = WIDTH - 1;
|
||||
buf[1] = (WIDTH - 1) >> 8;
|
||||
EPD_command(SSD1675_SET_RAMYCOUNT, buf, 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,18 +35,20 @@
|
|||
#define SSD1675B_SET_ANALOGBLOCK 0x74
|
||||
#define SSD1675B_SET_DIGITALBLOCK 0x7E
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Class for interfacing with SSD1675 EPD drivers
|
||||
*/
|
||||
/**************************************************************************/
|
||||
class Adafruit_SSD1675B : public Adafruit_EPD {
|
||||
public:
|
||||
Adafruit_SSD1675B(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY = -1);
|
||||
Adafruit_SSD1675B(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY = -1);
|
||||
public:
|
||||
Adafruit_SSD1675B(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
|
||||
int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY = -1);
|
||||
Adafruit_SSD1675B(int width, int height, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t SRCS, int8_t BUSY = -1);
|
||||
|
||||
void begin(bool reset=true);
|
||||
void begin(bool reset = true);
|
||||
void powerUp();
|
||||
void update();
|
||||
void powerDown();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
name=Adafruit EPD
|
||||
version=2.4.2
|
||||
version=2.4.3
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=ePaper display driver
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "Adafruit_EPD.h"
|
||||
#include "Adafruit_IL0371.h"
|
||||
#include "Adafruit_EPD.h"
|
||||
|
||||
#define BUSY_WAIT 500
|
||||
|
||||
|
|
@ -19,7 +19,10 @@
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL0371::Adafruit_IL0371(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY) : Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY){
|
||||
Adafruit_IL0371::Adafruit_IL0371(int width, int height, int8_t SID, int8_t SCLK,
|
||||
int8_t DC, int8_t RST, int8_t CS, int8_t SRCS,
|
||||
int8_t MISO, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
|
||||
#else
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
|
@ -34,12 +37,14 @@ Adafruit_IL0371::Adafruit_IL0371(int width, int height, int8_t SID, int8_t SCLK,
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL0371::Adafruit_IL0371(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t BUSY) : Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, BUSY) {
|
||||
bw_buf = (uint8_t *)malloc(width * height / 8);
|
||||
red_buf = (uint8_t *)malloc(width * height / 8);
|
||||
Adafruit_IL0371::Adafruit_IL0371(int width, int height, int8_t SID, int8_t SCLK,
|
||||
int8_t DC, int8_t RST, int8_t CS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, BUSY) {
|
||||
bw_buf = (uint8_t *)malloc(width * height / 8);
|
||||
red_buf = (uint8_t *)malloc(width * height / 8);
|
||||
#endif
|
||||
bw_bufsize = width * height / 8;
|
||||
red_bufsize = bw_bufsize;
|
||||
bw_bufsize = width * height / 8;
|
||||
red_bufsize = bw_bufsize;
|
||||
}
|
||||
|
||||
// constructor for hardware SPI - we indicate DataCommand, ChipSelect, Reset
|
||||
|
|
@ -56,7 +61,9 @@ Adafruit_IL0371::Adafruit_IL0371(int width, int height, int8_t SID, int8_t SCLK,
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL0371::Adafruit_IL0371(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY) : Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
Adafruit_IL0371::Adafruit_IL0371(int width, int height, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
#else
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
|
@ -69,12 +76,14 @@ Adafruit_IL0371::Adafruit_IL0371(int width, int height, int8_t DC, int8_t RST, i
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL0371::Adafruit_IL0371(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t BUSY) : Adafruit_EPD(width, height, DC, RST, CS, BUSY) {
|
||||
bw_buf = (uint8_t *)malloc(width * height / 8);
|
||||
red_buf = (uint8_t *)malloc(width * height / 8);
|
||||
Adafruit_IL0371::Adafruit_IL0371(int width, int height, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, BUSY) {
|
||||
bw_buf = (uint8_t *)malloc(width * height / 8);
|
||||
red_buf = (uint8_t *)malloc(width * height / 8);
|
||||
#endif
|
||||
bw_bufsize = width * height / 8;
|
||||
red_bufsize = bw_bufsize;
|
||||
bw_bufsize = width * height / 8;
|
||||
red_bufsize = bw_bufsize;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -83,21 +92,20 @@ Adafruit_IL0371::Adafruit_IL0371(int width, int height, int8_t DC, int8_t RST, i
|
|||
@param reset if true the reset pin will be toggled.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0371::begin(bool reset)
|
||||
{
|
||||
uint8_t buf[5];
|
||||
Adafruit_EPD::begin(reset);
|
||||
|
||||
buf[0] = 0x37;
|
||||
buf[1] = 0x00;
|
||||
//buf[2] = 0x0A;
|
||||
//buf[3] = 0x00;
|
||||
EPD_command(IL0371_POWER_SETTING, buf, 4);
|
||||
|
||||
buf[0] = 0xc7;
|
||||
buf[1] = 0xcc;
|
||||
buf[2] = 0x28;
|
||||
EPD_command(IL0371_BOOSTER_SOFT_START, buf, 3);
|
||||
void Adafruit_IL0371::begin(bool reset) {
|
||||
uint8_t buf[5];
|
||||
Adafruit_EPD::begin(reset);
|
||||
|
||||
buf[0] = 0x37;
|
||||
buf[1] = 0x00;
|
||||
// buf[2] = 0x0A;
|
||||
// buf[3] = 0x00;
|
||||
EPD_command(IL0371_POWER_SETTING, buf, 4);
|
||||
|
||||
buf[0] = 0xc7;
|
||||
buf[1] = 0xcc;
|
||||
buf[2] = 0x28;
|
||||
EPD_command(IL0371_BOOSTER_SOFT_START, buf, 3);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -105,30 +113,29 @@ void Adafruit_IL0371::begin(bool reset)
|
|||
@brief update the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0371::update()
|
||||
{
|
||||
EPD_command(IL0371_DISPLAY_REFRESH);
|
||||
|
||||
delay(10000);
|
||||
|
||||
//power off
|
||||
uint8_t buf[4];
|
||||
|
||||
buf[0] = 0x17;
|
||||
EPD_command(IL0371_CDI, buf, 1);
|
||||
|
||||
buf[0] = 0x1E;
|
||||
EPD_command(IL0371_VCM_DC_SETTING, buf, 0);
|
||||
|
||||
buf[0] = 0x02;
|
||||
buf[1] = 0x00;
|
||||
buf[2] = 0x00;
|
||||
buf[3] = 0x00;
|
||||
EPD_command(IL0371_POWER_SETTING);
|
||||
|
||||
EPD_command(IL0371_POWER_OFF);
|
||||
|
||||
delay(10000);
|
||||
void Adafruit_IL0371::update() {
|
||||
EPD_command(IL0371_DISPLAY_REFRESH);
|
||||
|
||||
delay(10000);
|
||||
|
||||
// power off
|
||||
uint8_t buf[4];
|
||||
|
||||
buf[0] = 0x17;
|
||||
EPD_command(IL0371_CDI, buf, 1);
|
||||
|
||||
buf[0] = 0x1E;
|
||||
EPD_command(IL0371_VCM_DC_SETTING, buf, 0);
|
||||
|
||||
buf[0] = 0x02;
|
||||
buf[1] = 0x00;
|
||||
buf[2] = 0x00;
|
||||
buf[3] = 0x00;
|
||||
EPD_command(IL0371_POWER_SETTING);
|
||||
|
||||
EPD_command(IL0371_POWER_OFF);
|
||||
|
||||
delay(10000);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -136,40 +143,40 @@ void Adafruit_IL0371::update()
|
|||
@brief start up the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0371::powerUp()
|
||||
{
|
||||
uint8_t buf[4];
|
||||
|
||||
EPD_command(IL0371_POWER_ON);
|
||||
if(busy > -1)
|
||||
while(digitalRead(busy)); //wait for busy low
|
||||
else
|
||||
delay(BUSY_WAIT);
|
||||
void Adafruit_IL0371::powerUp() {
|
||||
uint8_t buf[4];
|
||||
|
||||
delay(200);
|
||||
|
||||
buf[0] = 0xCF;
|
||||
buf[1] = 0x08;
|
||||
EPD_command(IL0371_PANEL_SETTING, buf, 2);
|
||||
|
||||
buf[0] = 0x77;
|
||||
EPD_command(IL0371_CDI, buf, 1);
|
||||
EPD_command(IL0371_POWER_ON);
|
||||
if (busy > -1)
|
||||
while (digitalRead(busy))
|
||||
; // wait for busy low
|
||||
else
|
||||
delay(BUSY_WAIT);
|
||||
|
||||
buf[0] = 0x03;
|
||||
EPD_command(0xe5, buf, 1);
|
||||
|
||||
buf[0] = 0x3c;
|
||||
EPD_command(IL0371_PLL, buf, 1);
|
||||
delay(200);
|
||||
|
||||
buf[0] = height() & 0xFF;
|
||||
buf[1] = (height() >> 8) & 0xFF;
|
||||
buf[2] = width() & 0xFF;
|
||||
buf[3] = (width() >> 8) & 0xFF;
|
||||
EPD_command(IL0371_RESOLUTION, buf, 4);
|
||||
|
||||
buf[0] = 0x0A;
|
||||
EPD_command(IL0371_VCM_DC_SETTING, buf, 1);
|
||||
delay(20);
|
||||
buf[0] = 0xCF;
|
||||
buf[1] = 0x08;
|
||||
EPD_command(IL0371_PANEL_SETTING, buf, 2);
|
||||
|
||||
buf[0] = 0x77;
|
||||
EPD_command(IL0371_CDI, buf, 1);
|
||||
|
||||
buf[0] = 0x03;
|
||||
EPD_command(0xe5, buf, 1);
|
||||
|
||||
buf[0] = 0x3c;
|
||||
EPD_command(IL0371_PLL, buf, 1);
|
||||
|
||||
buf[0] = height() & 0xFF;
|
||||
buf[1] = (height() >> 8) & 0xFF;
|
||||
buf[2] = width() & 0xFF;
|
||||
buf[3] = (width() >> 8) & 0xFF;
|
||||
EPD_command(IL0371_RESOLUTION, buf, 4);
|
||||
|
||||
buf[0] = 0x0A;
|
||||
EPD_command(IL0371_VCM_DC_SETTING, buf, 1);
|
||||
delay(20);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -177,139 +184,143 @@ void Adafruit_IL0371::powerUp()
|
|||
@brief show the data stored in the buffer on the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0371::display()
|
||||
{
|
||||
powerUp();
|
||||
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
uint8_t c;
|
||||
|
||||
sram.csLow();
|
||||
//send read command
|
||||
SPItransfer(MCPSRAM_READ);
|
||||
|
||||
//send address
|
||||
SPItransfer(0x00);
|
||||
SPItransfer(0x00);
|
||||
|
||||
//first data byte from SRAM will be transfered in at the same time as the EPD command is transferred out
|
||||
c = EPD_command(EPD_RAM_BW, false);
|
||||
|
||||
dcHigh();
|
||||
|
||||
for(uint16_t i=0; i<bw_bufsize; i++){
|
||||
c = SPItransfer(c);
|
||||
}
|
||||
csHigh();
|
||||
sram.csHigh();
|
||||
|
||||
delay(2);
|
||||
|
||||
sram.csLow();
|
||||
//send write command
|
||||
SPItransfer(MCPSRAM_READ);
|
||||
|
||||
uint8_t b[2];
|
||||
b[0] = (bw_bufsize >> 8);
|
||||
b[1] = (bw_bufsize & 0xFF);
|
||||
//send address
|
||||
SPItransfer(b[0]);
|
||||
SPItransfer(b[1]);
|
||||
|
||||
//first data byte from SRAM will be transfered in at the same time as the EPD command is transferred out
|
||||
c = EPD_command(EPD_RAM_RED, false);
|
||||
|
||||
dcHigh();
|
||||
|
||||
for(uint16_t i=0; i<red_bufsize; i++){
|
||||
c = SPItransfer(c);
|
||||
}
|
||||
csHigh();
|
||||
sram.csHigh();
|
||||
|
||||
#else
|
||||
//write image
|
||||
EPD_command(EPD_RAM_BW, false);
|
||||
dcHigh();
|
||||
void Adafruit_IL0371::display() {
|
||||
powerUp();
|
||||
|
||||
for(uint16_t i=0; i<bw_bufsize; i++){
|
||||
SPItransfer(bw_buf[i]);
|
||||
}
|
||||
csHigh();
|
||||
|
||||
EPD_command(EPD_RAM_RED, false);
|
||||
dcHigh();
|
||||
|
||||
for(uint16_t i=0; i<red_bufsize; i++){
|
||||
SPItransfer(red_buf[i]);
|
||||
}
|
||||
csHigh();
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
uint8_t c;
|
||||
|
||||
sram.csLow();
|
||||
// send read command
|
||||
SPItransfer(MCPSRAM_READ);
|
||||
|
||||
// send address
|
||||
SPItransfer(0x00);
|
||||
SPItransfer(0x00);
|
||||
|
||||
// first data byte from SRAM will be transfered in at the same time as the EPD
|
||||
// command is transferred out
|
||||
c = EPD_command(EPD_RAM_BW, false);
|
||||
|
||||
dcHigh();
|
||||
|
||||
for (uint16_t i = 0; i < bw_bufsize; i++) {
|
||||
c = SPItransfer(c);
|
||||
}
|
||||
csHigh();
|
||||
sram.csHigh();
|
||||
|
||||
delay(2);
|
||||
|
||||
sram.csLow();
|
||||
// send write command
|
||||
SPItransfer(MCPSRAM_READ);
|
||||
|
||||
uint8_t b[2];
|
||||
b[0] = (bw_bufsize >> 8);
|
||||
b[1] = (bw_bufsize & 0xFF);
|
||||
// send address
|
||||
SPItransfer(b[0]);
|
||||
SPItransfer(b[1]);
|
||||
|
||||
// first data byte from SRAM will be transfered in at the same time as the EPD
|
||||
// command is transferred out
|
||||
c = EPD_command(EPD_RAM_RED, false);
|
||||
|
||||
dcHigh();
|
||||
|
||||
for (uint16_t i = 0; i < red_bufsize; i++) {
|
||||
c = SPItransfer(c);
|
||||
}
|
||||
csHigh();
|
||||
sram.csHigh();
|
||||
|
||||
#else
|
||||
// write image
|
||||
EPD_command(EPD_RAM_BW, false);
|
||||
dcHigh();
|
||||
|
||||
for (uint16_t i = 0; i < bw_bufsize; i++) {
|
||||
SPItransfer(bw_buf[i]);
|
||||
}
|
||||
csHigh();
|
||||
|
||||
EPD_command(EPD_RAM_RED, false);
|
||||
dcHigh();
|
||||
|
||||
for (uint16_t i = 0; i < red_bufsize; i++) {
|
||||
SPItransfer(red_buf[i]);
|
||||
}
|
||||
csHigh();
|
||||
|
||||
#endif
|
||||
update();
|
||||
update();
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief draw a single pixel on the screen
|
||||
@param x the x axis position
|
||||
@param y the y axis position
|
||||
@param color the color of the pixel
|
||||
@param x the x axis position
|
||||
@param y the y axis position
|
||||
@param color the color of the pixel
|
||||
*/
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0371::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||
if ((x < 0) || (x >= width()) || (y < 0) || (y >= height()))
|
||||
return;
|
||||
|
||||
uint8_t *pBuf;
|
||||
if ((x < 0) || (x >= width()) || (y < 0) || (y >= height()))
|
||||
return;
|
||||
|
||||
// check rotation, move pixel around if necessary
|
||||
switch (getRotation()) {
|
||||
case 1:
|
||||
EPD_swap(x, y);
|
||||
x = WIDTH - x - 1;
|
||||
break;
|
||||
case 2:
|
||||
x = WIDTH - x - 1;
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
case 3:
|
||||
EPD_swap(x, y);
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
}
|
||||
//make our buffer happy
|
||||
x = (x == 0 ? 1 : x);
|
||||
uint8_t *pBuf;
|
||||
|
||||
uint16_t addr = ( (width() - x) * height() + y)/8;
|
||||
// check rotation, move pixel around if necessary
|
||||
switch (getRotation()) {
|
||||
case 1:
|
||||
EPD_swap(x, y);
|
||||
x = WIDTH - x - 1;
|
||||
break;
|
||||
case 2:
|
||||
x = WIDTH - x - 1;
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
case 3:
|
||||
EPD_swap(x, y);
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
}
|
||||
// make our buffer happy
|
||||
x = (x == 0 ? 1 : x);
|
||||
|
||||
uint16_t addr = ((width() - x) * height() + y) / 8;
|
||||
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
if(color == EPD_RED){
|
||||
//red is written after bw
|
||||
addr = addr + bw_bufsize;
|
||||
}
|
||||
uint8_t c = sram.read8(addr);
|
||||
pBuf = &c;
|
||||
if (color == EPD_RED) {
|
||||
// red is written after bw
|
||||
addr = addr + bw_bufsize;
|
||||
}
|
||||
uint8_t c = sram.read8(addr);
|
||||
pBuf = &c;
|
||||
#else
|
||||
if(color == EPD_RED){
|
||||
pBuf = red_buf + addr;
|
||||
}
|
||||
else{
|
||||
pBuf = bw_buf + addr;
|
||||
}
|
||||
if (color == EPD_RED) {
|
||||
pBuf = red_buf + addr;
|
||||
} else {
|
||||
pBuf = bw_buf + addr;
|
||||
}
|
||||
#endif
|
||||
// x is which column
|
||||
switch (color)
|
||||
{
|
||||
case EPD_WHITE: *pBuf |= (1 << (7 - y%8)); break;
|
||||
case EPD_RED:
|
||||
case EPD_BLACK: *pBuf &= ~(1 << (7 - y%8)); break;
|
||||
case EPD_INVERSE: *pBuf ^= (1 << (7 - y%8)); break;
|
||||
}
|
||||
// x is which column
|
||||
switch (color) {
|
||||
case EPD_WHITE:
|
||||
*pBuf |= (1 << (7 - y % 8));
|
||||
break;
|
||||
case EPD_RED:
|
||||
case EPD_BLACK:
|
||||
*pBuf &= ~(1 << (7 - y % 8));
|
||||
break;
|
||||
case EPD_INVERSE:
|
||||
*pBuf ^= (1 << (7 - y % 8));
|
||||
break;
|
||||
}
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
sram.write8(addr, *pBuf);
|
||||
sram.write8(addr, *pBuf);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -317,13 +328,12 @@ void Adafruit_IL0371::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
|||
@brief clear all data buffers
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0371::clearBuffer()
|
||||
{
|
||||
void Adafruit_IL0371::clearBuffer() {
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
sram.erase(0x00, bw_bufsize + red_bufsize, 0xFF);
|
||||
sram.erase(0x00, bw_bufsize + red_bufsize, 0xFF);
|
||||
#else
|
||||
memset(bw_buf, 0xFF, bw_bufsize);
|
||||
memset(red_buf, 0xFF, red_bufsize);
|
||||
memset(bw_buf, 0xFF, bw_bufsize);
|
||||
memset(red_buf, 0xFF, red_bufsize);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -333,8 +343,8 @@ void Adafruit_IL0371::clearBuffer()
|
|||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0371::clearDisplay() {
|
||||
clearBuffer();
|
||||
display();
|
||||
delay(100);
|
||||
display();
|
||||
clearBuffer();
|
||||
display();
|
||||
delay(100);
|
||||
display();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,25 +37,30 @@
|
|||
*/
|
||||
/**************************************************************************/
|
||||
class Adafruit_IL0371 : public Adafruit_EPD {
|
||||
public:
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
Adafruit_IL0371(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY = -1);
|
||||
Adafruit_IL0371(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY = -1);
|
||||
#else
|
||||
Adafruit_IL0371(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t BUSY = -1);
|
||||
Adafruit_IL0371(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t BUSY = -1);
|
||||
#endif
|
||||
public:
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
Adafruit_IL0371(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
|
||||
int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY = -1);
|
||||
Adafruit_IL0371(int width, int height, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t SRCS, int8_t BUSY = -1);
|
||||
#else
|
||||
Adafruit_IL0371(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
|
||||
int8_t RST, int8_t CS, int8_t BUSY = -1);
|
||||
Adafruit_IL0371(int width, int height, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t BUSY = -1);
|
||||
#endif
|
||||
|
||||
void begin(bool reset=true);
|
||||
void powerUp();
|
||||
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
|
||||
void display();
|
||||
void update();
|
||||
|
||||
void clearBuffer();
|
||||
void clearDisplay();
|
||||
void begin(bool reset = true);
|
||||
void powerUp();
|
||||
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
|
||||
void display();
|
||||
void update();
|
||||
|
||||
void clearBuffer();
|
||||
void clearDisplay();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -3,14 +3,22 @@
|
|||
|
||||
#define BUSY_WAIT 500
|
||||
|
||||
const uint8_t lut_vcom0[] ={ 0x0E ,0x14 ,0x01 ,0x0A ,0x06 ,0x04 ,0x0A ,0x0A ,0x0F ,0x03 ,0x03 ,0x0C ,0x06 ,0x0A ,0x00 };
|
||||
const uint8_t lut_w[] ={ 0x0E ,0x14 ,0x01 ,0x0A ,0x46 ,0x04 ,0x8A ,0x4A ,0x0F ,0x83 ,0x43 ,0x0C ,0x86 ,0x0A ,0x04 };
|
||||
const uint8_t lut_b[] ={ 0x0E ,0x14 ,0x01 ,0x8A ,0x06 ,0x04 ,0x8A ,0x4A ,0x0F ,0x83 ,0x43 ,0x0C ,0x06 ,0x4A ,0x04 };
|
||||
const uint8_t lut_g1[] ={ 0x8E ,0x94 ,0x01 ,0x8A ,0x06 ,0x04 ,0x8A ,0x4A ,0x0F ,0x83 ,0x43 ,0x0C ,0x06 ,0x0A ,0x04 };
|
||||
const uint8_t lut_g2[] ={ 0x8E ,0x94 ,0x01 ,0x8A ,0x06 ,0x04 ,0x8A ,0x4A ,0x0F ,0x83 ,0x43 ,0x0C ,0x06 ,0x0A ,0x04 };
|
||||
const uint8_t lut_vcom1[] ={ 0x03 ,0x1D ,0x01 ,0x01 ,0x08 ,0x23 ,0x37 ,0x37 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 };
|
||||
const uint8_t lut_red0[] ={ 0x83 ,0x5D ,0x01 ,0x81 ,0x48 ,0x23 ,0x77 ,0x77 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 };
|
||||
const uint8_t lut_red1[] ={ 0x03 ,0x1D ,0x01 ,0x01 ,0x08 ,0x23 ,0x37 ,0x37 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 };
|
||||
const uint8_t lut_vcom0[] = {0x0E, 0x14, 0x01, 0x0A, 0x06, 0x04, 0x0A, 0x0A,
|
||||
0x0F, 0x03, 0x03, 0x0C, 0x06, 0x0A, 0x00};
|
||||
const uint8_t lut_w[] = {0x0E, 0x14, 0x01, 0x0A, 0x46, 0x04, 0x8A, 0x4A,
|
||||
0x0F, 0x83, 0x43, 0x0C, 0x86, 0x0A, 0x04};
|
||||
const uint8_t lut_b[] = {0x0E, 0x14, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A,
|
||||
0x0F, 0x83, 0x43, 0x0C, 0x06, 0x4A, 0x04};
|
||||
const uint8_t lut_g1[] = {0x8E, 0x94, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A,
|
||||
0x0F, 0x83, 0x43, 0x0C, 0x06, 0x0A, 0x04};
|
||||
const uint8_t lut_g2[] = {0x8E, 0x94, 0x01, 0x8A, 0x06, 0x04, 0x8A, 0x4A,
|
||||
0x0F, 0x83, 0x43, 0x0C, 0x06, 0x0A, 0x04};
|
||||
const uint8_t lut_vcom1[] = {0x03, 0x1D, 0x01, 0x01, 0x08, 0x23, 0x37, 0x37,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
const uint8_t lut_red0[] = {0x83, 0x5D, 0x01, 0x81, 0x48, 0x23, 0x77, 0x77,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
const uint8_t lut_red1[] = {0x03, 0x1D, 0x01, 0x01, 0x08, 0x23, 0x37, 0x37,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
/**************************************************************************/
|
||||
|
|
@ -28,7 +36,11 @@ const uint8_t lut_red1[] ={ 0x03 ,0x1D ,0x01 ,0x01 ,0x08 ,0x23 ,0x37 ,0x37 ,0x01
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL0376F::Adafruit_IL0376F(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY) : Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY){
|
||||
Adafruit_IL0376F::Adafruit_IL0376F(int width, int height, int8_t SID,
|
||||
int8_t SCLK, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
|
||||
#else
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
|
@ -43,12 +55,15 @@ Adafruit_IL0376F::Adafruit_IL0376F(int width, int height, int8_t SID, int8_t SCL
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL0376F::Adafruit_IL0376F(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t BUSY) : Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, BUSY) {
|
||||
bw_buf = (uint8_t *)malloc(width * height / 4);
|
||||
red_buf = (uint8_t *)malloc(width * height / 8);
|
||||
Adafruit_IL0376F::Adafruit_IL0376F(int width, int height, int8_t SID,
|
||||
int8_t SCLK, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, BUSY) {
|
||||
bw_buf = (uint8_t *)malloc(width * height / 4);
|
||||
red_buf = (uint8_t *)malloc(width * height / 8);
|
||||
#endif
|
||||
bw_bufsize = width * height / 4;
|
||||
red_bufsize = width * height / 8;
|
||||
bw_bufsize = width * height / 4;
|
||||
red_bufsize = width * height / 8;
|
||||
}
|
||||
|
||||
// constructor for hardware SPI - we indicate DataCommand, ChipSelect, Reset
|
||||
|
|
@ -65,7 +80,9 @@ Adafruit_IL0376F::Adafruit_IL0376F(int width, int height, int8_t SID, int8_t SCL
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL0376F::Adafruit_IL0376F(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY) : Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
Adafruit_IL0376F::Adafruit_IL0376F(int width, int height, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
#else
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
|
|
@ -78,12 +95,14 @@ Adafruit_IL0376F::Adafruit_IL0376F(int width, int height, int8_t DC, int8_t RST,
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL0376F::Adafruit_IL0376F(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t BUSY) : Adafruit_EPD(width, height, DC, RST, CS, BUSY) {
|
||||
bw_buf = (uint8_t *)malloc(width * height / 4);
|
||||
red_buf = (uint8_t *)malloc(width * height / 8);
|
||||
Adafruit_IL0376F::Adafruit_IL0376F(int width, int height, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, BUSY) {
|
||||
bw_buf = (uint8_t *)malloc(width * height / 4);
|
||||
red_buf = (uint8_t *)malloc(width * height / 8);
|
||||
#endif
|
||||
bw_bufsize = width * height / 4;
|
||||
red_bufsize = width * height / 8;
|
||||
bw_bufsize = width * height / 4;
|
||||
red_bufsize = width * height / 8;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -91,12 +110,12 @@ Adafruit_IL0376F::Adafruit_IL0376F(int width, int height, int8_t DC, int8_t RST,
|
|||
@brief wait for busy signal to end
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0376F::busy_wait(void)
|
||||
{
|
||||
if(busy > -1)
|
||||
while(digitalRead(busy)); //wait for busy low
|
||||
else
|
||||
delay(BUSY_WAIT);
|
||||
void Adafruit_IL0376F::busy_wait(void) {
|
||||
if (busy > -1)
|
||||
while (digitalRead(busy))
|
||||
; // wait for busy low
|
||||
else
|
||||
delay(BUSY_WAIT);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -105,22 +124,21 @@ void Adafruit_IL0376F::busy_wait(void)
|
|||
@param reset if true the reset pin will be toggled.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0376F::begin(bool reset)
|
||||
{
|
||||
uint8_t buf[5];
|
||||
Adafruit_EPD::begin(reset);
|
||||
busy_wait();
|
||||
|
||||
buf[0] = 0x07;
|
||||
buf[1] = 0x00;
|
||||
buf[2] = 0x0D;
|
||||
buf[3] = 0x00;
|
||||
EPD_command(IL0376F_POWER_SETTING, buf, 4);
|
||||
|
||||
buf[0] = 0x07;
|
||||
buf[1] = 0x07;
|
||||
buf[2] = 0x07;
|
||||
EPD_command(IL0376F_BOOSTER_SOFT_START, buf, 3);
|
||||
void Adafruit_IL0376F::begin(bool reset) {
|
||||
uint8_t buf[5];
|
||||
Adafruit_EPD::begin(reset);
|
||||
busy_wait();
|
||||
|
||||
buf[0] = 0x07;
|
||||
buf[1] = 0x00;
|
||||
buf[2] = 0x0D;
|
||||
buf[3] = 0x00;
|
||||
EPD_command(IL0376F_POWER_SETTING, buf, 4);
|
||||
|
||||
buf[0] = 0x07;
|
||||
buf[1] = 0x07;
|
||||
buf[2] = 0x07;
|
||||
EPD_command(IL0376F_BOOSTER_SOFT_START, buf, 3);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -128,30 +146,29 @@ void Adafruit_IL0376F::begin(bool reset)
|
|||
@brief signal the display to update
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0376F::update()
|
||||
{
|
||||
EPD_command(IL0376F_DISPLAY_REFRESH);
|
||||
|
||||
busy_wait();
|
||||
void Adafruit_IL0376F::update() {
|
||||
EPD_command(IL0376F_DISPLAY_REFRESH);
|
||||
|
||||
delay(10000);
|
||||
|
||||
//power off
|
||||
uint8_t buf[4];
|
||||
|
||||
buf[0] = 0x17;
|
||||
EPD_command(IL0376F_CDI, buf, 1);
|
||||
|
||||
buf[0] = 0x00;
|
||||
EPD_command(IL0376F_VCM_DC_SETTING, buf, 0);
|
||||
|
||||
buf[0] = 0x02;
|
||||
buf[1] = 0x00;
|
||||
buf[2] = 0x00;
|
||||
buf[3] = 0x00;
|
||||
EPD_command(IL0376F_POWER_SETTING);
|
||||
|
||||
EPD_command(IL0376F_POWER_OFF);
|
||||
busy_wait();
|
||||
|
||||
delay(10000);
|
||||
|
||||
// power off
|
||||
uint8_t buf[4];
|
||||
|
||||
buf[0] = 0x17;
|
||||
EPD_command(IL0376F_CDI, buf, 1);
|
||||
|
||||
buf[0] = 0x00;
|
||||
EPD_command(IL0376F_VCM_DC_SETTING, buf, 0);
|
||||
|
||||
buf[0] = 0x02;
|
||||
buf[1] = 0x00;
|
||||
buf[2] = 0x00;
|
||||
buf[3] = 0x00;
|
||||
EPD_command(IL0376F_POWER_SETTING);
|
||||
|
||||
EPD_command(IL0376F_POWER_OFF);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -159,40 +176,39 @@ void Adafruit_IL0376F::update()
|
|||
@brief start up the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0376F::powerUp()
|
||||
{
|
||||
uint8_t buf[5];
|
||||
EPD_command(IL0376F_POWER_ON);
|
||||
busy_wait();
|
||||
delay(200);
|
||||
|
||||
buf[0] = 0xCF;
|
||||
EPD_command(IL0376F_PANEL_SETTING, buf, 1);
|
||||
|
||||
buf[0] = 0x37;
|
||||
EPD_command(IL0376F_CDI, buf, 1);
|
||||
|
||||
buf[0] = 0x39;
|
||||
EPD_command(IL0376F_PLL, buf, 1);
|
||||
void Adafruit_IL0376F::powerUp() {
|
||||
uint8_t buf[5];
|
||||
EPD_command(IL0376F_POWER_ON);
|
||||
busy_wait();
|
||||
delay(200);
|
||||
|
||||
buf[0] = height() & 0xFF;
|
||||
buf[1] = (height() >> 8) & 0xFF;
|
||||
buf[2] = width() & 0xFF;
|
||||
buf[3] = (width() >> 8) & 0xFF;
|
||||
EPD_command(IL0376F_RESOLUTION, buf, 4);
|
||||
|
||||
buf[0] = 0x0E;
|
||||
EPD_command(IL0376F_VCM_DC_SETTING, buf, 1);
|
||||
|
||||
//write LUTs
|
||||
EPD_command(IL0376F_VCOM1_LUT, lut_vcom0, 15);
|
||||
EPD_command(IL0376F_WHITE_LUT, lut_w, 15);
|
||||
EPD_command(IL0376F_BLACK_LUT, lut_b, 15);
|
||||
EPD_command(IL0376F_GRAY1_LUT, lut_g1, 15);
|
||||
EPD_command(IL0376F_GRAY2_LUT, lut_g2, 15);
|
||||
EPD_command(IL0376F_VCOM2_LUT, lut_vcom1, 15);
|
||||
EPD_command(IL0376F_RED0_LUT, lut_red0, 15);
|
||||
EPD_command(IL0376F_RED1_LUT, lut_red1, 15);
|
||||
buf[0] = 0xCF;
|
||||
EPD_command(IL0376F_PANEL_SETTING, buf, 1);
|
||||
|
||||
buf[0] = 0x37;
|
||||
EPD_command(IL0376F_CDI, buf, 1);
|
||||
|
||||
buf[0] = 0x39;
|
||||
EPD_command(IL0376F_PLL, buf, 1);
|
||||
|
||||
buf[0] = height() & 0xFF;
|
||||
buf[1] = (height() >> 8) & 0xFF;
|
||||
buf[2] = width() & 0xFF;
|
||||
buf[3] = (width() >> 8) & 0xFF;
|
||||
EPD_command(IL0376F_RESOLUTION, buf, 4);
|
||||
|
||||
buf[0] = 0x0E;
|
||||
EPD_command(IL0376F_VCM_DC_SETTING, buf, 1);
|
||||
|
||||
// write LUTs
|
||||
EPD_command(IL0376F_VCOM1_LUT, lut_vcom0, 15);
|
||||
EPD_command(IL0376F_WHITE_LUT, lut_w, 15);
|
||||
EPD_command(IL0376F_BLACK_LUT, lut_b, 15);
|
||||
EPD_command(IL0376F_GRAY1_LUT, lut_g1, 15);
|
||||
EPD_command(IL0376F_GRAY2_LUT, lut_g2, 15);
|
||||
EPD_command(IL0376F_VCOM2_LUT, lut_vcom1, 15);
|
||||
EPD_command(IL0376F_RED0_LUT, lut_red0, 15);
|
||||
EPD_command(IL0376F_RED1_LUT, lut_red1, 15);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -200,154 +216,157 @@ void Adafruit_IL0376F::powerUp()
|
|||
@brief show the data stored in the buffer on the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0376F::display()
|
||||
{
|
||||
powerUp();
|
||||
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
uint8_t c;
|
||||
|
||||
sram.csLow();
|
||||
//send read command
|
||||
SPItransfer(MCPSRAM_READ);
|
||||
|
||||
//send address
|
||||
SPItransfer(0x00);
|
||||
SPItransfer(0x00);
|
||||
|
||||
//first data byte from SRAM will be transfered in at the same time as the EPD command is transferred out
|
||||
c = EPD_command(EPD_RAM_BW, false);
|
||||
|
||||
dcHigh();
|
||||
|
||||
for(uint16_t i=0; i<bw_bufsize; i++){
|
||||
c = SPItransfer(c);
|
||||
}
|
||||
csHigh();
|
||||
sram.csHigh();
|
||||
|
||||
delay(2);
|
||||
|
||||
sram.csLow();
|
||||
//send write command
|
||||
SPItransfer(MCPSRAM_READ);
|
||||
|
||||
uint8_t b[2];
|
||||
b[0] = (bw_bufsize >> 8);
|
||||
b[1] = (bw_bufsize & 0xFF);
|
||||
//send address
|
||||
SPItransfer(b[0]);
|
||||
SPItransfer(b[1]);
|
||||
|
||||
//first data byte from SRAM will be transfered in at the same time as the EPD command is transferred out
|
||||
c = EPD_command(EPD_RAM_RED, false);
|
||||
|
||||
dcHigh();
|
||||
|
||||
for(uint16_t i=0; i<red_bufsize; i++){
|
||||
c = SPItransfer(c);
|
||||
}
|
||||
csHigh();
|
||||
sram.csHigh();
|
||||
|
||||
#else
|
||||
//write image
|
||||
EPD_command(EPD_RAM_BW, false);
|
||||
dcHigh();
|
||||
void Adafruit_IL0376F::display() {
|
||||
powerUp();
|
||||
|
||||
for(uint16_t i=0; i<bw_bufsize; i++){
|
||||
SPItransfer(bw_buf[i]);
|
||||
}
|
||||
csHigh();
|
||||
|
||||
EPD_command(EPD_RAM_RED, false);
|
||||
dcHigh();
|
||||
|
||||
for(uint16_t i=0; i<red_bufsize; i++){
|
||||
SPItransfer(red_buf[i]);
|
||||
}
|
||||
csHigh();
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
uint8_t c;
|
||||
|
||||
sram.csLow();
|
||||
// send read command
|
||||
SPItransfer(MCPSRAM_READ);
|
||||
|
||||
// send address
|
||||
SPItransfer(0x00);
|
||||
SPItransfer(0x00);
|
||||
|
||||
// first data byte from SRAM will be transfered in at the same time as the EPD
|
||||
// command is transferred out
|
||||
c = EPD_command(EPD_RAM_BW, false);
|
||||
|
||||
dcHigh();
|
||||
|
||||
for (uint16_t i = 0; i < bw_bufsize; i++) {
|
||||
c = SPItransfer(c);
|
||||
}
|
||||
csHigh();
|
||||
sram.csHigh();
|
||||
|
||||
delay(2);
|
||||
|
||||
sram.csLow();
|
||||
// send write command
|
||||
SPItransfer(MCPSRAM_READ);
|
||||
|
||||
uint8_t b[2];
|
||||
b[0] = (bw_bufsize >> 8);
|
||||
b[1] = (bw_bufsize & 0xFF);
|
||||
// send address
|
||||
SPItransfer(b[0]);
|
||||
SPItransfer(b[1]);
|
||||
|
||||
// first data byte from SRAM will be transfered in at the same time as the EPD
|
||||
// command is transferred out
|
||||
c = EPD_command(EPD_RAM_RED, false);
|
||||
|
||||
dcHigh();
|
||||
|
||||
for (uint16_t i = 0; i < red_bufsize; i++) {
|
||||
c = SPItransfer(c);
|
||||
}
|
||||
csHigh();
|
||||
sram.csHigh();
|
||||
|
||||
#else
|
||||
// write image
|
||||
EPD_command(EPD_RAM_BW, false);
|
||||
dcHigh();
|
||||
|
||||
for (uint16_t i = 0; i < bw_bufsize; i++) {
|
||||
SPItransfer(bw_buf[i]);
|
||||
}
|
||||
csHigh();
|
||||
|
||||
EPD_command(EPD_RAM_RED, false);
|
||||
dcHigh();
|
||||
|
||||
for (uint16_t i = 0; i < red_bufsize; i++) {
|
||||
SPItransfer(red_buf[i]);
|
||||
}
|
||||
csHigh();
|
||||
|
||||
#endif
|
||||
update();
|
||||
update();
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief draw a single pixel on the screen
|
||||
@param x the x axis position
|
||||
@param y the y axis position
|
||||
@param color the color of the pixel
|
||||
@param x the x axis position
|
||||
@param y the y axis position
|
||||
@param color the color of the pixel
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0376F::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||
if ((x < 0) || (x >= width()) || (y < 0) || (y >= height()))
|
||||
return;
|
||||
|
||||
uint8_t *pBuf;
|
||||
if ((x < 0) || (x >= width()) || (y < 0) || (y >= height()))
|
||||
return;
|
||||
|
||||
// check rotation, move pixel around if necessary
|
||||
switch (getRotation()) {
|
||||
case 1:
|
||||
EPD_swap(x, y);
|
||||
x = WIDTH - x - 1;
|
||||
break;
|
||||
case 2:
|
||||
x = WIDTH - x - 1;
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
case 3:
|
||||
EPD_swap(x, y);
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
//make our buffer happy
|
||||
x = (x == 0 ? 1 : x);
|
||||
uint16_t addr;
|
||||
uint8_t *pBuf;
|
||||
|
||||
if(color == EPD_RED){
|
||||
addr = ( (width() - x) * height() + y)/8;
|
||||
}
|
||||
else{
|
||||
addr = ( (width() - x) * height() + y)/4;
|
||||
}
|
||||
// check rotation, move pixel around if necessary
|
||||
switch (getRotation()) {
|
||||
case 1:
|
||||
EPD_swap(x, y);
|
||||
x = WIDTH - x - 1;
|
||||
break;
|
||||
case 2:
|
||||
x = WIDTH - x - 1;
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
case 3:
|
||||
EPD_swap(x, y);
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// make our buffer happy
|
||||
x = (x == 0 ? 1 : x);
|
||||
uint16_t addr;
|
||||
|
||||
if (color == EPD_RED) {
|
||||
addr = ((width() - x) * height() + y) / 8;
|
||||
} else {
|
||||
addr = ((width() - x) * height() + y) / 4;
|
||||
}
|
||||
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
if(color == EPD_RED){
|
||||
//red is written after bw
|
||||
addr = addr + bw_bufsize;
|
||||
}
|
||||
uint8_t c = sram.read8(addr);
|
||||
pBuf = &c;
|
||||
if (color == EPD_RED) {
|
||||
// red is written after bw
|
||||
addr = addr + bw_bufsize;
|
||||
}
|
||||
uint8_t c = sram.read8(addr);
|
||||
pBuf = &c;
|
||||
#else
|
||||
if(color == EPD_RED){
|
||||
pBuf = red_buf + addr;
|
||||
}
|
||||
else{
|
||||
pBuf = bw_buf + addr;
|
||||
}
|
||||
if (color == EPD_RED) {
|
||||
pBuf = red_buf + addr;
|
||||
} else {
|
||||
pBuf = bw_buf + addr;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(color == EPD_RED){
|
||||
*pBuf &= ~(1 << (7 - (y%8)));
|
||||
}
|
||||
else{
|
||||
uint8_t bits = (6 - y%4 * 2);
|
||||
*pBuf &= ~(0x3 << bits);
|
||||
switch (color)
|
||||
{
|
||||
case EPD_BLACK: break;
|
||||
case EPD_DARK: *pBuf |= (0x1 << bits); break;
|
||||
case EPD_LIGHT: *pBuf |= (0x2 << bits); break;
|
||||
case EPD_WHITE: *pBuf |= (0x3 << bits); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (color == EPD_RED) {
|
||||
*pBuf &= ~(1 << (7 - (y % 8)));
|
||||
} else {
|
||||
uint8_t bits = (6 - y % 4 * 2);
|
||||
*pBuf &= ~(0x3 << bits);
|
||||
switch (color) {
|
||||
case EPD_BLACK:
|
||||
break;
|
||||
case EPD_DARK:
|
||||
*pBuf |= (0x1 << bits);
|
||||
break;
|
||||
case EPD_LIGHT:
|
||||
*pBuf |= (0x2 << bits);
|
||||
break;
|
||||
case EPD_WHITE:
|
||||
*pBuf |= (0x3 << bits);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
sram.write8(addr, *pBuf);
|
||||
sram.write8(addr, *pBuf);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -355,14 +374,13 @@ void Adafruit_IL0376F::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
|||
@brief clear all data buffers
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0376F::clearBuffer()
|
||||
{
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
sram.erase(0x00, bw_bufsize + red_bufsize, 0xFF);
|
||||
#else
|
||||
memset(bw_buf, 0xFF, bw_bufsize);
|
||||
memset(red_buf, 0xFF, red_bufsize);
|
||||
#endif
|
||||
void Adafruit_IL0376F::clearBuffer() {
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
sram.erase(0x00, bw_bufsize + red_bufsize, 0xFF);
|
||||
#else
|
||||
memset(bw_buf, 0xFF, bw_bufsize);
|
||||
memset(red_buf, 0xFF, red_bufsize);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -371,8 +389,8 @@ void Adafruit_IL0376F::clearBuffer()
|
|||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL0376F::clearDisplay() {
|
||||
clearBuffer();
|
||||
display();
|
||||
delay(100);
|
||||
display();
|
||||
clearBuffer();
|
||||
display();
|
||||
delay(100);
|
||||
display();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
#if defined(IL0376F_200_200)
|
||||
#define EPD_LCDWIDTH 200
|
||||
#define EPD_LCDHEIGHT 200
|
||||
#define EPD_BUFSIZE 10000
|
||||
#define EPD_REDBUFSIZE 5000
|
||||
#define EPD_LCDWIDTH 200
|
||||
#define EPD_LCDHEIGHT 200
|
||||
#define EPD_BUFSIZE 10000
|
||||
#define EPD_REDBUFSIZE 5000
|
||||
#endif
|
||||
|
||||
#define EPD_RAM_BW 0x10
|
||||
#define EPD_RAM_RED 0x13
|
||||
#define EPD_RAM_BW 0x10
|
||||
#define EPD_RAM_RED 0x13
|
||||
|
||||
#define IL0376F_PANEL_SETTING 0x00
|
||||
#define IL0376F_POWER_SETTING 0x01
|
||||
|
|
@ -44,28 +44,33 @@
|
|||
*/
|
||||
/**************************************************************************/
|
||||
class Adafruit_IL0376F : public Adafruit_EPD {
|
||||
public:
|
||||
public:
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
Adafruit_IL0376F(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
|
||||
int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY = -1);
|
||||
Adafruit_IL0376F(int width, int height, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t SRCS, int8_t BUSY = -1);
|
||||
#else
|
||||
Adafruit_IL0376F(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
|
||||
int8_t RST, int8_t CS, int8_t BUSY = -1);
|
||||
Adafruit_IL0376F(int width, int height, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t BUSY = -1);
|
||||
#endif
|
||||
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
Adafruit_IL0376F(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY = -1);
|
||||
Adafruit_IL0376F(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY = -1);
|
||||
#else
|
||||
Adafruit_IL0376F(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t BUSY = -1);
|
||||
Adafruit_IL0376F(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t BUSY = -1);
|
||||
#endif
|
||||
void begin(bool reset = true);
|
||||
void powerUp();
|
||||
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
|
||||
void display();
|
||||
void update();
|
||||
|
||||
void clearBuffer();
|
||||
void clearDisplay();
|
||||
|
||||
void begin(bool reset=true);
|
||||
void powerUp();
|
||||
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
|
||||
void display();
|
||||
void update();
|
||||
|
||||
void clearBuffer();
|
||||
void clearDisplay();
|
||||
protected:
|
||||
void busy_wait();
|
||||
void busy_wait();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,25 +1,21 @@
|
|||
#include "Adafruit_EPD.h"
|
||||
#include "Adafruit_IL3897.h"
|
||||
#include "Adafruit_EPD.h"
|
||||
|
||||
#define BUSY_WAIT 1000
|
||||
|
||||
|
||||
//0x32, // command
|
||||
const unsigned char LUTDefault_full[]={
|
||||
0x22, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x11,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
// 0x32, // command
|
||||
const unsigned char LUTDefault_full[] = {
|
||||
0x22, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x11, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x1E, 0x1E, 0x1E,
|
||||
0x1E, 0x1E, 0x1E, 0x1E, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
const unsigned char LUTDefault_part[]={
|
||||
0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x0F, 0x01, 0x00, 0x00,0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
const unsigned char LUTDefault_part[] = {
|
||||
0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -37,7 +33,10 @@ const unsigned char LUTDefault_part[]={
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL3897::Adafruit_IL3897(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY) : Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY){
|
||||
Adafruit_IL3897::Adafruit_IL3897(int width, int height, int8_t SID, int8_t SCLK,
|
||||
int8_t DC, int8_t RST, int8_t CS, int8_t SRCS,
|
||||
int8_t MISO, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, SRCS, MISO, BUSY) {
|
||||
#else
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -53,10 +52,12 @@ Adafruit_IL3897::Adafruit_IL3897(int width, int height, int8_t SID, int8_t SCLK,
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL3897::Adafruit_IL3897(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t BUSY) : Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, BUSY) {
|
||||
bw_buf = (uint8_t *)malloc(width * height / 8);
|
||||
Adafruit_IL3897::Adafruit_IL3897(int width, int height, int8_t SID, int8_t SCLK,
|
||||
int8_t DC, int8_t RST, int8_t CS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, SID, SCLK, DC, RST, CS, BUSY) {
|
||||
bw_buf = (uint8_t *)malloc(width * height / 8);
|
||||
#endif
|
||||
bw_bufsize = width * height / 8;
|
||||
bw_bufsize = width * height / 8;
|
||||
}
|
||||
|
||||
// constructor for hardware SPI - we indicate DataCommand, ChipSelect, Reset
|
||||
|
|
@ -74,7 +75,9 @@ Adafruit_IL3897::Adafruit_IL3897(int width, int height, int8_t SID, int8_t SCLK,
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL3897::Adafruit_IL3897(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY) : Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
Adafruit_IL3897::Adafruit_IL3897(int width, int height, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t SRCS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY) {
|
||||
#else
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -88,10 +91,12 @@ Adafruit_IL3897::Adafruit_IL3897(int width, int height, int8_t DC, int8_t RST, i
|
|||
@param BUSY the busy pin to use
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_IL3897::Adafruit_IL3897(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t BUSY) : Adafruit_EPD(width, height, DC, RST, CS, BUSY) {
|
||||
bw_buf = (uint8_t *)malloc(width * height / 8);
|
||||
Adafruit_IL3897::Adafruit_IL3897(int width, int height, int8_t DC, int8_t RST,
|
||||
int8_t CS, int8_t BUSY)
|
||||
: Adafruit_EPD(width, height, DC, RST, CS, BUSY) {
|
||||
bw_buf = (uint8_t *)malloc(width * height / 8);
|
||||
#endif
|
||||
bw_bufsize = width * height / 8;
|
||||
bw_bufsize = width * height / 8;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -99,11 +104,10 @@ Adafruit_IL3897::Adafruit_IL3897(int width, int height, int8_t DC, int8_t RST, i
|
|||
@brief wait for busy signal to end
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL3897::busy_wait(void)
|
||||
{
|
||||
void Adafruit_IL3897::busy_wait(void) {
|
||||
if (busy >= 0) {
|
||||
while (!digitalRead(busy)) {
|
||||
delay(1); //wait for busy high
|
||||
delay(1); // wait for busy high
|
||||
}
|
||||
} else {
|
||||
delay(BUSY_WAIT);
|
||||
|
|
@ -116,8 +120,7 @@ void Adafruit_IL3897::busy_wait(void)
|
|||
@param reset if true the reset pin will be toggled.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL3897::begin(bool reset)
|
||||
{
|
||||
void Adafruit_IL3897::begin(bool reset) {
|
||||
uint8_t buf[5];
|
||||
Adafruit_EPD::begin(reset);
|
||||
}
|
||||
|
|
@ -127,8 +130,7 @@ void Adafruit_IL3897::begin(bool reset)
|
|||
@brief signal the display to update
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL3897::update(bool partial)
|
||||
{
|
||||
void Adafruit_IL3897::update(bool partial) {
|
||||
uint8_t buf[1];
|
||||
|
||||
if (partial) {
|
||||
|
|
@ -141,9 +143,8 @@ void Adafruit_IL3897::update(bool partial)
|
|||
EPD_command(0xFF); // ??
|
||||
}
|
||||
|
||||
|
||||
void Adafruit_IL3897::setRAMArea(uint8_t xstart, uint8_t xend,
|
||||
uint16_t ystart, uint16_t yend) {
|
||||
void Adafruit_IL3897::setRAMArea(uint8_t xstart, uint8_t xend, uint16_t ystart,
|
||||
uint16_t yend) {
|
||||
uint8_t buf[4];
|
||||
buf[0] = xstart;
|
||||
buf[1] = xend;
|
||||
|
|
@ -153,24 +154,23 @@ void Adafruit_IL3897::update(bool partial)
|
|||
buf[2] = yend & 0xFF;
|
||||
buf[3] = yend >> 8;
|
||||
EPD_command(IL3897_SET_RAM_Y, buf, 4);
|
||||
}
|
||||
}
|
||||
|
||||
void Adafruit_IL3897::setRAMPointer(uint8_t addrX, uint16_t addrY) {
|
||||
void Adafruit_IL3897::setRAMPointer(uint8_t addrX, uint16_t addrY) {
|
||||
uint8_t buf[2];
|
||||
buf[0] = addrX;
|
||||
EPD_command(IL3897_SET_RAM_XADDR, buf, 1);
|
||||
buf[0] = addrY & 0xFF;
|
||||
buf[1] = addrY >> 8;
|
||||
EPD_command(IL3897_SET_RAM_YADDR, buf, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief start up the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL3897::powerUp()
|
||||
{
|
||||
void Adafruit_IL3897::powerUp() {
|
||||
uint8_t buf[4];
|
||||
|
||||
if (rst >= 0) {
|
||||
|
|
@ -190,13 +190,13 @@ void Adafruit_IL3897::powerUp()
|
|||
|
||||
// Gate control
|
||||
//{0x01,(yDot-1)%256,(yDot-1)/256,0x00}; //for 2.13inch
|
||||
buf[0] = (WIDTH - 1) & 0xFF;
|
||||
buf[0] = (WIDTH - 1) & 0xFF;
|
||||
buf[1] = (WIDTH - 1) >> 8;
|
||||
buf[2] = 0x00;
|
||||
EPD_command(IL3897_DRIVER_OUT_CONTROL, buf, 3);
|
||||
|
||||
//unsigned char softstart[]={0x0c,0xd7,0xd6,0x9d};
|
||||
buf[0] = 0xd7;
|
||||
// unsigned char softstart[]={0x0c,0xd7,0xd6,0x9d};
|
||||
buf[0] = 0xd7;
|
||||
buf[1] = 0xd6;
|
||||
buf[2] = 0x9d;
|
||||
EPD_command(0x0C, buf, 3);
|
||||
|
|
@ -205,7 +205,7 @@ void Adafruit_IL3897::powerUp()
|
|||
buf[0] = 0xa8;
|
||||
EPD_command(IL3897_VCOM_SET, buf, 1);
|
||||
|
||||
//DummyLine[] = {0x3a,0x1a}; // 4 dummy line per gate
|
||||
// DummyLine[] = {0x3a,0x1a}; // 4 dummy line per gate
|
||||
buf[0] = 0x1A;
|
||||
EPD_command(IL3897_DUMMY_LINE, buf, 1);
|
||||
|
||||
|
|
@ -216,12 +216,13 @@ void Adafruit_IL3897::powerUp()
|
|||
// {0x11,0x01}; // Ram data entry mode
|
||||
buf[0] = 0x01;
|
||||
EPD_command(IL3897_DATA_ENTRY_MODE, buf, 1);
|
||||
|
||||
// EPD_W21_SetRamArea(0x00,(xDot-1)/8,(yDot-1)%256,(yDot-1)/256,0x00,0x00); // X-source area,Y-gage area
|
||||
setRAMArea(0, (HEIGHT-1)/8, WIDTH-1, 0);
|
||||
|
||||
// EPD_W21_SetRamArea(0x00,(xDot-1)/8,(yDot-1)%256,(yDot-1)/256,0x00,0x00);
|
||||
// // X-source area,Y-gage area
|
||||
setRAMArea(0, (HEIGHT - 1) / 8, WIDTH - 1, 0);
|
||||
|
||||
// EPD_W21_SetRamPointer(0x00,(yDot-1)%256,(yDot-1)/256); // set ram
|
||||
setRAMPointer(0, WIDTH-1);
|
||||
setRAMPointer(0, WIDTH - 1);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
@ -229,91 +230,92 @@ void Adafruit_IL3897::powerUp()
|
|||
@brief show the data stored in the buffer on the display
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL3897::display()
|
||||
{
|
||||
powerUp();
|
||||
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
uint8_t c;
|
||||
|
||||
sram.csLow();
|
||||
//send read command
|
||||
SPItransfer(MCPSRAM_READ);
|
||||
|
||||
//send address
|
||||
SPItransfer(0x00);
|
||||
SPItransfer(0x00);
|
||||
|
||||
//first data byte from SRAM will be transfered in at the same time as the EPD command is transferred out
|
||||
c = EPD_command(EPD_RAM_BW, false);
|
||||
|
||||
dcHigh();
|
||||
|
||||
for(uint16_t i=0; i<bw_bufsize; i++){
|
||||
c = SPItransfer(c);
|
||||
}
|
||||
csHigh();
|
||||
sram.csHigh();
|
||||
|
||||
delay(2);
|
||||
|
||||
sram.csLow();
|
||||
//send write command
|
||||
SPItransfer(MCPSRAM_READ);
|
||||
|
||||
uint8_t b[2];
|
||||
b[0] = (bw_bufsize >> 8);
|
||||
b[1] = (bw_bufsize & 0xFF);
|
||||
//send address
|
||||
SPItransfer(b[0]);
|
||||
SPItransfer(b[1]);
|
||||
|
||||
//first data byte from SRAM will be transfered in at the same time as the EPD command is transferred out
|
||||
c = EPD_command(EPD_RAM_RED, false);
|
||||
|
||||
dcHigh();
|
||||
|
||||
for(uint16_t i=0; i<red_bufsize; i++){
|
||||
c = SPItransfer(c);
|
||||
}
|
||||
csHigh();
|
||||
sram.csHigh();
|
||||
#else
|
||||
//write image
|
||||
EPD_command(EPD_RAM_BW, false);
|
||||
dcHigh();
|
||||
void Adafruit_IL3897::display() {
|
||||
powerUp();
|
||||
|
||||
for(uint16_t i=0; i<bw_bufsize; i++){
|
||||
SPItransfer(bw_buf[i]);
|
||||
}
|
||||
csHigh();
|
||||
|
||||
EPD_command(EPD_RAM_RED, false);
|
||||
dcHigh();
|
||||
|
||||
for(uint16_t i=0; i<red_bufsize; i++){
|
||||
SPItransfer(red_buf[i]);
|
||||
}
|
||||
csHigh();
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
uint8_t c;
|
||||
|
||||
sram.csLow();
|
||||
// send read command
|
||||
SPItransfer(MCPSRAM_READ);
|
||||
|
||||
// send address
|
||||
SPItransfer(0x00);
|
||||
SPItransfer(0x00);
|
||||
|
||||
// first data byte from SRAM will be transfered in at the same time as the EPD
|
||||
// command is transferred out
|
||||
c = EPD_command(EPD_RAM_BW, false);
|
||||
|
||||
dcHigh();
|
||||
|
||||
for (uint16_t i = 0; i < bw_bufsize; i++) {
|
||||
c = SPItransfer(c);
|
||||
}
|
||||
csHigh();
|
||||
sram.csHigh();
|
||||
|
||||
delay(2);
|
||||
|
||||
sram.csLow();
|
||||
// send write command
|
||||
SPItransfer(MCPSRAM_READ);
|
||||
|
||||
uint8_t b[2];
|
||||
b[0] = (bw_bufsize >> 8);
|
||||
b[1] = (bw_bufsize & 0xFF);
|
||||
// send address
|
||||
SPItransfer(b[0]);
|
||||
SPItransfer(b[1]);
|
||||
|
||||
// first data byte from SRAM will be transfered in at the same time as the EPD
|
||||
// command is transferred out
|
||||
c = EPD_command(EPD_RAM_RED, false);
|
||||
|
||||
dcHigh();
|
||||
|
||||
for (uint16_t i = 0; i < red_bufsize; i++) {
|
||||
c = SPItransfer(c);
|
||||
}
|
||||
csHigh();
|
||||
sram.csHigh();
|
||||
#else
|
||||
// write image
|
||||
EPD_command(EPD_RAM_BW, false);
|
||||
dcHigh();
|
||||
|
||||
for (uint16_t i = 0; i < bw_bufsize; i++) {
|
||||
SPItransfer(bw_buf[i]);
|
||||
}
|
||||
csHigh();
|
||||
|
||||
EPD_command(EPD_RAM_RED, false);
|
||||
dcHigh();
|
||||
|
||||
for (uint16_t i = 0; i < red_bufsize; i++) {
|
||||
SPItransfer(red_buf[i]);
|
||||
}
|
||||
csHigh();
|
||||
|
||||
#endif
|
||||
update();
|
||||
update();
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief draw a single pixel on the screen
|
||||
@param x the x axis position
|
||||
@param y the y axis position
|
||||
@param color the color of the pixel
|
||||
@param x the x axis position
|
||||
@param y the y axis position
|
||||
@param color the color of the pixel
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL3897::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||
if ((x < 0) || (x >= width()) || (y < 0) || (y >= height()))
|
||||
return;
|
||||
|
||||
|
||||
uint8_t *pBuf;
|
||||
|
||||
|
||||
// check rotation, move pixel around if necessary
|
||||
switch (getRotation()) {
|
||||
case 1:
|
||||
|
|
@ -329,11 +331,11 @@ void Adafruit_IL3897::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
|||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
}
|
||||
//make our buffer happy
|
||||
// make our buffer happy
|
||||
x = (x == 0 ? 1 : x);
|
||||
|
||||
uint16_t addr = ( (WIDTH - x) * HEIGHT + y)/8;
|
||||
|
||||
|
||||
uint16_t addr = ((WIDTH - x) * HEIGHT + y) / 8;
|
||||
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
uint8_t c = sram.read8(addr);
|
||||
pBuf = &c;
|
||||
|
|
@ -342,9 +344,15 @@ void Adafruit_IL3897::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
|||
#endif
|
||||
// x is which column
|
||||
switch (color) {
|
||||
case EPD_WHITE: *pBuf |= (1 << (7 - y%8)); break;
|
||||
case EPD_BLACK: *pBuf &= ~(1 << (7 - y%8)); break;
|
||||
case EPD_INVERSE: *pBuf ^= (1 << (7 - y%8)); break;
|
||||
case EPD_WHITE:
|
||||
*pBuf |= (1 << (7 - y % 8));
|
||||
break;
|
||||
case EPD_BLACK:
|
||||
*pBuf &= ~(1 << (7 - y % 8));
|
||||
break;
|
||||
case EPD_INVERSE:
|
||||
*pBuf ^= (1 << (7 - y % 8));
|
||||
break;
|
||||
}
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
sram.write8(addr, *pBuf);
|
||||
|
|
@ -356,8 +364,7 @@ void Adafruit_IL3897::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
|||
@brief clear all data buffers
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_IL3897::clearBuffer()
|
||||
{
|
||||
void Adafruit_IL3897::clearBuffer() {
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
sram.erase(0x00, bw_bufsize, 0xFF);
|
||||
#else
|
||||
|
|
@ -377,8 +384,6 @@ void Adafruit_IL3897::clearDisplay() {
|
|||
display();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Go into deep sleep mode
|
||||
|
|
|
|||
|
|
@ -39,33 +39,37 @@
|
|||
*/
|
||||
/**************************************************************************/
|
||||
class Adafruit_IL3897 : public Adafruit_EPD {
|
||||
public:
|
||||
public:
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
Adafruit_IL3897(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
|
||||
int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO,
|
||||
int8_t BUSY = -1);
|
||||
Adafruit_IL3897(int width, int height, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t SRCS, int8_t BUSY = -1);
|
||||
#else
|
||||
Adafruit_IL3897(int width, int height, int8_t SID, int8_t SCLK, int8_t DC,
|
||||
int8_t RST, int8_t CS, int8_t BUSY = -1);
|
||||
Adafruit_IL3897(int width, int height, int8_t DC, int8_t RST, int8_t CS,
|
||||
int8_t BUSY = -1);
|
||||
#endif
|
||||
|
||||
#ifdef USE_EXTERNAL_SRAM
|
||||
Adafruit_IL3897(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t MISO, int8_t BUSY = -1);
|
||||
Adafruit_IL3897(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t SRCS, int8_t BUSY = -1);
|
||||
#else
|
||||
Adafruit_IL3897(int width, int height, int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS, int8_t BUSY = -1);
|
||||
Adafruit_IL3897(int width, int height, int8_t DC, int8_t RST, int8_t CS, int8_t BUSY = -1);
|
||||
#endif
|
||||
void begin(bool reset = true);
|
||||
void powerUp();
|
||||
|
||||
void begin(bool reset=true);
|
||||
void powerUp();
|
||||
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
void setRAMArea(uint8_t xstart, uint8_t xend,
|
||||
uint16_t ystart, uint16_t yend);
|
||||
void setRAMPointer(uint8_t addrX, uint16_t addrY);
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
void setRAMArea(uint8_t xstart, uint8_t xend, uint16_t ystart, uint16_t yend);
|
||||
void setRAMPointer(uint8_t addrX, uint16_t addrY);
|
||||
|
||||
void display();
|
||||
void update(bool partial=false);
|
||||
void display();
|
||||
void update(bool partial = false);
|
||||
|
||||
void deepSleep(void);
|
||||
|
||||
void clearBuffer();
|
||||
void clearDisplay();
|
||||
|
||||
void deepSleep(void);
|
||||
|
||||
void clearBuffer();
|
||||
void clearDisplay();
|
||||
protected:
|
||||
void busy_wait();
|
||||
void busy_wait();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue