Teensy 4.x + ESP32 Stack

Bt data logger ran 17 hours - then edit to output {added cnt on Purge items to show how many 5 sec hits they persisted for} and ~28 hours since. Is seeming a cool data store - even if not useful.

Code:
 >> MAC: 35:70:29:65:17:30    NEW :: CRC: 1394898376    Name: , Address: 35:70:29:65:17:30, <>        RSSI: -87
Devices found: 10    >>> Num MAC Known 41
PAK to Scan again [more than 2 chars erases known MACs] 's' ShowAll : 'd' Toggle Dupe display : 't' 5sec Auto Update

=== 41 Known Bt MAC IDs ===
 >25> MAC: 03:46:5E:A8:6C:EA  CRC:6A34DA9F    cnt:107    Chron:366
 > 9> MAC: 04:EA:5C:C8:05:71  CRC:F3DA0139    cnt:85    Chron:364
 >35> MAC: 04:99:4D:85:8E:50  CRC:4951E491    cnt:84    Chron:369
 > 6> MAC: 06:48:3B:74:43:20  CRC:640F2DEB    cnt:121    Chron:371
 >16> MAC: 08:39:B0:8D:47:4E  CRC:D49C75DA    cnt:121    Chron:369
 >20> MAC: 09:FC:C9:E4:25:B4  CRC:65A7CC4A    cnt:89    Chron:363
 > 1> MAC: 0E:84:2B:C7:A4:40  CRC:6F35B9F9    cnt:82    Chron:368
 >24> MAC: 12:92:BE:6C:83:15  CRC:6AF6AD32    cnt:120    Chron:365
 >39> MAC: 16:3D:7C:AE:97:AB  CRC:4F08CA1E    cnt:6    Chron:371
 >36> MAC: 1B:BD:7A:A4:B4:D3  CRC:8AFB3D37    cnt:90    Chron:371
 >10> MAC: 1C:EB:6A:C1:08:54  CRC:5049E87    cnt:15    Chron:371
 > 7> MAC: 1D:D8:B7:03:4D:18  CRC:9CA81AE5    cnt:94    Chron:364
 >28> MAC: 1F:2C:38:CE:E9:8D  CRC:A97F02B    cnt:21    Chron:371
 >30> MAC: 20:53:88:D9:CB:F5  CRC:794E760C    cnt:120    Chron:371
 >22> MAC: 21:20:81:74:2F:A0  CRC:81DB2D9C    cnt:101    Chron:366
 > 2> MAC: 22:71:B8:95:C2:D3  CRC:5E319D2    cnt:100    Chron:371
 > 3> MAC: 24:CE:33:DB:83:5C  CRC:9514140F    cnt:22145    Chron:371
 >26> MAC: 26:D0:36:FC:1C:16  CRC:6D0002EB    cnt:121    Chron:367
 >17> MAC: 27:FF:56:D9:40:CA  CRC:79069634    cnt:120    Chron:369
 >21> MAC: 28:91:C1:FC:3D:40  CRC:27BFDD5E    cnt:91    Chron:367
 >23> MAC: 28:B8:21:BE:03:53  CRC:8B74D21E    cnt:90    Chron:366
 > 5> MAC: 2B:5B:30:91:90:2B  CRC:BD920C4F    cnt:120    Chron:367
 >11> MAC: 2F:87:25:8C:D8:5D  CRC:98F95A8B    cnt:120    Chron:363
 >33> MAC: 30:CA:A6:56:2B:E5  CRC:4FC356CE    cnt:97    Chron:369
 >15> MAC: 31:EE:79:6D:04:CA  CRC:5F1AAA25    cnt:88    Chron:363
 >27> MAC: 31:FB:41:34:61:1F  CRC:4FDBCE1F    cnt:87    Chron:364
 >18> MAC: 34:37:9C:E3:1D:C9  CRC:8331599C    cnt:108    Chron:371
 >40> MAC: 35:70:29:65:17:30  CRC:532475C8    cnt:1    Chron:371
 > 4> MAC: 38:17:FF:A9:52:F9  CRC:3094857E    cnt:121    Chron:365
 >14> MAC: 39:06:EC:A4:EF:0A  CRC:99E3F098    cnt:103    Chron:368
 >34> MAC: 39:0D:9C:C9:00:B4  CRC:303C48CE    cnt:100    Chron:369
 >12> MAC: 3C:E0:C4:31:02:E6  CRC:B2888D6C    cnt:120    Chron:363
 >13> MAC: 46:2C:9D:CE:2C:DE  CRC:1F4C6366    cnt:88    Chron:363
 >38> MAC: 49:3D:C1:FC:9D:3D  CRC:D173C25E    cnt:1    Chron:370
 >19> MAC: 50:62:EF:EE:63:98  CRC:3C25FD50    cnt:94    Chron:368
 >29> MAC: 51:15:BC:A7:4B:26  CRC:6BFC3408    cnt:90    Chron:365
 >37> MAC: 5A:12:86:D7:17:D3  CRC:A3A57C85    cnt:75    Chron:371
 > 8> MAC: 64:E8:33:00:63:99  CRC:E061DBC5    cnt:12698    Chron:371
 >32> MAC: 65:DB:C7:45:99:F5  CRC:18BE20A9    cnt:105    Chron:370
 >31> MAC: 7A:06:1F:EF:83:67  CRC:2786A7C    cnt:99    Chron:366
 > 0> MAC: E2:BB:9E:20:44:53  CRC:710387E8    cnt:22219    Chron:371
