Combine sd card sketch into LED scoller sketch

Im a noob to Arduino programming, I would like to combine sd card sketch into an existing LED scroller sketch, below is my working LED scroll sketch without the sd card code.
On line 255 and 256 it gives " HELLO WORLD " " SAMPLE TEXT " being the wording that appears on the LED display, I want to relocate those words onto an sd card

#define PIXELS 60*1.6

#define PIXEL_PORT  PORTD  
#define PIXEL_DDR   DDRD   

static const uint8_t onBits=0b11111110;                                  

#define T1H  814    
#define T1L  438    

#define T0H  312    
#define T0L  936    



#define RES 500000   



#define NS_PER_SEC (1000000000L)          

#define CYCLES_PER_SEC (F_CPU)

#define NS_PER_CYCLE ( NS_PER_SEC / CYCLES_PER_SEC )

#define NS_TO_CYCLES(n) ( (n) / NS_PER_CYCLE )

static inline void sendBitx8(  const uint8_t row , const uint8_t colorbyte , const uint8_t onBits ) {  
              
    asm volatile (


      "L_%=: \n\r"  
      
      "out %[port], %[onBits] \n\t"                

      
      "mov r0, %[bitwalker] \n\t"                  
      "and r0, %[colorbyte] \n\t"                   
      "breq OFF_%= \n\t"                          

      
      "nop \n\t  "                                 
      "out %[port], %[row]   \n\t"                  
                                                   
                                                    


      "nop \n\t nop \n\t "                          
      "nop \n\t nop \n\t "                           
      "nop \n\t nop \n\t "                           
      "nop \n\t "                                 

      "out %[port], __zero_reg__ \n\t"              
                                                   
                                                    
                                                    
      "ror %[bitwalker] \n\t"                      
                  
      "brcs DONE_%= \n\t"                          
      "nop \n\t \n\t "                          
            
      "jmp L_%= \n\t"                             
                                                  
                                               
                                               
                                                   
                                                          
      "OFF_%=: \n\r"                            

      "out %[port], __zero_reg__ \n\t"              
                                                   
                                                    

      "ror %[bitwalker] \n\t"                      
                  
      "brcs DONE_%= \n\t"                          

      "nop \n\t nop \n\t "                          
      "nop \n\t nop \n\t "                          
      "nop \n\t nop \n\t "                                
      "nop \n\t nop \n\t "                                      
      "nop \n\t "                                               
            
      "jmp L_%= \n\t"                                
                                                       
                                                   
                                                   
      
            
      "DONE_%=: \n\t"

 
    
      ::
      [port]    "I" (_SFR_IO_ADDR(PIXEL_PORT)),
      [row]   "d" (row),
      [onBits]   "d" (onBits),
      [colorbyte]   "d" (colorbyte ),                     
      [bitwalker] "r" (0x80)                      

    );
                                  
    
    
}



void show() {
  delayMicroseconds( (RES / 1000UL) + 1);    
}



static inline void sendRowRGB( uint8_t row ,  uint8_t r,  uint8_t g,  uint8_t b ) {

  sendBitx8( row , g , onBits);    
  sendBitx8( row , r , onBits);
  sendBitx8( row , b , onBits);    
 
}

#define FONT_WIDTH 5      
#define INTERCHAR_SPACE 1
#define ASCII_OFFSET 0x20    

