mirror of
https://github.com/adafruit/Adafruit-GFX-Library.git
synced 2026-10-26 22:10:52 +00:00
Add support for Arduino Nesso-N1 ExpanderPin args
This commit is contained in:
1 parent
e4df4cc64f
commit
d70f720925
2 files changed
+153
-2
No files matched your search
+103
-2
@@ -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).
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)) &&
|
||||
|
||||
@@ -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__)
|
||||
@@ -157,6 +161,23 @@ public:
|
||||
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
|
||||
@@ -300,6 +321,12 @@ public:
|
||||
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)
|
||||
@@ -322,6 +349,12 @@ public:
|
||||
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)
|
||||
@@ -341,6 +374,12 @@ public:
|
||||
@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)
|
||||
@@ -360,6 +399,12 @@ public:
|
||||
@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)
|
||||
@@ -528,6 +573,11 @@ protected:
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user