==================
===== Purge oldest Chron 363
    REMOVE >11> MAC: 2F:87:25:8C:D8:5D    cnt:120
    REMOVE >12> MAC: 3C:E0:C4:31:02:E6    cnt:120
    REMOVE >13> MAC: 46:2C:9D:CE:2C:DE    cnt:88
    REMOVE >15> MAC: 31:EE:79:6D:04:CA    cnt:88
    REMOVE >20> MAC: 09:FC:C9:E4:25:B4    cnt:89
==================
Devices found: 9    >>> Num MAC Known 36
 
I downloaded and tested all of this on my other computers. The weather_display_v5_RA8876 sketch works with both WIFI and native Ethernet.
Hopefully everything works at first try:cautious:
In the middle of a couple of other things will give set it up and give it a try later today :)

Thanks.
Mike
 
The "weather_display_v5_RA8876" sketch is for use with the ER-0TFTM-101-1 RA8876 SPI TFT and resistive touch screen is working with the Sparkfun CYW43439 WIFI shield.
As @mjs513 will try to try it out later today ... Although I don't have a 10" display, but hopefully the smaller RA8876 should work.

As for distractions, yesterday was able to get it to run on UNO R4 Wifi including touch and keyboard... But had to do more more compression
of the images, so now have it removing the top and bottom blank lines and structure has count of those so use fillRect for those. Maybe at
some point will also so that to left and right...

Other things I may hack into the UNO version is something similar to the Giga version where I don't have a arduino_secrets.h or the like file... I hate those... On GIGA I stored it in a file on Flash... With Uno it has an 8K EEPROM, so maybe there.

Wish there was setup without needs of jumpers.... Maybe a display like:

But that is a different subject....
 
As @mjs513 will try to try it out later today ... Although I don't have a 10" display, but hopefully the smaller RA8876 should work.
You will probably have to run the calibration sketch example in XPT2046_RA8876 and add those results to:
Code:
  // Replace these for your screen module
  ts.setCalibration(1921, 1974, 171, 70);
//  ts.setCalibration(1951, 1990, 152, 51);
The ts.setCalibration(1921, 1974, 171, 70) function needs to be run in the setup function of any sketch using the touchscreen.
Wish there was setup without needs of jumpers.... Maybe a display like:
I am still using your Dev board 4.5 shield. But I guess that only does the 8080 parallel thing on the 40 pin connector, right?
I'm with you It is getting harder to use the wire jumpers. I have to double and triple check the connections and they are usually of by one:LOL:
 