const uint8_t Font5x7[] PROGMEM = {
0x00,0x00,0x00,0x00,0x00,//  
0x00,0x00,0xfa,0x00,0x00,// !
0x00,0xe0,0x00,0xe0,0x00,// "
0x28,0xfe,0x28,0xfe,0x28,// #
//0x24,0x54,0xfe,0x54,0x48,// $ // default
0x12,0x7e,0x92,0x92,0x42,// $  //this is £
0xc4,0xc8,0x10,0x26,0x46,// %
0x6c,0x92,0xaa,0x44,0x0a,// &
0x00,0xa0,0xc0,0x00,0x00,// '
0x00,0x38,0x44,0x82,0x00,// (
0x00,0x82,0x44,0x38,0x00,// )
0x10,0x54,0x38,0x54,0x10,// *
0x10,0x10,0x7c,0x10,0x10,// +
0x00,0x0a,0x0c,0x00,0x00,// ,
0x10,0x10,0x10,0x10,0x10,// -
0x00,0x06,0x06,0x00,0x00,// .
0x04,0x08,0x10,0x20,0x40,// /
0x7c,0x8a,0x92,0xa2,0x7c,// 0
0x00,0x42,0xfe,0x02,0x00,// 1
0x42,0x86,0x8a,0x92,0x62,// 2
0x84,0x82,0xa2,0xd2,0x8c,// 3
0x18,0x28,0x48,0xfe,0x08,// 4
0xe4,0xa2,0xa2,0xa2,0x9c,// 5
0x3c,0x52,0x92,0x92,0x0c,// 6
0x80,0x8e,0x90,0xa0,0xc0,// 7
0x6c,0x92,0x92,0x92,0x6c,// 8
0x60,0x92,0x92,0x94,0x78,// 9
0x00,0x6c,0x6c,0x00,0x00,// :
0x00,0x6a,0x6c,0x00,0x00,// ;
0x00,0x10,0x28,0x44,0x82,// <
0x28,0x28,0x28,0x28,0x28,// =
0x82,0x44,0x28,0x10,0x00,// >
0x40,0x80,0x8a,0x90,0x60,// ?
0x4c,0x92,0x9e,0x82,0x7c,// @
0x7e,0x88,0x88,0x88,0x7e,// A
0xfe,0x92,0x92,0x92,0x6c,// B
0x7c,0x82,0x82,0x82,0x44,// C
0xfe,0x82,0x82,0x44,0x38,// D
0xfe,0x92,0x92,0x92,0x82,// E
0xfe,0x90,0x90,0x80,0x80,// F
0x7c,0x82,0x82,0x8a,0x4c,// G
0xfe,0x10,0x10,0x10,0xfe,// H
0x00,0x82,0xfe,0x82,0x00,// I
0x04,0x02,0x82,0xfc,0x80,// J
0xfe,0x10,0x28,0x44,0x82,// K
0xfe,0x02,0x02,0x02,0x02,// L
0xfe,0x40,0x20,0x40,0xfe,// M
0xfe,0x20,0x10,0x08,0xfe,// N
0x7c,0x82,0x82,0x82,0x7c,// O
0xfe,0x90,0x90,0x90,0x60,// P
0x7c,0x82,0x8a,0x84,0x7a,// Q
0xfe,0x90,0x98,0x94,0x62,// R
0x62,0x92,0x92,0x92,0x8c,// S
0x80,0x80,0xfe,0x80,0x80,// T
0xfc,0x02,0x02,0x02,0xfc,// U
0xf8,0x04,0x02,0x04,0xf8,// V
0xfe,0x04,0x18,0x04,0xfe,// W
0xc6,0x28,0x10,0x28,0xc6,// X
0xc0,0x20,0x1e,0x20,0xc0,// Y
0x86,0x8a,0x92,0xa2,0xc2,// Z
0x00,0x00,0xfe,0x82,0x82,// [
0x40,0x20,0x10,0x08,0x04,// (backslash)
0x82,0x82,0xfe,0x00,0x00,// ]
0x20,0x40,0x80,0x40,0x20,// ^
0x02,0x02,0x02,0x02,0x02,// _
0x00,0x80,0x40,0x20,0x00,// `
0x04,0x2a,0x2a,0x2a,0x1e,// a
0xfe,0x12,0x22,0x22,0x1c,// b

0x12,0x2a,0x2a,0x2a,0x04,// s

0x00,0x10,0x6c,0x82,0x00,// {
0x00,0x00,0xfe,0x00,0x00,// |
0x00,0x82,0x6c,0x10,0x00,// }
0x10,0x10,0x54,0x38,0x10,// ~
0x10,0x38,0x54,0x10,0x10,// 
};


