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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 103 additions & 2 deletions Adafruit_SPITFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,81 @@ Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass,
}
#endif // end !ESP8266

#if defined(ARDUINO_ARDUINO_NESSO_N1)
Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass,
int8_t cs, ExpanderPin *dc, ExpanderPin *rst)
: Adafruit_GFX(w, h), connection(TFT_HARD_SPI), _rst(-1), _cs(cs), _dc(-1) {
hwspi._spi = spiClass;
#if !defined(SPI_HAS_TRANSACTION)
hwspi._freq = 0;
hwspi._mode = SPI_MODE0;
#endif
_dcExp = dc;
_rstExp = rst;
}

Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass,
int8_t cs, int8_t dc, ExpanderPin *rst)
: Adafruit_GFX(w, h), connection(TFT_HARD_SPI), _rst(-1), _cs(cs), _dc(dc) {
hwspi._spi = spiClass;
#if !defined(SPI_HAS_TRANSACTION)
hwspi._freq = 0;
hwspi._mode = SPI_MODE0;
#endif
_rstExp = rst;
}

Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass,
ExpanderPin *cs, ExpanderPin *dc,
ExpanderPin *rst)
: Adafruit_GFX(w, h), connection(TFT_HARD_SPI), _rst(-1), _cs(-1), _dc(-1) {
hwspi._spi = spiClass;
#if !defined(SPI_HAS_TRANSACTION)
hwspi._freq = 0;
hwspi._mode = SPI_MODE0;
#endif
_csExp = cs;
_dcExp = dc;
_rstExp = rst;
}

Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t cs,
ExpanderPin *dc, ExpanderPin *rst)
: Adafruit_GFX(w, h), connection(TFT_HARD_SPI), _rst(-1), _cs(cs), _dc(-1) {
hwspi._spi = &SPI;
#if !defined(SPI_HAS_TRANSACTION)
hwspi._freq = 0;
hwspi._mode = SPI_MODE0;
#endif
_dcExp = dc;
_rstExp = rst;
}

Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t cs, int8_t dc,
ExpanderPin *rst)
: Adafruit_GFX(w, h), connection(TFT_HARD_SPI), _rst(-1), _cs(cs), _dc(dc) {
hwspi._spi = &SPI;
#if !defined(SPI_HAS_TRANSACTION)
hwspi._freq = 0;
hwspi._mode = SPI_MODE0;
#endif
_rstExp = rst;
}

Adafruit_SPITFT::Adafruit_SPITFT(uint16_t w, uint16_t h, ExpanderPin *cs,
ExpanderPin *dc, ExpanderPin *rst)
: Adafruit_GFX(w, h), connection(TFT_HARD_SPI), _rst(-1), _cs(-1), _dc(-1) {
hwspi._spi = &SPI;
#if !defined(SPI_HAS_TRANSACTION)
hwspi._freq = 0;
hwspi._mode = SPI_MODE0;
#endif
_csExp = cs;
_dcExp = dc;
_rstExp = rst;
}
#endif

