adafruit / Adafruit_HX8357_Library

Arduino library for HX8357
43 stars 37 forks source link

Compiler errors with the latest HX8357 library (1.0.7) #11

Closed mickpf closed 6 years ago

mickpf commented 6 years ago

I wrote a small sketch to test a display (Adafruit Product ID 2050) with an ESP32 Feather:

#include <Wire.h>
#include <SPI.h>

#include <Adafruit_GFX.h>
#include <Adafruit_HX8357.h>

#define SERIAL_BAUDRATE                     115200

#define PIN_SPI_MISO                        GPIO_NUM_12
#define PIN_SPI_MOSI                        GPIO_NUM_13
#define PIN_SPI_SCK                         GPIO_NUM_14

#define PIN_LCD_CS                          GPIO_NUM_15
#define PIN_LCD_DC                          GPIO_NUM_21
#define PIN_LCD_RESET                       GPIO_NUM_17
#define PIN_LCD_BACKLIGHT                   GPIO_NUM_16

#define LCD_BRIGHTNESS_MIN                  0
#define LCD_BRIGHTNESS_MAX                  255
#define LCD_BRIGHTNESS_START                200

#define LCD_COLOR_BACKGROUND                0x28E2    
#define LCD_COLOR_FOREGROUND                0xFD29

Adafruit_HX8357 tft = Adafruit_HX8357(PIN_LCD_CS, PIN_LCD_DC, PIN_SPI_MOSI, PIN_SPI_SCK, PIN_LCD_RESET, PIN_SPI_MISO);

void loop(void)
{
}

void setup(void)
{
    Serial.begin(SERIAL_BAUDRATE);
    Wire.begin();
    SPI.begin(PIN_SPI_SCK, PIN_SPI_MISO, PIN_SPI_MOSI, PIN_LCD_CS);
    delay(1000);
    pinMode(PIN_LCD_CS, OUTPUT);
    pinMode(PIN_LCD_DC, OUTPUT);
    pinMode(PIN_LCD_RESET, OUTPUT);
    pinMode(PIN_LCD_BACKLIGHT, OUTPUT);
    analogWrite(PIN_LCD_BACKLIGHT, LCD_BRIGHTNESS_START);
    tft.begin(HX8357D);
    tft.setRotation(0);
    tft.fillScreen(LCD_COLOR_BACKGROUND);
    tft.fillRect(20, 10, 200, 100, LCD_COLOR_FOREGROUND);
}

Compiling this sketch outputs following errors:

Arduino: 1.8.5 (Linux), TD: 1.41, Board: "Adafruit ESP32 Feather, 80MHz, 921600, None"

