Skip to content

Commit

Permalink
Add support for ESP32 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nkawu authored Nov 27, 2017
1 parent e528fd1 commit 5eb3788
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 19 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
TFT_22_ILI9225
==============

**v1.3.4, released 2017-11-27, add support for ESP32**

**v1.3.3, released 2017-11-26, add support for STM32F1** Credit: [nicolasimeoni](https://github.com/nicolasimeoni)

**v1.3.2, released 2017-11-20, add triangle function demo**
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
TFT_22_ILI9225
==============

**v1.3.4, released 2017-11-27, add support for ESP32**

**v1.3.3, released 2017-11-26, add support for STM32F1** Credit: [nicolasimeoni](https://github.com/nicolasimeoni)

This is a library for the ILI9225 based 2.2" 176x220 TFT LCD shields commonly found on eBay, originally forked from the screen_4D_22_library library. The ability to use GLCD fonts has been added and the syntax has been changed to match the Adafruit libraries somewhat.
Expand Down
2 changes: 1 addition & 1 deletion examples/Basic_Demo/Basic_Demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "SPI.h"
#include "TFT_22_ILI9225.h"

#if defined (ARDUINO_ARCH_STM32F1)
#ifdef ARDUINO_ARCH_STM32F1
#define TFT_RST PA1
#define TFT_RS PA2
#define TFT_CS PA0 // SS
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"authors": {
"name": "Nkawu"
},
"version": "1.3.3",
"version": "1.3.4",
"frameworks": "arduino",
"platforms": "*"
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TFT_22_ILI9225
version=1.3.3
version=1.3.4
author=Nkawu
maintainer=Nkawu
sentence=ILI9225 2.2" 176x220 TFT LCD shield
Expand Down
2 changes: 1 addition & 1 deletion src/DefaultFonts.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <pgmspace.h>
#endif

#if defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) || defined(STM32F1)
#if defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_STM32F1) || defined(STM32F1) || defined(ESP32)
#define PROGMEM
#define fontdatatype const char
#else
Expand Down
28 changes: 16 additions & 12 deletions src/TFT_22_ILI9225.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@
#define SSPI_SCK_LOW() digitalWrite(_clk, LOW)
#endif

// #define SSPI_BEGIN_TRANSACTION()
// #define SSPI_END_TRANSACTION()
// #define SSPI_WRITE(v) _spiWrite(v)
// #define SSPI_WRITE16(s) SSPI_WRITE((s) >> 8); SSPI_WRITE(s)
// #define SSPI_WRITE32(l) SSPI_WRITE((l) >> 24); SSPI_WRITE((l) >> 16); SSPI_WRITE((l) >> 8); SSPI_WRITE(l)
// #define SSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<(l); i+=2){ SSPI_WRITE(((uint8_t*)(c))[i+1]); SSPI_WRITE(((uint8_t*)(c))[i]); }
#define SSPI_BEGIN_TRANSACTION()
#define SSPI_END_TRANSACTION()
#define SSPI_WRITE(v) _spiWrite(v)
#define SSPI_WRITE16(s) SSPI_WRITE((s) >> 8); SSPI_WRITE(s)
#define SSPI_WRITE32(l) SSPI_WRITE((l) >> 24); SSPI_WRITE((l) >> 16); SSPI_WRITE((l) >> 8); SSPI_WRITE(l)
#define SSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<(l); i+=2){ SSPI_WRITE(((uint8_t*)(c))[i+1]); SSPI_WRITE(((uint8_t*)(c))[i]); }

// Hardware SPI Macros

Expand Down Expand Up @@ -105,15 +105,15 @@
#endif
#if defined(ESP8266) || defined(ESP32)
// Optimized SPI (ESP8266 and ESP32)
// #define HSPI_READ() SPI_OBJECT.transfer(0)
#define HSPI_READ() SPI_OBJECT.transfer(0)
#define HSPI_WRITE(b) SPI_OBJECT.write(b)
// #define HSPI_WRITE16(s) SPI_OBJECT.write16(s)
// #define HSPI_WRITE32(l) SPI_OBJECT.write32(l)
#define HSPI_WRITE16(s) SPI_OBJECT.write16(s)
#define HSPI_WRITE32(l) SPI_OBJECT.write32(l)
#ifdef SPI_HAS_WRITE_PIXELS
#define SPI_MAX_PIXELS_AT_ONCE 32
// #define HSPI_WRITE_PIXELS(c,l) SPI_OBJECT.writePixels(c,l)
#define HSPI_WRITE_PIXELS(c,l) SPI_OBJECT.writePixels(c,l)
#else
// #define HSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<((l)/2); i++){ SPI_WRITE16(((uint16_t*)(c))[i]); }
#define HSPI_WRITE_PIXELS(c,l) for(uint32_t i=0; i<((l)/2); i++){ SPI_WRITE16(((uint16_t*)(c))[i]); }
#endif
#else
// Standard Byte-by-Byte SPI
Expand Down Expand Up @@ -221,11 +221,13 @@ TFT_22_ILI9225::TFT_22_ILI9225(int8_t rst, int8_t rs, int8_t cs, int8_t led, uin

#ifdef ESP32
void TFT_22_ILI9225::begin(SPIClass &spi)
_spi = spi;
#else
void TFT_22_ILI9225::begin()
#endif
{
#ifdef ESP32
_spi = spi;
#endif
// Set up reset pin
if (_rst > 0) {
pinMode(_rst, OUTPUT);
Expand Down Expand Up @@ -461,7 +463,9 @@ void TFT_22_ILI9225::invert(boolean flag) {

void TFT_22_ILI9225::setBacklight(boolean flag) {
blState = flag;
#ifndef ESP32
if (_led) analogWrite(_led, blState ? _brightness : 0);
#endif
}


Expand Down
6 changes: 3 additions & 3 deletions src/TFT_22_ILI9225.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ class TFT_22_ILI9225 {
TFT_22_ILI9225(int8_t RST, int8_t RS, int8_t CS, int8_t LED, uint8_t brightness);

/// Initialization
#ifdef ESP32
void begin(SPIClass &spi)
#else
#ifndef ESP32
void begin(void);
#else
void begin(SPIClass &spi=SPI);
#endif

/// Clear the screen
Expand Down

0 comments on commit 5eb3788

Please sign in to comment.