Adafruit graphics library, blocking sketch and missing transmission...

I have a mega with a 3.5 inch tft shield. It takes about 500 mS to update the text on it, but that is OK with me.

Attached on the SPI is the NRF24L module, an RF modem that listens to strings of data from the sender.
The sender is not included here.

All the data comes fine if it is spaced about 500mS apart.
But if the data comes fast, like every 5 mS , the Arduino is missing the receiving as it is busy updating the TFT.

What to do? I heard about software interrupts.... I would love to stop the TFT updates and get my data in, and then continue. Is that doable?

here is the code.
I commented the TFT update and it works fine
/*
tft.fillRect(0, 60, 480, 300, BLUE);
tft.setTextSize(4);
etc.

If it is un-commented then I face the missed transmissions.

thanks
Mitch

INFINITY_Receiver_03.ino (5.44 KB)

Please post your code in-line using Code Tags.

#include <LibPrintf.h>
#include <RF24.h>
#include <RF24Network.h>
#include <SPI.h>
RF24 radio(48, 53);// nRF24L01 (CE,CSN)
RF24Network network(radio);

const uint16_t this_node = 00;   // Address of our node in Octal format ( 04,031, etc)


# define TestPin 49


int var = 0;
String The_Last = "-------";
String B_Last = "-------";
String BB_Last = "-------";
String BBB_Last = "-------";
String BBBB_Last = "-------";
String BBBBB_Last = "-------";

float AVG_CUT, AVG_MFG, PARTS_MADE;
String AVG_CUT_STR, AVG_MFG_STR, PARTS_MADE_STR, MSG_STR ;

String MACH_ID;
String PeriodMillis_STR;
int PeriodMillis;
long TR_SEQ = 1; // Transmission sequence, transmission id.
//////////////////////////TFT
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
//#include <Fonts/FreeSansBold24pt7b.h>


#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0

#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin


// Assign human-readable names to some common 16-bit color values:
#define  BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);




void setup() {
  Serial.begin(115200);
  // Serial.print("TFT size is "); Serial.print(tft.width()); Serial.print("x"); Serial.println(tft.height());

  uint16_t identifier = tft.readID();
  if (identifier == 0x9325) {

  } else {
    // Serial.print(F("Unknown LCD driver chip: "));
    // Serial.println(identifier, HEX);

    identifier = 0x9341;

  }

  tft.begin(identifier);

  // testFillScreen();
  tft.setRotation(1);  //0 is portrait , 1 is lanscape, 2 portrait upside down, 3 is lanscape reversed
  tft.setCursor(1, 1);
  //tft.println();
  tft.fillScreen(BLACK);
  tft.setCursor(10, 110);
  //tft.println();
  tft.setTextColor(GREEN);
  tft.setTextSize(4);
  tft.print("AWAITING SIGNAL ");

  SPI.begin();
  radio.begin();
  if (!radio.begin()) {
    Serial.println(F("radio hardware is not responding!!"));
    while (1) {} // hold in infinite loop
  }
  else
  { Serial.println ("Radio OK");
  }
  network.begin(90, this_node); //(channel, node address)
  // network.begin(80, this_node); //(channel, node address)
  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_2MBPS);


  pinMode(TestPin, INPUT_PULLUP);

  Serial.print("This node is OK : ");
  Serial.println(this_node);
  //tft.setTextColor(YELLOW);
  //tft.setTextSize(4);
  //tft.setCursor(10, 10);
  //tft.print("NODE OK:");
  tft.setCursor(290, 10);
  tft.print(this_node);
  tft.setCursor(0, 210);
  //tft.println();
  tft.setTextColor(GREEN);
  tft.setTextSize(2.5);
  tft.println("Data Collector by Machine-Cycle.US");
  tft.println("");
  tft.print("Ver. INFINITY_Receiver_02 - APR 2021");
  delay (2000);

  tft.setTextColor(YELLOW);
  tft.setTextSize(4);
  tft.setCursor(10, 10);
  tft.print("RECEIVED:");
}
void loop() {
  ///////////////////Test section

  if (digitalRead (TestPin) == 0) // button is pushed
  { //
    tft.fillScreen(BLACK);
    // tft.print(IncStrR1);
    tft.setCursor(10, 10);
    tft.setTextColor(GREEN);
    tft.print("TEST OUTPUT");
    String Mach_ID [32] = {"1", "2",  "3" , "4", "5" , "6", "7", "8",  "9"};

    for (int i = 0; i <= 10; i++) {

      String TestOut = Mach_ID [i] + " " + (i + 10) + " " + "3" + " " + "OPR" + " " + "INFO" + " ";
      Serial.println(TestOut);
      delay(10);
      if (i = 10)
      
      { The_Last = "-------";
        B_Last = "-------";
        BB_Last = "-------";
        BBB_Last = "-------";
        BBBB_Last = "-------";
        BBBBB_Last = "-------";
      }
    }// end for loop
    tft.fillScreen(BLACK);
    tft.setCursor(10, 10);
    tft.print("AWAITING SIGNAL");
  } // end test


  else
  {
    network.update();
    while ( network.available() ) {
      RF24NetworkHeader header;
      char text[32] = "";
      network.read(header, &text, sizeof(text)); // Read the incoming data
      String End = "End";
      The_Last = text; //+End;  // converting the Char array to string c.
      //The_Last = The_Last.substring(0, The_Last.length() - 1);
      Serial.println(The_Last);
/*
      
      tft.fillRect(0, 60, 480, 300, BLUE);
      tft.setTextSize(4);
      tft.setCursor(10, 70);
      tft.print (The_Last);
      tft.setCursor(10, 110);
      tft.print (B_Last);
      tft.setCursor(10, 150);
      tft.print (BB_Last);
      tft.setCursor(10, 190);
      tft.print (BBB_Last);
      tft.setCursor(10, 230);
      tft.print (BBBB_Last);
      tft.setCursor(10, 270);
      tft.print (BBBBB_Last);

      BBBBB_Last = BBBB_Last;
      BBBB_Last = BBB_Last;
      BBB_Last = BB_Last;
      BB_Last = B_Last;
      B_Last = The_Last;
*/
    }
  } // end of else

Can you explain what you'd do with the data received faster than it can be displayed?

I've never used RF24Network, just Single Master to Multiple Slaves. With that setup I only need the RF24.h library. It supports interrupts (IRQ pin on module) and non-blocking techniques. Look up the following functions in RF24.h:
startWrite()
whatHappened()
isAckPayloadAvailable()
getDynamicPayloadSize()
read()

Blackfin:
Can you explain what you'd do with the data received faster than it can be displayed?

I had that question too.

Add a processor to run the screen. A thumb size teensy is perfect for the job.

-jim lee

Thanks everyone, I will explore the IRQ function in the NRF library.

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