I am still using your Dev board 4.5 shield. But I guess that only does the 8080 parallel thing on the 40 pin connector, right?
I am trying to get it hooked up with one of my RA8876 shields...
1789835789777.png


But by default: this is setup for:
Code:
#define TFT_CS   30
#define TFT_RST   28
Which I think is running directly into the WiFi board... luckily most all of these are connected through shunts, so can remove
those and hopefully jumper to a different pin...

Also on your instructions for the Qnet... library are you using the main branch or the QNether..._0.37.0 branch guessing the later
 
@wwatson - @KurtE

Found that I dont have any RA8876 displays that use resistive touch only capacitive touch. Spent the morning sorting through that. Did find a lib that supports it:


Hacked up your calibration sketch and was able to get a calibration - argh. Guess now have to sort out how to support it - looks like you really hacked up the xp2046 driver - nice but...

Mike
 
I believe that with the current TeensyRA8876 code that the Capacitive Touch code is or can be built in...

in RA8876_common.h is:
Code:
//#define USE_FT5206_TOUCH

And in the class there is:
Code:
#if defined(USE_FT5206_TOUCH)
    bool touched(bool safe = false);
    void setTouchLimit(uint8_t limit); // 5 for FT5206, 1 for  RA8875
    uint8_t getTouchLimit(void);

    void setWireObject(TwoWire *wire) { _wire = wire; }
    void useCapINT(const uint8_t INTpin = 2, const uint8_t RSTPin = 255);
    void enableCapISR(bool force = false);
    void updateTS(void);
    uint8_t getGesture(void);
    uint8_t getTouches(void);
    uint8_t getTouchState(void);
    uint8_t getTScoordinates(uint16_t (*touch_coordinates)[2]);
    void printTSRegisters(Print &pr, uint8_t start, uint8_t count);
#endif
 
I am trying to get it hooked up with one of my RA8876 shields...
View attachment 39854

But by default: this is setup for:
Code:
#define TFT_CS   30
#define TFT_RST   28
Which I think is running directly into the WiFi board... luckily most all of these are connected through shunts, so can remove
those and hopefully jumper to a different pin...

Also on your instructions for the Qnet... library are you using the main branch or the QNether..._0.37.0 branch guessing the later
Yes, I am using the main branch. It is version 0.37.0.
 
@wwatson - @KurtE

Found that I dont have any RA8876 displays that use resistive touch only capacitive touch. Spent the morning sorting through that. Did find a lib that supports it:


Hacked up your calibration sketch and was able to get a calibration - argh. Guess now have to sort out how to support it - looks like you really hacked up the xp2046 driver - nice but...

Mike
The XTP206_RA8876 driver is not a hacked up version of XTP2046_Touchscreen in Teensyduino but a slightly hacked up version found on GitHub a few years ago:D Unfortunately I do not have an SPI TFT with a capacitive touch screen to work with...
 
The XTP206_RA8876 driver is not a hacked up version of XTP2046_Touchscreen in Teensyduino but a slightly hacked up version found on GitHub a few years ago:D Unfortunately I do not have an SPI TFT with a capacitive touch screen to work with...
Sorry thought it was the other way around. Not to worry will work on getting the FT5206 driver working.

I believe that with the current TeensyRA8876 code that the Capacitive Touch code is or can be built in...
Just tried the example RA8876 touch and while its registering the touch it not grabbing the points. More to work on I guess.
 
@KurtE
If you are going to play along as I said if I use the built in commands for FT5206 in RA8876 common if the screen is touched it will register but the coordinates are not updated - before digging into the code more I first tried the example using the driver directly
C++:
/*
  An example of the RA8876 screen with the capacitive touch screen that use FT5316
  Such as BuyDisplay ER-TFTM070-6
  The FT5206 is normally used with the RA8875 screens but it seems all the FT chips work the same...
  Get the RA8876_t3 library from: https://github.com/mjs513/Ra8876LiteTeensy/tree/RA8876-redo
  Get the FT5206 library from: https://github.com/sumotoy/FT5206

  Also demonstrates use of the "graphic cursor" mouse cursor and a simple animated cursor.
*/
#define use_spi
#if defined(use_spi)
#include <SPI.h>
#include <RA8876_t3.h>
#include <FT5206.h>
#else
#include <RA8876_t41_p.h>
#endif