static inline void sendChar( uint8_t c ,  uint8_t skip , uint8_t r,  uint8_t g,  uint8_t b ) {

  const uint8_t *charbase = Font5x7 + (( c -' ')* FONT_WIDTH ) ;

  uint8_t col=FONT_WIDTH;

  while (skip--) {
      charbase++;
      col--;    
  }
 
  while (col--) {
      sendRowRGB( pgm_read_byte_near( charbase++ ) , r , g , b );
  }    
 
  col=INTERCHAR_SPACE;
 
  while (col--) {

    sendRowRGB( 0 , r , g , b );    // Interchar space
    
  }
 
}


static inline void sendString( const char *s , uint8_t skip ,  const uint8_t r,  const uint8_t g,  const uint8_t b ) {

  unsigned int l=PIXELS/(FONT_WIDTH+INTERCHAR_SPACE);

  sendChar( *s , skip ,  r , g , b );   // First char is special case becuase it can be stepped for smooth scrolling
 
  while ( *(++s) && l--) {

    sendChar( *s , 0,  r , g , b );

  }

  show();
}

void setup() {
  PIXEL_DDR |= onBits;         // Set used pins to output mode
}

static char jabberText[] =
       
     " HELLO WORLD "
     " SAMPLE TEXT "
     ;

void loop() {
 
  const char *m = jabberText;
              
  while (*m) {      


      for( uint8_t step=0; step<FONT_WIDTH+INTERCHAR_SPACE  ; step++ ) {   // step though each column of the 1st char for smooth scrolling

         cli();
 
      
 
         sendString( m , step , 0x00, 0x00 , 0x40 );    // Nice and not-too-bright blue hue default//peaks at 3.27 amps over 1.6m
     
        
         sei();
         
      
         _delay_ms(25);   // this is best in vertical
    
 
      }

    m++;

  }


}

below is my basic sd card sketch which I have attempted to drop into the above sketch, all advice is much appreciated.

#include <SD.h>
#include <SPI.h>

int CS_PIN = 10;

File jabberText;

void setup()
{

  Serial.begin(9600);

  initializeSD();

  openFile("test.txt");
  Serial.println(readLine());

}

void loop() { 
  
}

void initializeSD()
{
  //Serial.println("Initializing SD card...");
  pinMode(CS_PIN, OUTPUT);

  if (SD.begin())
  {
    return;
  }
}



int openFile(char filename[])
{
  jabberText = SD.open(filename);
  if (jabberText)
  {
    //Serial.println("File opened with success!");
    return 1;
  } else
  {
    Serial.println("Error opening file...");
    return 0;
  }
}

String readLine()
{
  String received = "";
  char ch;
  while (jabberText.available())
  {
    ch = jabberText.read();
    if (ch == '\n')
    {
      return String(received);
    }
    else
    {
      received += ch;
    }
  }
  return "";
}

which I have attempted to drop into the above sketch

Where? How? With what results?

#define PIXEL_PORT  PORTD

Do you know which pins this corresponds to?

      return String(received);

received was already a String. There is no reason to create ANOTHER String instance to return.

I only see one call to readLine(), and you don't actually do anything useful with the one String you get.

Thanks for getting back so quickly, I am using an uno port D, the led WS2812B strips are connected to 7 pins those being 1-7 so pin 0 is unused, I have my sd card connected to pin 10.

Here below is my attempt at converging the two sketches but i,m rather clueless to be honest, the below sketch provides the expected output on the serial monitor off the sd card but I had to comment out most of the void loop (the speed and brightness on lines 286 to 308) to get it to compile, thanks in advance.

#include <SD.h>
#include <SPI.h>

const int CSpin = 10;




#define PIXELS 60*1.6

#define PIXEL_PORT  PORTD  
#define PIXEL_DDR   DDRD   

static const uint8_t onBits=0b11111110;                                  

#define T1H  814    
#define T1L  438    

#define T0H  312    
#define T0L  936    



#define RES 500000   



#define NS_PER_SEC (1000000000L)          

#define CYCLES_PER_SEC (F_CPU)