/*!
@brief Adafruit_SPITFT constructor for parallel display connection.
@param w Display width in pixels at default rotation (0).
Expand Down Expand Up @@ -543,8 +618,23 @@ void Adafruit_SPITFT::initSPI(uint32_t freq, uint8_t spiMode) {
pinMode(_cs, OUTPUT);
digitalWrite(_cs, HIGH); // Deselect
}
pinMode(_dc, OUTPUT);
digitalWrite(_dc, HIGH); // Data mode
#if defined(ARDUINO_ARDUINO_NESSO_N1)
if (_csExp) {
pinMode(*_csExp, OUTPUT);
digitalWrite(*_csExp, HIGH);
}
#endif

if (_dc >= 0) {
pinMode(_dc, OUTPUT);
digitalWrite(_dc, HIGH); // Data mode
}
#if defined(ARDUINO_ARDUINO_NESSO_N1)
if (_dcExp) {
pinMode(*_dcExp, OUTPUT);
digitalWrite(*_dcExp, HIGH);
}
#endif

if (connection == TFT_HARD_SPI) {

Expand Down Expand Up @@ -657,6 +747,17 @@ void Adafruit_SPITFT::initSPI(uint32_t freq, uint8_t spiMode) {
digitalWrite(_rst, HIGH);
delay(200);
}
#if defined(ARDUINO_ARDUINO_NESSO_N1)
if (_rstExp) {
pinMode(*_rstExp, OUTPUT);
digitalWrite(*_rstExp, HIGH);
delay(100);
digitalWrite(*_rstExp, LOW);
delay(100);
digitalWrite(*_rstExp, HIGH);
delay(200);
}
#endif

#if defined(USE_SPI_DMA) && (defined(__SAMD51__) || defined(ARDUINO_SAMD_ZERO))
if (((connection == TFT_HARD_SPI) || (connection == TFT_PARALLEL)) &&
Expand Down
50 changes: 50 additions & 0 deletions Adafruit_SPITFT.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include "Adafruit_GFX.h"
#include <SPI.h>

#if defined(ARDUINO_ARDUINO_NESSO_N1)
class ExpanderPin;
#endif

// HARDWARE CONFIG ---------------------------------------------------------

#if defined(__AVR__)
Expand Down Expand Up @@ -157,6 +161,23 @@ class Adafruit_SPITFT : public Adafruit_GFX {
int8_t dc, int8_t rst = -1);
#endif // end !ESP8266

#if defined(ARDUINO_ARDUINO_NESSO_N1)
// Hardware SPI constructor using default or an arbitrary SPI peripheral
// and ExpanderPin for cs, dc, rst
Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass, int8_t cs,
ExpanderPin *dc, ExpanderPin *rst = NULL);
Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass, int8_t cs,
int8_t dc, ExpanderPin *rst = NULL);
Adafruit_SPITFT(uint16_t w, uint16_t h, SPIClass *spiClass,
ExpanderPin *cs, ExpanderPin *dc, ExpanderPin *rst = NULL);
Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t cs, ExpanderPin *dc,
ExpanderPin *rst = NULL);
Adafruit_SPITFT(uint16_t w, uint16_t h, int8_t cs, int8_t dc,
ExpanderPin *rst = NULL);
Adafruit_SPITFT(uint16_t w, uint16_t h, ExpanderPin *cs, ExpanderPin *dc,
ExpanderPin *rst = NULL);
#endif

// Parallel constructor: expects width & height (rotation 0), flag
// indicating whether 16-bit (true) or 8-bit (false) interface, 3 signal
// pins (d0, wr, dc), 3 optional pins (cs, rst, rd). 16-bit parallel
Expand Down Expand Up @@ -300,6 +321,12 @@ class Adafruit_SPITFT : public Adafruit_GFX {
connection is parallel.
*/
void SPI_CS_HIGH(void) {
#if defined(ARDUINO_ARDUINO_NESSO_N1)
if (_csExp) {
digitalWrite(*_csExp, HIGH);
return;
}
#endif
#if defined(USE_FAST_PINIO)
#if defined(HAS_PORT_SET_CLR)
#if defined(KINETISK)
Expand All @@ -322,6 +349,12 @@ class Adafruit_SPITFT : public Adafruit_GFX {
connection is parallel.
*/
void SPI_CS_LOW(void) {
#if defined(ARDUINO_ARDUINO_NESSO_N1)
if (_csExp) {
digitalWrite(*_csExp, LOW);
return;
}
#endif
#if defined(USE_FAST_PINIO)
#if defined(HAS_PORT_SET_CLR)
#if defined(KINETISK)
Expand All @@ -341,6 +374,12 @@ class Adafruit_SPITFT : public Adafruit_GFX {
@brief Set the data/command line HIGH (data mode).
*/
void SPI_DC_HIGH(void) {
#if defined(ARDUINO_ARDUINO_NESSO_N1)
if (_dcExp) {
digitalWrite(*_dcExp, HIGH);
return;
}
#endif
#if defined(USE_FAST_PINIO)
#if defined(HAS_PORT_SET_CLR)
#if defined(KINETISK)
Expand All @@ -360,6 +399,12 @@ class Adafruit_SPITFT : public Adafruit_GFX {
@brief Set the data/command line LOW (command mode).
*/
void SPI_DC_LOW(void) {
#if defined(ARDUINO_ARDUINO_NESSO_N1)
if (_dcExp) {
digitalWrite(*_dcExp, LOW);
return;
}
#endif
#if defined(USE_FAST_PINIO)
#if defined(HAS_PORT_SET_CLR)
#if defined(KINETISK)
Expand Down Expand Up @@ -528,6 +573,11 @@ class Adafruit_SPITFT : public Adafruit_GFX {
int8_t _rst; ///< Reset pin # (or -1)
int8_t _cs; ///< Chip select pin # (or -1)
int8_t _dc; ///< Data/command pin #
#if defined(ARDUINO_ARDUINO_NESSO_N1)
ExpanderPin *_rstExp = NULL;
ExpanderPin *_csExp = NULL;
ExpanderPin *_dcExp = NULL;
#endif

int16_t _xstart = 0; ///< Internal framebuffer X offset
int16_t _ystart = 0; ///< Internal framebuffer Y offset
Expand Down
Loading