#if defined(use_spi)
#define RA8876_CS 10
#define RA8876_RESET 9
//#define BACKLITE 7 //External backlight control connected to this Arduino pin
RA8876_t3 tft = RA8876_t3(RA8876_CS, RA8876_RESET); //Using standard SPI pins
FT5206 ts = FT5206(6);
uint8_t registers[FT5206_REGISTERS];
#else
uint8_t dc = 13;
uint8_t cs = 11;
uint8_t rst = 12;
RA8876_t41_p tft = RA8876_t41_p(dc,cs,rst); //(dc, cs, rst)
#endif

#define CTP_INT           6    // Use an interrupt capable pin such as pin 2 (any pin on a Teensy)
#define MAXTOUCHLIMIT 1
uint16_t new_coordinates[5][2];
uint16_t old_coordinates[5][2];
uint8_t current_touches = 0;
uint8_t old_touches = 0;

int currentCursor;
int cursorOffsetX = 15;
int cursorOffsetY = 15;

//Custom cursor is a spinning circle which can be mirrored and rotated for an 8-frame animation cycle
PROGMEM unsigned char customCursor[256] = {
  0b10101010, 0b10101010, 0b10101010, 0b10010101, 0b01011010, 0b10101010, 0b10101010, 0b10101010,
  0b10101010, 0b10101010, 0b10010101, 0b01000000, 0b00011010, 0b10101010, 0b10101010, 0b10101010,
  0b10101010, 0b10101010, 0b01010000, 0b00000000, 0b00011010, 0b10101010, 0b10101010, 0b10101010,
  0b10101010, 0b10100101, 0b01000000, 0b00000000, 0b00011010, 0b10101010, 0b10101010, 0b10101010,
  0b10101010, 0b10010100, 0b00000000, 0b00000101, 0b01011010, 0b10101010, 0b10100110, 0b10101010,
  0b10101010, 0b01010000, 0b00000001, 0b01011010, 0b10101010, 0b10101010, 0b10010101, 0b10101010,
  0b10101001, 0b01000000, 0b00010101, 0b10101010, 0b10101010, 0b10101010, 0b01000001, 0b01101010,
  0b10101001, 0b00000000, 0b01011010, 0b10101010, 0b10101010, 0b10101001, 0b00000000, 0b01101010,
  0b10100101, 0b00000001, 0b01101010, 0b10101010, 0b10101010, 0b10101001, 0b01000000, 0b01011010,
  0b10010100, 0b00000110, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b01010000, 0b00010110,
  0b10010000, 0b00000110, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10010000, 0b00000110,
  0b10010000, 0b00010110, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10010100, 0b00000110,
  0b10010000, 0b00011010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10100100, 0b00000110,
  0b01000000, 0b01011010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10100101, 0b00000001,
  0b01000000, 0b01101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101001, 0b00000001,
  0b01000000, 0b01101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101001, 0b00000001,
  0b01000000, 0b01101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101001, 0b00000001,
  0b01000000, 0b01101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101001, 0b00000001,
  0b01000000, 0b01011010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10100101, 0b00000001,
  0b10010000, 0b00011010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10100100, 0b00000110,
  0b10010000, 0b00010110, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10010100, 0b00000110,
  0b10010000, 0b00000110, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10010000, 0b00000110,
  0b10010100, 0b00000110, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b01010000, 0b00010110,
  0b10100101, 0b00000001, 0b01101010, 0b10101010, 0b10101010, 0b10101001, 0b01000000, 0b01011010,
  0b10101001, 0b00000000, 0b01011010, 0b10101010, 0b10101010, 0b10100101, 0b00000000, 0b01101010,
  0b10101001, 0b01000000, 0b00010101, 0b10101010, 0b10101010, 0b01010100, 0b00000001, 0b01101010,
  0b10101010, 0b01010000, 0b00000001, 0b01011010, 0b10100101, 0b01000000, 0b00000101, 0b10101010,
  0b10101010, 0b10010100, 0b00000000, 0b00000101, 0b01010100, 0b00000000, 0b00010110, 0b10101010,
  0b10101010, 0b10100101, 0b01000000, 0b00000000, 0b00000000, 0b00000001, 0b01011010, 0b10101010,
  0b10101010, 0b10101010, 0b01010000, 0b00000000, 0b00000000, 0b00000101, 0b10101010, 0b10101010,
  0b10101010, 0b10101010, 0b10010101, 0b01000000, 0b00000001, 0b01010110, 0b10101010, 0b10101010,
  0b10101010, 0b10101010, 0b10101010, 0b10010101, 0b01010110, 0b10101010, 0b10101010, 0b10101010,

};


