Skip to content

Commit

Permalink
make compatible with ILI lib, plus minor fixeups.
Browse files Browse the repository at this point in the history
- fix library.properties
- minor cleanup on scrollTo (ported back from ILI lib)
- ported drawBitmap back from ILI lib.
- Added ILI defines in .h so that WROVER can be dropped in place
  for code that used to use the ILI library.
- Added min/max to override the bad versions that come from arduino libs
  (even the examples/graphicstest will not compile without those).
  • Loading branch information
marcmerlin committed Apr 13, 2017
1 parent 6ccc98b commit 4c72788
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
6 changes: 3 additions & 3 deletions library.properties
@@ -1,9 +1,9 @@
name=Adafruit ILI9341
name=WROVER KIT LCD
version=1.0.3
author=Adafruit
maintainer=Adafruit <info@adafruit.com>
sentence=Library for Adafruit ILI9341 displays
paragraph=Library for Adafruit ILI9341 displays
sentence=Library for WROVER displays
paragraph=Library for WROVER displays
category=Display
url=https://github.com/adafruit/WROVER_KIT_LCD
architectures=*
11 changes: 10 additions & 1 deletion src/WROVER_KIT_LCD.cpp
Expand Up @@ -229,7 +229,7 @@ void WROVER_KIT_LCD::invertDisplay(boolean i) {

void WROVER_KIT_LCD::scrollTo(uint16_t y) {
startWrite();
writeCommand(0x37);
writeCommand(WROVER_VSCRSADD);
SPI.write16(y);
endWrite();
}
Expand Down Expand Up @@ -368,6 +368,15 @@ void WROVER_KIT_LCD::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
endWrite();
}

// This code was ported/adapted from https://github.com/PaulStoffregen/ILI9341_t3
// by Marc MERLIN. See examples/pictureEmbed to use this.
void WROVER_KIT_LCD::drawBitmap(int16_t x, int16_t y, int16_t w, int16_t h, const uint16_t *pcolors) {
startWrite();
setAddrWindow(x, y, w, h);
writePixels((uint16_t*) pcolors, w*h);
endWrite();
}


/*
* Bitmaps and JPEGs
Expand Down
36 changes: 36 additions & 0 deletions src/WROVER_KIT_LCD.h
Expand Up @@ -98,6 +98,41 @@
#define WROVER_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
#define WROVER_PINK 0xF81F


// Compatibility with ILI code.
#define ILI9341_WIDTH WROVER_WIDTH
#define ILI9341_HEIGHT WROVER_HEIGHT

#define ILI9341_RDMODE WROVER_RDDPM
#define ILI9341_RDMADCTL WROVER_RDDMADCTL
#define ILI9341_RDPIXFMT WROVER_RDDCOLMOD
#define ILI9341_RDIMGFMT WROVER_RDDIM
#define ILI9341_RDSELFDIAG WROVER_RDDSDR

#define ILI9341_BLACK WROVER_BLACK
#define ILI9341_NAVY WROVER_NAVY
#define ILI9341_DARKGREEN WROVER_DARKGREEN
#define ILI9341_DARKCYAN WROVER_DARKCYAN
#define ILI9341_MAROON WROVER_MAROON
#define ILI9341_PURPLE WROVER_PURPLE
#define ILI9341_OLIVE WROVER_OLIVE
#define ILI9341_LIGHTGREY WROVER_LIGHTGREY
#define ILI9341_DARKGREY WROVER_DARKGREY
#define ILI9341_BLUE WROVER_BLUE
#define ILI9341_GREEN WROVER_GREEN
#define ILI9341_CYAN WROVER_CYAN
#define ILI9341_RED WROVER_RED
#define ILI9341_MAGENTA WROVER_MAGENTA
#define ILI9341_YELLOW WROVER_YELLOW
#define ILI9341_WHITE WROVER_WHITE
#define ILI9341_ORANGE WROVER_ORANGE
#define ILI9341_GREENYELLOW WROVER_GREENYELLOW
#define ILI9341_PINK WROVER_PINK

// These get redefined to an incompatible 3 arg version in arduino libs.
#define min(X, Y) (((X) < (Y)) ? (X) : (Y))
#define max(X, Y) (((X) > (Y)) ? (X) : (Y))

typedef enum {
JPEG_DIV_NONE,
JPEG_DIV_2,
Expand Down Expand Up @@ -141,6 +176,7 @@ class WROVER_KIT_LCD : public Adafruit_GFX {
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
void drawBitmap(int16_t x, int16_t y, int16_t w, int16_t h, const uint16_t *pcolors);

uint8_t readcommand8(uint8_t reg, uint8_t index = 0);
uint32_t readId();
Expand Down

0 comments on commit 4c72788

Please sign in to comment.