Help modifying code

I have a 7" TFT screen that uses the RA8875 controller to run it and was trying to manipulate some existing code I have that I used with a smaller screen that used the STMPE610 touch controller.

I have been able to get graphics and touch events to work on the RA8875 with a simple on/off button where one side of the button turns green and the other turns red upon touching but can't figure out how to change a grid of buttons using the RA8875.

I get a compile error using the If statements for collecting the touch events using the following code and I'm just not good enough with code to decipher the RA8875.h file to put in the correct call to do what I want. The graphics all come out as coded but the touch events don't work because of the compile error.

The code in question is this part where I don't know what to call instead of it for it to work with the RA8875.

 if (!tft.bufferEmpty()) {
    TS_Point p = tft.getPoint();
    switch (rotation) {

This is the full code for you to see everything I'm doing and I will attach the RA8875.h file that I'm using.

#include <SPI.h>
#include <Wire.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"

#define RA8875_INT 3
#define RA8875_CS 10
#define RA8875_RESET 9

Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
uint16_t tx, ty;

byte rotation = 0;
int x, y;
const byte row = 4;
const byte col = 3;
byte lastHit = 0;
byte currentHit = 0;
Adafruit_GFX_Button btn[row * col];

#define TS_MINX 150
#define TS_MINY 130
#define TS_MAXX 3800
#define TS_MAXY 4000

void setup() {
  Serial.begin(9600);
  if (!tft.begin(RA8875_800x480)) {
    Serial.println("RA8875 Not Found!");
    while (1);
  }
  Serial.println("Found RA8875");

  tft.displayOn(true);
  tft.GPIOX(true);      // Enable TFT - display enable tied to GPIOX
  tft.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
  tft.PWM1out(255);
  tft.fillScreen(RA8875_BLACK);
  tft.textMode();
  tft.textSetCursor(20, 15);
  tft.textEnlarge(2);
  tft.textColor(RA8875_WHITE, RA8875_RED);
  tft.textWrite("Choose how many petals you need.");
  tft.graphicsMode();
  tft.touchEnable(true);
  btnGrid();

}
void loop() {
  if (!tft.bufferEmpty()) {
    TS_Point p = tft.getPoint();
    switch (rotation) {
      case 0:
        x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
        y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());
        break;
      case 1:
        // p.x, p.y reversed //
        x = map(p.y, TS_MINY, TS_MAXY, 0, tft.width());
        y = map(p.x, TS_MAXX, TS_MINX, 0, tft.height());
        break;
      case 2:
        x = map(p.x, TS_MAXX, TS_MINX, 0, tft.width());
        y = map(p.y, TS_MAXY, TS_MINY, 0, tft.height());
        break;
      case 3:
        // p.x, p.y reversed //
        x = map(p.y, TS_MAXY, TS_MINY, 0, tft.width());
        y = map(p.x, TS_MINX, TS_MAXX, 0, tft.height());
        break;
    }
  }
  while (tft.touched()) {
    for (uint8_t b = 0; b < row * col; b++) {
      if (btn[b].contains(x, y)) {
        btn[b].press(true);
        btn[b].drawButton(true);
        currentHit = b;
      } else if (btn[b].contains(x, y) == false) {
        btn[b].press(false);
        if (b == lastHit) {
          btn[b].drawButton(false);
        }
      } else {
        return;
      }
    }
    lastHit = currentHit;
  }

}

void btnGrid() {

  int left, top;
  int l = 50;
  int t = 90;
  int w = 200;
  int h = 60;
  byte hgap = 40;
  byte vgap = 40;
  byte id = 0;
  char *titleStr[row * col] = {"4", "6", "8", "9", "12", "16", "Load", "1"};
  for (byte j = 0; j < row; j++) {
    for (byte i = 0; i < col; i++) {
      left = l + i * (w + vgap);
      top = t + j * (h + hgap);
      btn[id].initButtonUL( &tft, left, top, w, h, RA8875_WHITE, RA8875_RED, RA8875_GREEN, titleStr[id], 3 );
      if (id == currentHit) {
        // inverted
        btn[id].drawButton(true);
      } else {
        btn[id].drawButton(false);
      }
      id++;
    }
  }
}

Adafruit_RA8875.h (19.5 KB)

Please post that, in its entirety.

Arduino: 1.8.13 (Mac OS X), Board: "Arduino Due (Programming Port)"











/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/glennholberg/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/glennholberg/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/glennholberg/Documents/Arduino/libraries -fqbn=arduino:sam:arduino_due_x_dbg -ide-version=10813 -build-path /var/folders/sr/r_qf1c_n19b3gr2rrtgsmqg40000gn/T/arduino_build_750933 -warnings=none -build-cache /var/folders/sr/r_qf1c_n19b3gr2rrtgsmqg40000gn/T/arduino_cache_805991 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.bossac.path=/Users/glennholberg/Library/Arduino15/packages/arduino/tools/bossac/1.6.1-arduino -prefs=runtime.tools.bossac-1.6.1-arduino.path=/Users/glennholberg/Library/Arduino15/packages/arduino/tools/bossac/1.6.1-arduino -prefs=runtime.tools.arm-none-eabi-gcc.path=/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1 -prefs=runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path=/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1 -verbose /Users/glennholberg/Documents/Arduino/7_newgrid/7_newgrid.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/glennholberg/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/glennholberg/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/glennholberg/Documents/Arduino/libraries -fqbn=arduino:sam:arduino_due_x_dbg -ide-version=10813 -build-path /var/folders/sr/r_qf1c_n19b3gr2rrtgsmqg40000gn/T/arduino_build_750933 -warnings=none -build-cache /var/folders/sr/r_qf1c_n19b3gr2rrtgsmqg40000gn/T/arduino_cache_805991 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.bossac.path=/Users/glennholberg/Library/Arduino15/packages/arduino/tools/bossac/1.6.1-arduino -prefs=runtime.tools.bossac-1.6.1-arduino.path=/Users/glennholberg/Library/Arduino15/packages/arduino/tools/bossac/1.6.1-arduino -prefs=runtime.tools.arm-none-eabi-gcc.path=/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1 -prefs=runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path=/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1 -verbose /Users/glennholberg/Documents/Arduino/7_newgrid/7_newgrid.ino
Using board 'arduino_due_x_dbg' from platform in folder: /Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11
Using core 'arduino' from platform in folder: /Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11
Detecting libraries used...
/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10813 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/libsam -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/CMSIS/Include/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/cores/arduino -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/variants/arduino_due_x /var/folders/sr/r_qf1c_n19b3gr2rrtgsmqg40000gn/T/arduino_build_750933/sketch/7_newgrid.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for SPI.h: [SPI@1.0]
ResolveLibrary(SPI.h)
  -> candidates: [SPI@1.0]
/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10813 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/libsam -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/CMSIS/Include/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/cores/arduino -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/variants/arduino_due_x -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/SPI/src /var/folders/sr/r_qf1c_n19b3gr2rrtgsmqg40000gn/T/arduino_build_750933/sketch/7_newgrid.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for Wire.h: [Wire@1.0]
ResolveLibrary(Wire.h)
  -> candidates: [Wire@1.0]
/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10813 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/libsam -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/CMSIS/Include/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/cores/arduino -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/variants/arduino_due_x -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/SPI/src -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/Wire/src /var/folders/sr/r_qf1c_n19b3gr2rrtgsmqg40000gn/T/arduino_build_750933/sketch/7_newgrid.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for Adafruit_GFX.h: [Adafruit_GFX_Library@1.1.6]
ResolveLibrary(Adafruit_GFX.h)
  -> candidates: [Adafruit_GFX_Library@1.1.6]
/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10813 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/libsam -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/CMSIS/Include/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/cores/arduino -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/variants/arduino_due_x -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/SPI/src -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/Wire/src -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_GFX_Library /var/folders/sr/r_qf1c_n19b3gr2rrtgsmqg40000gn/T/arduino_build_750933/sketch/7_newgrid.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Alternatives for Adafruit_RA8875.h: [Adafruit_RA8875@1.4.0]
ResolveLibrary(Adafruit_RA8875.h)
  -> candidates: [Adafruit_RA8875@1.4.0]
/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10813 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/libsam -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/CMSIS/Include/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/cores/arduino -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/variants/arduino_due_x -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/SPI/src -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/Wire/src -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_GFX_Library -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_RA8875 /var/folders/sr/r_qf1c_n19b3gr2rrtgsmqg40000gn/T/arduino_build_750933/sketch/7_newgrid.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10813 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/libsam -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/CMSIS/Include/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/cores/arduino -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/variants/arduino_due_x -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/SPI/src -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/Wire/src -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_GFX_Library -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_RA8875 /Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/SPI/src/SPI.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10813 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/libsam -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/CMSIS/Include/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/cores/arduino -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/variants/arduino_due_x -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/SPI/src -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/Wire/src -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_GFX_Library -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_RA8875 /Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/Wire/src/Wire.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10813 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/libsam -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/CMSIS/Include/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/cores/arduino -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/variants/arduino_due_x -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/SPI/src -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/Wire/src -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_GFX_Library -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_RA8875 /Users/glennholberg/Documents/Arduino/libraries/Adafruit_GFX_Library/Adafruit_GFX.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10813 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/libsam -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/CMSIS/Include/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/cores/arduino -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/variants/arduino_due_x -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/SPI/src -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/Wire/src -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_GFX_Library -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_RA8875 /Users/glennholberg/Documents/Arduino/libraries/Adafruit_GFX_Library/glcdfont.c -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10813 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/libsam -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/CMSIS/Include/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/cores/arduino -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/variants/arduino_due_x -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/SPI/src -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/Wire/src -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_GFX_Library -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_RA8875 /Users/glennholberg/Documents/Arduino/libraries/Adafruit_RA8875/Adafruit_RA8875.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Generating function prototypes...
/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10813 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/libsam -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/CMSIS/Include/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/cores/arduino -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/variants/arduino_due_x -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/SPI/src -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/Wire/src -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_GFX_Library -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_RA8875 /var/folders/sr/r_qf1c_n19b3gr2rrtgsmqg40000gn/T/arduino_build_750933/sketch/7_newgrid.ino.cpp -o /var/folders/sr/r_qf1c_n19b3gr2rrtgsmqg40000gn/T/arduino_build_750933/preproc/ctags_target_for_gcc_minus_e.cpp -DARDUINO_LIB_DISCOVERY_PHASE
/Applications/Arduino.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /var/folders/sr/r_qf1c_n19b3gr2rrtgsmqg40000gn/T/arduino_build_750933/preproc/ctags_target_for_gcc_minus_e.cpp
Compiling sketch...
/Users/glennholberg/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -MMD -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10813 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/libsam -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/CMSIS/Include/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/system/CMSIS/Device/ATMEL/ -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/cores/arduino -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/variants/arduino_due_x -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/SPI/src -I/Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/Wire/src -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_GFX_Library -I/Users/glennholberg/Documents/Arduino/libraries/Adafruit_RA8875 /var/folders/sr/r_qf1c_n19b3gr2rrtgsmqg40000gn/T/arduino_build_750933/sketch/7_newgrid.ino.cpp -o /var/folders/sr/r_qf1c_n19b3gr2rrtgsmqg40000gn/T/arduino_build_750933/sketch/7_newgrid.ino.cpp.o
/Users/glennholberg/Documents/Arduino/7_newgrid/7_newgrid.ino: In function 'void loop()':
7_newgrid:50:12: error: 'class Adafruit_RA8875' has no member named 'bufferEmpty'
   if (!tft.bufferEmpty()) {
            ^
7_newgrid:51:5: error: 'TS_Point' was not declared in this scope
     TS_Point p = tft.getPoint();
     ^
7_newgrid:51:14: error: expected ';' before 'p'
     TS_Point p = tft.getPoint();
              ^
7_newgrid:54:17: error: 'p' was not declared in this scope
         x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
                 ^
Using library SPI at version 1.0 in folder: /Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/SPI 
Using library Wire at version 1.0 in folder: /Users/glennholberg/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/libraries/Wire 
Using library Adafruit_GFX_Library at version 1.1.6 in folder: /Users/glennholberg/Documents/Arduino/libraries/Adafruit_GFX_Library 
Using library Adafruit_RA8875 at version 1.4.0 in folder: /Users/glennholberg/Documents/Arduino/libraries/Adafruit_RA8875 
exit status 1
'class Adafruit_RA8875' has no member named 'bufferEmpty'

If the class has no method 'bufferEmpty()' then it's likely the driver IC has no buffer, or the buffer is handled differently than with the other chip.

What is your level of understanding code? Display hardware? This is not a beginner task. You have to really understand the difference in driver hardware/software in order to adapt the other program for this use.

Is there not an Adafruit example sketch for this display that you can consult?

The examples for the Adafruit RA8875 are a little lacking to be honest.

I don't have that much experience with coding but manage to muddle my way through most of the time which is why I was asking if anyone had experience with how the RA8875 handled things.

it seemed like something small to change if I understood the RA8875.h file.

What do you mean, "a little lacking"? What do they lack, that you need?

It's unlikely that anyone that reads this will have specific RA8875 experience, as there are so many displays. Even if so, how many of those people would be willing to wade deeply into your code without any help from your side? So it's unlikely to happen that way.

What specific things don't you understand about the .h file? If you have specific questions, you could post the lines in question and state what misunderstanding you have.

Lastly, have you undertaken any general research on the IC? For example, looked for data sheets and other documentation?

Thanks for the help aarg, I thought it would be something simple with the code but when I get stuck with no direction to go I post a topic and someone usually ask's me the right question and gets me moving in the right direction.

I was able to change the the basic code I posted along with a couple other things to get everything working properly. I changed the following code,

 if (!tft.bufferEmpty()) {
    TS_Point p = tft.getPoint();

to this,

 if (tft.touched()) {
    tft.touchRead(&tx,&ty);

along with changing a while statement to an if statement a little farther down.

I will post the completed code just in case someone has a similar problem in the future.

#include <SPI.h>
#include <Wire.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"

#define RA8875_CS 10
#define RA8875_RESET 9

Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
uint16_t tx, ty;

byte rotation = 0;
int x, y;
const byte row = 4;
const byte col = 3;
byte lastHit = 0;
byte currentHit = 0;
Adafruit_GFX_Button btn[row * col];
const int TS_MAXX = 900, TS_MINX = 60, TS_MAXY = 920, TS_MINY = 80;

void setup() {
  Serial.begin(9600);
  if (!tft.begin(RA8875_800x480)) {
    Serial.println("RA8875 Not Found!");
    while (1);
  }
  Serial.println("Found RA8875");

  tft.displayOn(true);
  tft.GPIOX(true);      // Enable TFT - display enable tied to GPIOX
  tft.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
  tft.PWM1out(255);
  tft.fillScreen(RA8875_BLACK);
  tft.textMode();
  tft.textSetCursor(20, 15);
  tft.textEnlarge(2);
  tft.textColor(RA8875_WHITE, RA8875_RED);
  tft.textWrite("Choose how many petals you need.");
  tft.graphicsMode();
  tft.touchEnable(true);
  btnGrid();

}
void loop() {
  if (tft.touched()) {
    tft.touchRead(&tx,&ty);
    switch (rotation) {
      case 0:
        tx = map(tx, TS_MINX, TS_MAXX, 0, tft.width());
        ty = map(ty, TS_MINY, TS_MAXY, 0, tft.height());
        break;
      case 1:
        // p.x, p.y reversed //
        tx = map(ty, TS_MINY, TS_MAXY, 0, tft.width());
        ty = map(tx, TS_MAXX, TS_MINX, 0, tft.height());
        break;
      case 2:
        tx = map(tx, TS_MAXX, TS_MINX, 0, tft.width());
        ty = map(ty, TS_MAXY, TS_MINY, 0, tft.height());
        break;
      case 3:
        // p.x, p.y reversed //
        tx = map(ty, TS_MAXY, TS_MINY, 0, tft.width());
        ty = map(tx, TS_MINX, TS_MAXX, 0, tft.height());
        break;
    }
  }
  if (tft.touched()) {
    for (uint8_t b = 0; b < row * col; b++) {
      if (btn[b].contains(tx, ty)) {
        btn[b].press(true);
        btn[b].drawButton(true);
        currentHit = b;
      } else if (btn[b].contains(tx, ty) == false) {
        btn[b].press(false);
        if (b == lastHit) {
          btn[b].drawButton(false);
        }
      } else {
        return;
      }
    }
    lastHit = currentHit;
  }

}

void btnGrid() {

  int left, top;
  int l = 50;
  int t = 90;
  int w = 200;
  int h = 60;
  byte hgap = 40;
  byte vgap = 40;
  byte id = 0;
  char *titleStr[row * col] = {"4", "6", "8", "9", "12", "16", "Load", "1"};
  for (byte j = 0; j < row; j++) {
    for (byte i = 0; i < col; i++) {
      left = l + i * (w + vgap);
      top = t + j * (h + hgap);
      btn[id].initButtonUL( &tft, left, top, w, h, RA8875_WHITE, RA8875_RED, RA8875_GREEN, titleStr[id], 3 );
      if (id == currentHit) {
        // inverted
        btn[id].drawButton(true);
      } else {
        btn[id].drawButton(false);
      }
      id++;
    }
  }
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.