void setup()
{
  Serial.begin(38400);
  long unsigned debug_start = millis ();
  while (!Serial && ((millis () - debug_start) <= 500)) ;
  Serial.println("RA8876 touchscreen test starting!");
  Serial.print("Compiled ");
  Serial.print(__DATE__);
  Serial.print(" at ");
  Serial.println(__TIME__);

  //I'm guessing most copies of this display are using external PWM
  //backlight control instead of the internal RA8876 PWM.
  //Connect a Teensy pin to pin 14 on the display.
  //Can use analogWrite() but I suggest you increase the PWM frequency first so it doesn't sing.
#if defined(use_spi)
////  pinMode(BACKLITE, OUTPUT);
//  digitalWrite(BACKLITE, HIGH);
//  tft.backlight(true);
#endif

#if defined(use_spi)
  tft.begin();
  ts.begin(SAFE);
#else
  tft.begin(20);// 20 is working in 8bit and 16bit mode on T41
#endif
#if 0
  tft.useCapINT(CTP_INT);//we use the capacitive chip Interrupt out!
  //the following set the max touches (max 5)
  //it can be placed inside loop but BEFORE touched()
  //to limit dinamically the touches (for example to 1)
  tft.setTouchLimit(MAXTOUCHLIMIT);
  tft.enableCapISR(true);//capacitive touch screen interrupt it's armed
#endif


  tft.setTextColor(0xFFFF, 0x0000);
  Serial.println("inited...");

  //begin method of RA8876_t3 will initialize the graphic cursor images from the default ones in the library
  //and select the arrow one (but does not enable the cursor as visible)

  //Test uploading our own custom cursor (will be animated later)
  tft.Upload_Graphic_Cursor(4, customCursor);
  tft.Select_Graphic_Cursor_4();
  currentCursor = 4;

  tft.Enable_Graphic_Cursor(); // Turn on selected graphic cursor.
  // You can play with the cursor colors in the following two lines.
  tft.Set_Graphic_Cursor_Color_1(0xff); // White forground Color. (8 bit RRRGGBB)
  tft.Set_Graphic_Cursor_Color_2(0x00); // Black outline Color. (8 bit RRRGGBB)
  tft.Graphic_Cursor_XY(tft.width() / 2 - cursorOffsetX, tft.height() / 2 - cursorOffsetY); // Center cursor on screen.

  tft.fillRect(0, 0, 215, 215, ORCHID);
  tft.fillRect(400, 0, 172, 172, BLUEVIOLET);
}