#define NS_PER_CYCLE ( NS_PER_SEC / CYCLES_PER_SEC )

#define NS_TO_CYCLES(n) ( (n) / NS_PER_CYCLE )

static inline void sendBitx8(  const uint8_t row , const uint8_t colorbyte , const uint8_t onBits ) {  
              
    asm volatile (


      "L_%=: \n\r"  
      
      "out %[port], %[onBits] \n\t"                

      
      "mov r0, %[bitwalker] \n\t"                  
      "and r0, %[colorbyte] \n\t"                   
      "breq OFF_%= \n\t"                          

      
      "nop \n\t  "                                 
      "out %[port], %[row]   \n\t"                  
                                                   
                                                    


      "nop \n\t nop \n\t "                          
      "nop \n\t nop \n\t "                           
      "nop \n\t nop \n\t "                           
      "nop \n\t "                                 

      "out %[port], __zero_reg__ \n\t"              
                                                   
                                                    
                                                    
      "ror %[bitwalker] \n\t"                      
                  
      "brcs DONE_%= \n\t"                          
      "nop \n\t \n\t "                          
            
      "jmp L_%= \n\t"                             
                                                  
                                               
                                               
                                                   
                                                          
      "OFF_%=: \n\r"                            

      "out %[port], __zero_reg__ \n\t"              
                                                   
                                                    

      "ror %[bitwalker] \n\t"                      
                  
      "brcs DONE_%= \n\t"                          

      "nop \n\t nop \n\t "                          
      "nop \n\t nop \n\t "                          
      "nop \n\t nop \n\t "                                
      "nop \n\t nop \n\t "                                      
      "nop \n\t "                                               
            
      "jmp L_%= \n\t"                                
                                                       
                                                   
                                                   
      
            
      "DONE_%=: \n\t"

 
    
      ::
      [port]    "I" (_SFR_IO_ADDR(PIXEL_PORT)),
      [row]   "d" (row),
      [onBits]   "d" (onBits),
      [colorbyte]   "d" (colorbyte ),                     
      [bitwalker] "r" (0x80)                      

    );
                                  
    
    
}



void show() {
  delayMicroseconds( (RES / 1000UL) + 1);    
}



static inline void sendRowRGB( uint8_t row ,  uint8_t r,  uint8_t g,  uint8_t b ) {

  sendBitx8( row , g , onBits);    
  sendBitx8( row , r , onBits);
  sendBitx8( row , b , onBits);    
 
}

#define FONT_WIDTH 5      
#define INTERCHAR_SPACE 1
#define ASCII_OFFSET 0x20    