/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp: In member function 'void Adafruit_HX8357::begin(uint8_t)':
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:112:25: error: '_spi' was not declared in this scope
     #define SPI_OBJECT  _spi        ///< Default SPI hardware peripheral
                         ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:192:47: note: in expansion of macro 'SPI_OBJECT'
 #define SPI_BEGIN()             if(_sclk < 0){SPI_OBJECT.begin();}          ///< SPI initialize
                                               ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:312:3: note: in expansion of macro 'SPI_BEGIN'
   SPI_BEGIN();
   ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp: In member function 'void Adafruit_HX8357::setAddrWindow(uint16_t, uint16_t, uint16_t, uint16_t)':
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:112:25: error: '_spi' was not declared in this scope
     #define SPI_OBJECT  _spi        ///< Default SPI hardware peripheral
                         ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:145:38: note: in expansion of macro 'SPI_OBJECT'
     #define HSPI_WRITE32(l)          SPI_OBJECT.write32(l)     ///< Hardware SPI write 32 bits
                                      ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:196:47: note: in expansion of macro 'HSPI_WRITE32'
 #define SPI_WRITE32(l)          if(_sclk < 0){HSPI_WRITE32(l);}else{SSPI_WRITE32(l);}  ///< SPI write 32 bits
                                               ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:594:3: note: in expansion of macro 'SPI_WRITE32'
   SPI_WRITE32(xa);
   ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:112:25: error: '_spi' was not declared in this scope
     #define SPI_OBJECT  _spi        ///< Default SPI hardware peripheral
                         ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:145:38: note: in expansion of macro 'SPI_OBJECT'
     #define HSPI_WRITE32(l)          SPI_OBJECT.write32(l)     ///< Hardware SPI write 32 bits
                                      ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:196:47: note: in expansion of macro 'HSPI_WRITE32'
 #define SPI_WRITE32(l)          if(_sclk < 0){HSPI_WRITE32(l);}else{SSPI_WRITE32(l);}  ///< SPI write 32 bits
                                               ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:597:3: note: in expansion of macro 'SPI_WRITE32'
   SPI_WRITE32(ya);
   ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp: In member function 'void Adafruit_HX8357::pushColor(uint16_t)':
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:112:25: error: '_spi' was not declared in this scope
     #define SPI_OBJECT  _spi        ///< Default SPI hardware peripheral
                         ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:144:38: note: in expansion of macro 'SPI_OBJECT'
     #define HSPI_WRITE16(s)          SPI_OBJECT.write16(s)     ///< Hardware SPI write 16 bits
                                      ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:195:47: note: in expansion of macro 'HSPI_WRITE16'
 #define SPI_WRITE16(s)          if(_sclk < 0){HSPI_WRITE16(s);}else{SSPI_WRITE16(s);}  ///< SPI write 16 bits
                                               ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:610:3: note: in expansion of macro 'SPI_WRITE16'
   SPI_WRITE16(color);
   ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp: In member function 'void Adafruit_HX8357::writePixel(uint16_t)':
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:112:25: error: '_spi' was not declared in this scope
     #define SPI_OBJECT  _spi        ///< Default SPI hardware peripheral
                         ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:144:38: note: in expansion of macro 'SPI_OBJECT'
     #define HSPI_WRITE16(s)          SPI_OBJECT.write16(s)     ///< Hardware SPI write 16 bits
                                      ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:195:47: note: in expansion of macro 'HSPI_WRITE16'
 #define SPI_WRITE16(s)          if(_sclk < 0){HSPI_WRITE16(s);}else{SSPI_WRITE16(s);}  ///< SPI write 16 bits
                                               ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:620:5: note: in expansion of macro 'SPI_WRITE16'
     SPI_WRITE16(color);
     ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp: In member function 'void Adafruit_HX8357::writePixels(uint16_t*, uint32_t)':
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:112:25: error: '_spi' was not declared in this scope
     #define SPI_OBJECT  _spi        ///< Default SPI hardware peripheral
                         ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:148:42: note: in expansion of macro 'SPI_OBJECT'
         #define HSPI_WRITE_PIXELS(c,l)   SPI_OBJECT.writePixels(c,l)
                                          ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:197:47: note: in expansion of macro 'HSPI_WRITE_PIXELS'
 #define SPI_WRITE_PIXELS(c,l)   if(_sclk < 0){HSPI_WRITE_PIXELS(c,l);}else{SSPI_WRITE_PIXELS(c,l);}  ///< SPI write 'l' pixels of 16-bits each
                                               ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:632:5: note: in expansion of macro 'SPI_WRITE_PIXELS'
     SPI_WRITE_PIXELS((uint8_t*)colors , len * 2);
     ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp: In member function 'uint8_t Adafruit_HX8357::spiRead()':
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:112:25: error: '_spi' was not declared in this scope
     #define SPI_OBJECT  _spi        ///< Default SPI hardware peripheral
                         ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:142:38: note: in expansion of macro 'SPI_OBJECT'
     #define HSPI_READ()              SPI_OBJECT.transfer(0)    ///< Hardware SPI read 8 bits
                                      ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:891:16: note: in expansion of macro 'HSPI_READ'
         return HSPI_READ();
                ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp: In member function 'void Adafruit_HX8357::spiWrite(uint8_t)':
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:112:25: error: '_spi' was not declared in this scope
     #define SPI_OBJECT  _spi        ///< Default SPI hardware peripheral
                         ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:143:38: note: in expansion of macro 'SPI_OBJECT'
     #define HSPI_WRITE(b)            SPI_OBJECT.write(b)       ///< Hardware SPI write 8 bits
                                      ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:916:9: note: in expansion of macro 'HSPI_WRITE'
         HSPI_WRITE(b);
         ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp: In member function 'virtual void Adafruit_HX8357::startWrite()':
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:112:25: error: '_spi' was not declared in this scope
     #define SPI_OBJECT  _spi        ///< Default SPI hardware peripheral
                         ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:130:38: note: in expansion of macro 'SPI_OBJECT'
     #define HSPI_BEGIN_TRANSACTION() SPI_OBJECT.beginTransaction(SPISettings(_freq, MSBFIRST, SPI_MODE0))
                                      ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:193:47: note: in expansion of macro 'HSPI_BEGIN_TRANSACTION'
 #define SPI_BEGIN_TRANSACTION() if(_sclk < 0){HSPI_BEGIN_TRANSACTION();}    ///< SPI begin transaction
                                               ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:936:5: note: in expansion of macro 'SPI_BEGIN_TRANSACTION'
     SPI_BEGIN_TRANSACTION();
     ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp: In member function 'virtual void Adafruit_HX8357::endWrite()':
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:112:25: error: '_spi' was not declared in this scope
     #define SPI_OBJECT  _spi        ///< Default SPI hardware peripheral
                         ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:131:38: note: in expansion of macro 'SPI_OBJECT'
     #define HSPI_END_TRANSACTION()   SPI_OBJECT.endTransaction()
                                      ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:194:47: note: in expansion of macro 'HSPI_END_TRANSACTION'
 #define SPI_END_TRANSACTION()   if(_sclk < 0){HSPI_END_TRANSACTION();}      ///< SPI end transaction
                                               ^
/home/mick/Arduino/libraries/Adafruit_HX8357_Library/Adafruit_HX8357.cpp:947:5: note: in expansion of macro 'SPI_END_TRANSACTION'
     SPI_END_TRANSACTION();
     ^
exit status 1
Error compiling for board Adafruit ESP32 Feather.
per1234 commented 6 years ago

Duplicate of https://github.com/adafruit/Adafruit_HX8357_Library/issues/9

mickpf commented 6 years ago

Sorry, I searched for similar issues before I created this one... Maybe the library is not compatible with latest official esp32 tools anymore. I did not try it in the past. Is a solution available?

Thanks in advance, Michael

per1234 commented 6 years ago

The workaround is explained in #9. You only need to use the 1.0.6 version of this library.

ladyada commented 6 years ago

should be good now