void loop()
{
#if 0
  //cts.setTouchLimit(1);//from 1 to 5
  if (tft.touched()) { //if touched(true) detach isr
    //at this point we need to fill the FT5206 registers...
    tft.updateTS();//now we have the data inside library
    Serial.print(">> touches:");
    Serial.print(tft.getTouches());
    Serial.print(" | gesture:");
    Serial.print(tft.getGesture(), HEX);
    Serial.print(" | state:");
    Serial.print(tft.getTouchState(), HEX);
    uint16_t coordinates[MAXTOUCHLIMIT][2];//to hold coordinates
    tft.getTScoordinates(coordinates);//done
    //now coordinates has the x,y of all touches
    for (uint8_t i = 0; i <= tft.getTouches(); i++) {
      Serial.printf(" (%d,%d)", coordinates[i][0], coordinates[i][1]);
    }
    tft.enableCapISR();//rearm ISR if needed (touched(true))
    Serial.println();
  }
#endif
#if 1
  if (ts.touched()) {
    uint8_t i;
    uint16_t x, y;
    ts.getTSregisters(registers);
    current_touches = ts.getTScoordinates(new_coordinates, registers);
    if (current_touches < 1) return;

    for (i = 1; i <= old_touches; i++) { // remove previous touches on screen
      //tft.fillCircle(old_coordinates[i - 1][0], old_coordinates[i - 1][1], 70, BLACK);
    }

    Serial.print(current_touches);
    Serial.print(" touches: ");

    for (i = 1; i <= current_touches; i++) { // mark touches on screen
      //Touch panel is upside-down to the screen coordinates, so we must subtract
      x = new_coordinates[i - 1][0] - 1;
      y = new_coordinates[i - 1][1] - 1;

      Serial.print(x);
      Serial.print(",");
      Serial.print(y);
      Serial.print("  ");

      // Mark touches on screen
      //tft.fillCircle(x, y, 70, BLUE);
      //tft.fillCircle(x, y, 50, WHITE);
      //tft.fillCircle(x, y, 30, WHITE);

      //demonstrate the mouse cursor (yes, it won't be very visible under your finger, that's why it is left on the screen after you lift up
      tft.Graphic_Cursor_XY(x - cursorOffsetX, y - cursorOffsetY);

      old_coordinates[i - 1][0] = x;
      old_coordinates[i - 1][1] = y;
    }

    old_touches = current_touches;
    Serial.println();
  }
  ts.rearmISR();

  static unsigned long lastCursorSwap = 0;
  if (millis() - lastCursorSwap > 3000) {
    //select the next cursor
    //Due to different cursor shapes, the "visual center" of each cursor is different, so we need different offsets.
    lastCursorSwap = millis();
    currentCursor++;
    if (currentCursor > 4) currentCursor = 1;
    switch (currentCursor) {
      case 1:
        tft.Select_Graphic_Cursor_1();
        updateOffsets(0, 0);
        break;
      case 2:
        tft.Select_Graphic_Cursor_2();
        updateOffsets(0, 0);
        break;
      case 3:
        tft.Select_Graphic_Cursor_3();
        updateOffsets(15, 10);
        break;
      case 4:
        tft.Select_Graphic_Cursor_4();
        updateOffsets(15, 10);
        break;
    }
  }

  static unsigned long lastRotate = 0;
  static int rotation = 0;
  if (currentCursor == 4 && millis() - lastRotate > 100) {
    lastRotate = millis();
    rotation++;
    if (rotation >= 8) rotation = 0;
    //rotate our custom cursor through 8 orientations
    rotateCursor(rotation);
  }
#endif
}

void updateOffsets(int x, int y) {
  //change the graphic cursor offset
  int oldOffsetX = cursorOffsetX;
  int oldOffsetY = cursorOffsetY;
  cursorOffsetX = x;
  cursorOffsetY = y;
  tft.Graphic_Cursor_XY(tft.GetGCursorX() + oldOffsetX - cursorOffsetX, tft.GetGCursorY() + oldOffsetY - cursorOffsetY);
}