const uint8_t Font5x7[] PROGMEM = {
0x00,0x00,0x00,0x00,0x00,//  
0x00,0x00,0xfa,0x00,0x00,// !
0x00,0xe0,0x00,0xe0,0x00,// "
0x28,0xfe,0x28,0xfe,0x28,// #
//0x24,0x54,0xfe,0x54,0x48,// $ // default
0x12,0x7e,0x92,0x92,0x42,// $  //this is £
0xc4,0xc8,0x10,0x26,0x46,// %
0x6c,0x92,0xaa,0x44,0x0a,// &
0x00,0xa0,0xc0,0x00,0x00,// '
0x00,0x38,0x44,0x82,0x00,// (
0x00,0x82,0x44,0x38,0x00,// )
0x10,0x54,0x38,0x54,0x10,// *
0x10,0x10,0x7c,0x10,0x10,// +
0x00,0x0a,0x0c,0x00,0x00,// ,
0x10,0x10,0x10,0x10,0x10,// -
0x00,0x06,0x06,0x00,0x00,// .
0x04,0x08,0x10,0x20,0x40,// /
0x7c,0x8a,0x92,0xa2,0x7c,// 0
0x00,0x42,0xfe,0x02,0x00,// 1
0x42,0x86,0x8a,0x92,0x62,// 2
0x84,0x82,0xa2,0xd2,0x8c,// 3
0x18,0x28,0x48,0xfe,0x08,// 4
0xe4,0xa2,0xa2,0xa2,0x9c,// 5
0x3c,0x52,0x92,0x92,0x0c,// 6
0x80,0x8e,0x90,0xa0,0xc0,// 7
0x6c,0x92,0x92,0x92,0x6c,// 8
0x60,0x92,0x92,0x94,0x78,// 9
0x00,0x6c,0x6c,0x00,0x00,// :
0x00,0x6a,0x6c,0x00,0x00,// ;
0x00,0x10,0x28,0x44,0x82,// <
0x28,0x28,0x28,0x28,0x28,// =
0x82,0x44,0x28,0x10,0x00,// >
0x40,0x80,0x8a,0x90,0x60,// ?
0x4c,0x92,0x9e,0x82,0x7c,// @
0x7e,0x88,0x88,0x88,0x7e,// A
0xfe,0x92,0x92,0x92,0x6c,// B
0x7c,0x82,0x82,0x82,0x44,// C
0xfe,0x82,0x82,0x44,0x38,// D
0xfe,0x92,0x92,0x92,0x82,// E
0xfe,0x90,0x90,0x80,0x80,// F
0x7c,0x82,0x82,0x8a,0x4c,// G
0xfe,0x10,0x10,0x10,0xfe,// H
0x00,0x82,0xfe,0x82,0x00,// I
0x04,0x02,0x82,0xfc,0x80,// J
0xfe,0x10,0x28,0x44,0x82,// K
0xfe,0x02,0x02,0x02,0x02,// L
0xfe,0x40,0x20,0x40,0xfe,// M
0xfe,0x20,0x10,0x08,0xfe,// N
0x7c,0x82,0x82,0x82,0x7c,// O
0xfe,0x90,0x90,0x90,0x60,// P
0x7c,0x82,0x8a,0x84,0x7a,// Q
0xfe,0x90,0x98,0x94,0x62,// R
0x62,0x92,0x92,0x92,0x8c,// S
0x80,0x80,0xfe,0x80,0x80,// T
0xfc,0x02,0x02,0x02,0xfc,// U
0xf8,0x04,0x02,0x04,0xf8,// V
0xfe,0x04,0x18,0x04,0xfe,// W
0xc6,0x28,0x10,0x28,0xc6,// X
0xc0,0x20,0x1e,0x20,0xc0,// Y
0x86,0x8a,0x92,0xa2,0xc2,// Z
0x00,0x00,0xfe,0x82,0x82,// [
0x40,0x20,0x10,0x08,0x04,// (backslash)
0x82,0x82,0xfe,0x00,0x00,// ]
0x20,0x40,0x80,0x40,0x20,// ^
0x02,0x02,0x02,0x02,0x02,// _
0x00,0x80,0x40,0x20,0x00,// `
0x04,0x2a,0x2a,0x2a,0x1e,// a
0xfe,0x12,0x22,0x22,0x1c,// b

0x12,0x2a,0x2a,0x2a,0x04,// s

0x00,0x10,0x6c,0x82,0x00,// {
0x00,0x00,0xfe,0x00,0x00,// |
0x00,0x82,0x6c,0x10,0x00,// }
0x10,0x10,0x54,0x38,0x10,// ~
0x10,0x38,0x54,0x10,0x10,// 
};


static inline void sendChar( uint8_t c ,  uint8_t skip , uint8_t r,  uint8_t g,  uint8_t b ) {

  const uint8_t *charbase = Font5x7 + (( c -' ')* FONT_WIDTH ) ;

  uint8_t col=FONT_WIDTH;

  while (skip--) {
      charbase++;
      col--;    
  }
 
  while (col--) {
      sendRowRGB( pgm_read_byte_near( charbase++ ) , r , g , b );
  }    
 
  col=INTERCHAR_SPACE;
 
  while (col--) {

    sendRowRGB( 0 , r , g , b );    // Interchar space
    
  }
 
}