void rotateCursor(int rotation) {
  //flip or rotate the cursor image into a temporary array then reload that array onto the RA8876
  unsigned char data[256];
  int outx = 0; //horizontal (byte) in output array
  int outy = 0; //vertical coordinate in output
  int out = 0; //byte index into output array
  int inx, iny, in;
  while (out < 256) {
    unsigned char tmp = 0;
    switch (rotation) {
      case 0: //no rotation, out = in
        tmp = customCursor[out];
        break;
      case 1: //flip on diagonal from bottom left to top right (or rotate right 90, then flip on horizontal axis)
        inx = 7 - outy / 4;
        iny = 31 - outx * 4;
        in = iny * 8 + inx;
        tmp = reverseByte(rotateByte(customCursor, in, 3 - outy % 4));
        break;
      case 2: //rotate 90 right
        inx = outy / 4;
        iny = 31 - outx * 4;
        in = iny * 8 + inx;
        tmp = reverseByte(rotateByte(customCursor, in, outy % 4));
        break;
      case 3: //flip on horizontal axis: top to bottom
        inx = outx;
        iny = 31 - outy;
        in = iny * 8 + inx;
        tmp = customCursor[in];
        break;
      case 4: //flip both H and V
        inx = 7 - outx;
        iny = 31 - outy;
        in = iny * 8 + inx;
        tmp = reverseByte(customCursor[in]);
        break;
      case 5: //rotate 90 left then flip on horizontal axis
        inx = outy / 4;
        iny = outx * 4 + 3;
        in = iny * 8 + inx;
        tmp = rotateByte(customCursor, in, outy % 4);
        break;
      case 6: //rotate 90 left
        inx = 7 - outy / 4;
        iny = outx * 4 + 3;
        in = iny * 8 + inx;
        tmp = rotateByte(customCursor, in, 3 - outy % 4);
        break;
      case 7: //flip on vertical axis: left to right
        inx = 7 - outx;
        iny = outy;
        in = iny * 8 + inx;
        tmp = reverseByte(customCursor[in]);
        break;
      default: //no rotation, out = in
        tmp = customCursor[out];
    }

    data[out] = tmp;
    outx++;
    if (outx >= 8) {
      outx = 0;
      outy++;
    }
    out++;
  }

  //Yes, we really can just upload a new cursor while it's currently displayed.
  //This does occasionally display a glitch but only for a very short time as
  //the upload will finish before the next "frame" of the LCD is displayed.
  tft.Upload_Graphic_Cursor(4, data);
}

unsigned char reverseByte(unsigned char b) {
  //swap the order of pixels in a byte
  return (b & 0b00000011) << 6 | (b & 0b00001100) << 2 | (b & 0b00110000) >> 2 | (b & 11000000) >> 6;
}

unsigned char rotateByte(unsigned char input[], int in, int column) {
  //return a byte transposed from a column
  //eg. "in" may be 248 which is the bottom-left byte in the 8x32 byte array
  //then in-8 is the row above this, in-16 is the row above that and in-24 is the row above that.
  //columns are numbered left-to right in the byte with 0 being the left or MSB side
  switch (column) {
    case 3: //select right-hand pixel out of each byte
      return (input[in] & 0b00000011) | (input[in - 8] & 0b00000011) << 2 | (input[in - 16] & 0b00000011) << 4 | (input[in - 24] & 0b00000011) << 6;
    case 2:
      return (input[in] & 0b00001100) >> 2 | (input[in - 8] & 0b00001100) | (input[in - 16] & 0b00001100) << 2 | (input[in - 24] & 0b00001100) << 4;
    case 1:
      return (input[in] & 0b00110000) >> 4 | (input[in - 8] & 0b00110000) >> 2 | (input[in - 16] & 0b00110000) | (input[in - 24] & 0b00110000) << 2;
    case 0: //left hand pixel in each byte
      return (input[in] & 0b11000000) >> 6 | (input[in - 8] & 0b11000000) >> 4 | (input[in - 16] & 0b11000000) >> 2 | (input[in - 24] & 0b11000000);
  }
  return 0;
}

It works:

Rich (BB code):
 touches: 1022,596 