static inline void sendString( const char *s , uint8_t skip ,  const uint8_t r,  const uint8_t g,  const uint8_t b ) {

  unsigned int l=PIXELS/(FONT_WIDTH+INTERCHAR_SPACE);

  sendChar( *s , skip ,  r , g , b );   // First char is special case becuase it can be stepped for smooth scrolling
 
  while ( *(++s) && l--) {

    sendChar( *s , 0,  r , g , b );

  }

  show();
}

File myFile;
void InitializeSDcard();

void setup() {
  PIXEL_DDR |= onBits;         // Set used pins to output mode
   pinMode(CSpin, OUTPUT);
 Serial.begin(9600);
 InitializeSDcard();

 
 OpenFile("test.txt");
 while (myFile.available()) {
 String list = myFile.readStringUntil('\r');
 Serial.println(list);
 }
}

//static char jabberText[] =
       
    // " HELLO WORLD "
    // " SAMPLE TEXT "
  //   ;

void loop() {
 
//const char *m = jabberText;
 //static char *m = myFile;
//String *m = myFile;
  File();            
//  while (*m) {      
//
//
//      for( uint8_t step=0; step<FONT_WIDTH+INTERCHAR_SPACE  ; step++ ) {   
//
//         cli();
// 
//      
// 
//         sendString( m , step , 0x00, 0x00 , 0x40 );    // Nice and not-too-bright blue hue default//peaks at 3.27 amps over 1.6m
//     
//        
//         sei();
//         
//      
//         _delay_ms(25);   
//    
// 
//      }
//
//    m++;
//
//  }

    return;

}

void InitializeSDcard(){
  Serial.println("Opening SD Card . . .");
  delay(500);
  if(SD.begin(CSpin))
  {
    Serial.println("SD Card ready to use");
  }else{
    Serial.println("Failed to open SD Card");
    return;
  }
}

int OpenFile(char Filename[]){
  myFile = SD.open(Filename, FILE_WRITE);
  myFile = SD.open(Filename, FILE_READ);
  delay(500);
  if(myFile)
  {
    Serial.println("File is open");
    return 1;
  }else{
    Serial.println("Error opening file");
    return 0;
  }
}

I am using an uno port D

My reading comprehension skills are good enough that I knew that. What I want to know is whether you know which physical pins that corresponds to, in terms of the numbers printed next to the pins.

  File();

File is a type (class). Calling the constructor explicitly is generally not a good idea. Throwing away the results is definitely a bad idea.

Now, you read the entire file, one record at a time, in setup(), but do nothing with the text read from the file, with respect to getting it onto the display.

I had to comment out most of the void loop (the speed and brightness on lines 286 to 308) to get it to compile

What were the errors?

The value you want to pass to sendString(), in loop(), is the value you read from the file. But, you read the file in setup(), and tossed the data into the bitbucket, so you can't do that.

Create a function, displayLine(). In loop(), open the file, read a record, pass it to displayLine(), and repeat, until there are no more records. Then, close the file.

Of course, loop() will open the file again and do the whole thing all over again. So, you might want to leave loop empty, and call displayLine() from setup().

the sd card holder is this one…
https://www.ebay.co.uk/itm/Micro-SD-Card-Module-Slot-Socket-Reader-for-ARM-PIC-MCU-Arduino-Robot-UK-A904/161620434019?hash=item25a1541c63:g:WiQAAOSw6HJZ2jEp
connected…
MISO to digital pin 12
MOSI to digital pin 11
SCK to digital pin 13
CS to digital pin 10
5v to 5v
Gnd to Gnd

my uno is connected to led WS2812b
on digital pins 1 through to 7

did you mean I should insert into the sketch

void displayLine()
{
     cout << "----------------" << end1;
}   //end of displayline function

sorry I,m not very good at this could you elaborate thanks in advance

did you mean I should insert into the sketch

Did that compile? If so, then, yes, put that in your sketch. Then, put the code that actually displays the data on the display in that function. Then, call that function as appropriate.

my uno is connected to led WS2812b
on digital pins 1 through to 7

And yet you are still using Serial, which is an instance of the HardwareSerial class that uses digital pins 0 and 1. Well, OK.