1 touches: 1022,588 
1 touches: 979,567 
1 touches: 901,528 
1 touches: 728,441 
1 touches: 649,400 
1 touches: 577,361 
1 touches: 541,340 
1 touches: 439,279 
1 touches: 376,246 
1 touches: 316,214 
1 touches: 48,48 
1 touches: 27,29 
1 touches: 5,7 
1 touches: 1,3

Now to dig into stuff.
 
@wwatson - @KurtE

Now that I have figured out how to get the 5206 working :) I moded the weather sketch to use the capacitive touch screen.

However with that said I ran into a problem that if I uncomment `#define USE_FT5206_TOUCH` in `RA8876_Config_SPI.h` its not picking it up in `RA8876_t3.h` - it throughs a `undefined` error on the touch commands. Got around it by adding this to the common.h file

C++:
#if __has_include("RA8876_t3.h")
#include <RA8876_Config_SPI.h>
#endif

not sure if there is a better way. My guess is that the 8080 version of the library has that issue as well - maybe.

But touch does work - now to see what has to be done for keypad. Attaching the updated sketch
 

Attachments

  • weather_display_v5_RA8876-260920a.zip
    78.4 KB · Views: 24
@wwatson
Just pushed another PR to cover adding in the Config_SPI into the common repo.

Let me know if you want me add in the other display, i.e., 8080 version. Will do it later today.
 
@wwatson
Just pushed another PR to cover adding in the Config_SPI into the common repo.

Let me know if you want me add in the other display, i.e., 8080 version. Will do it later today.
Not sure if we can use the WIFI board from Sparkfun with the 8080 interface because of pin conflicts. But maybe if we used the new @KenHahn devices (which I need to order still) maybe that would work. The latest 10.1" BuyDisplay 8080 TFT uses the Goodix GT9271 CPT touch screen. I adapted an Arduino driver to work with it. It is kind of a rough cut sketch but it was working.The link is https://github.com/wwatson4506/Arduino-goodix-GT9271.
The BuyDisplay keeps changing there controllers on thier TFT's. I guess if we had a SDHC style interface that plugs into the SDIO slot on the T4.1 with a CYW43439 chip on it that would give another option taking up less pins and a person could use the USB Host with a thumb drive if needed. Right now I am using a 256MB NVME SSD with a USB to NVME adapter that is giving 30MB transfer rates with both reads and writes. This is comparable to SDIO SDHC transfer speeds...
 
@wwatson @mjs513

I ran it and it works...

Question: @wwatson I know you have your sketch in your fork/main - which is one commit ahead of @mjs513 in the Teensy-wifi-Apps

Originally i checked out your fork/branch and then copied the sketch to different folder. At some point are you planning to PR it back
to @mjs513...

It will also be interesting to experiment using more space of the display:
1789931644711.png


Looks like it is currently same layout as the ST7796, like the one hooked up to the T41 stack (top), where as
the GIGA (middle) was setup to use the full 800x480

But good to see it working
 
Not sure if we can use the WIFI board from Sparkfun with the 8080 interface because of pin conflicts. But maybe if we used the new @KenHahn devices (which I need to order still) maybe that would work.
The Teensy 4.1/ESP32 stacks only need to use either Teensy D0/D1 (serial1) or D20/D21(serial5) for the serial interface, so it looks like it should work for either 8-bit or 16-bit. Just need to use Serial1 on the Teensy 4.1 to free up pins 20 & 21 to use 16-bit.
 
@wwatson @mjs513

I ran it and it works...

Question: @wwatson I know you have your sketch in your fork/main - which is one commit ahead of @mjs513 in the Teensy-wifi-Apps

Originally i checked out your fork/branch and then copied the sketch to different folder. At some point are you planning to PR it back
to @mjs513...

It will also be interesting to experiment using more space of the display:
View attachment 39861

Looks like it is currently same layout as the ST7796, like the one hooked up to the T41 stack (top), where as
the GIGA (middle) was setup to use the full 800x480

But good to see it working
Yes, I will do a PR. Not at home right now so it will be later. I need to pull out my GIGA and try it out...
 
Back
Top