almost there with my vga overlay

Thanks for everyones help last year, I have got my vga overlay thing sort of working, but still have some trouble with the queueing of the announcements/displays.

I have tried to simplify my pseudo program.

My setup is :-

I have a Holtek HT12 encoder/ RF link /decoder to send a door number from 1 to 9.

The VT ( valid transmission ) output from the decoder is my interrupt input that has a routine to decode the BCD data to decimal 1-9, and put that number in a queue.

This is done with the one "video" micro, that also handle the display with a SPI library.
There is a second "audio" micro that handles the announcements using WaveHC.h library and a SD card.

Once the announcement starts, it runs to the end of the track, and I use the "isplaying" signal to display the door number on the screen for that time.

The code below works, ( I have taken out or greyed most of the video side which is working fine ) its just the queueing again that I have a problem with.

It will play the track, but keeps repeating it, wherever I put the vtoutPin LOW to reset it.

Any ideas?? ( obviously with all the bits chopped out the curley braces will be wrong )

/* 
 VGA overlay generator 
 */
#include <FIFO.h>
#include <SPI.h>

volatile int bcda ; // define bcd digital inputs from HT12
volatile int bcdb;
volatile int bcdc;
volatile int bcdd;
// the VT valid transmission from the HT12 connects to pin4 to interrupt on RISING

volatile int door;    // door number to show and announce

int talking;     // LOW while audio running

/*int vb;          // part of display routine
int q = B11100000;   //part of display routine
*/
int aPin = A3; //binary data in from Holtek chip, representing door numbers 1 to 9
int bPin = A2;
int cPin = A1;
int dPin = A0;
/*int timingPin = 4;  // part of display routine
int windowPin = 6;  // part of display routine
*/
int runningPin = 12; // input from audio board, low when audio playing

int aoutPin = 10; //     queued bcd codes to audio board
int boutPin = 8;
int coutPin = 7;
int doutPin = 9;
int vtoutPin = 3;   // vt trigger to audio board to start playing,  audio board will play selected track from a SD card, 
        //and hold "running pin" LOW until track is finished.

FIFO<int,10> fifo; //store 10 ints

/////////////////////////////////////////////////////////
void setup ()   {

  pinMode (aoutPin, OUTPUT );
  pinMode (boutPin, OUTPUT );
  pinMode (coutPin, OUTPUT );
  pinMode (doutPin, OUTPUT );
  pinMode (vtoutPin, OUTPUT );
  pinMode (runningPin, INPUT );
  pinMode(aPin, INPUT);
  pinMode(bPin, INPUT);
  pinMode(cPin, INPUT);
  pinMode(dPin, INPUT);
 // pinMode(timingPin, INPUT);
  //pinMode(fsPin, INPUT);
  //pinMode(windowPin, OUTPUT );
  attachInterrupt(0, queue, RISING);   // interupt routine from vt input ht12 to load new number to queue

}
//////////////////////////////////////////////////

void loop () 
{
   int talking = digitalRead (runningPin ); // checks to see if audio is playing ( will be LOW if it is )
  if (talking == HIGH) {   
    
    if (fifo.count () > 0 )   //  sees if there are any unread numbers in queue subroutine
    {
      door = fifo.dequeue();  //  returns first unread number in queue

        if (door == 1){
        digitalWrite ( aoutPin, HIGH);   // Sends the door number in bcd to the audio micro -
           // I havnt got round to shortening this bit yet !
        digitalWrite ( boutPin, LOW);
        digitalWrite ( coutPin, LOW);
        digitalWrite ( doutPin, LOW);
      }  

     // and so on for doors 1 to 8

      if (door == 9){
        digitalWrite ( aoutPin, HIGH); 
        digitalWrite ( boutPin, LOW);
        digitalWrite ( coutPin, LOW);
        digitalWrite ( doutPin, HIGH);
      }  

    }
   digitalWrite ( vtoutPin, HIGH);   //  to audio board to begin announcement
  }

  ///////////////////////////////////////////////////////////////////////////////////////////

  //  all this is display routine 
   /*   case 16:  
        SPI.transfer(h); 
        SPI.transfer(q);  
        break;
         }
      break;

    }
    */
  ///////////////////////////////////////////////////////////////////////////////////////////  
     digitalWrite ( vtoutPin, LOW);  // resets the trigger to the audio micro, which goes on announcing for several seconds
     
     


}

void queue ()  {
  bcda = digitalRead ( aPin );  // check the state of the HT12 data outputs
  bcdb = digitalRead ( bPin );
  bcdc = digitalRead ( cPin );
  bcdd = digitalRead ( dPin );

  if (bcda==1 && bcdb==0 && bcdc == 0 && bcdd == 0 )
  {    
    door = 1;    }
    
    // and so on for doors 1 - 9
  
  if (bcda==1 && bcdb==0 && bcdc == 0 && bcdd == 1 ) {
    door = 9;
  }
  fifo.enqueue(door);
}

I have just tested the basic queue and dequeue functions in this little sketch and it works fine, so I don't know where my problem lies.....
unless I have to add some delay perhaps in the dequeue?

#include <FIFO.h>
int door;    
FIFO<int,10> fifo; //store 10 ints
/////////////////////////////////////////////////////////
void setup ()   {
  Serial.begin(9600);
  for( door= 9; door >5; door-- )
  {     
    fifo.enqueue(door);   
  }
}
///////////////////////////////////////////////////////
void loop () 
{
  if (fifo.count () > 0 )   //  sees if there are any unread numbers in queue subroutine
  {
    Serial.println ( "and now for the countdown" );
    door = fifo.dequeue();  //  returns first unread number in queue
    {
      Serial.println ( door );  // print current door number
      delay (200);
    }
  }
  if (fifo.count () == 0 ) {
    delay ( 5000 );  // waits 5 seconds and adds some more into queue
    door = 7;
    fifo.enqueue (door);
     door = 9;
    fifo.enqueue (door);
     door = 2;
    fifo.enqueue (door);
        
    }
  }

Is FIFO specifically written to be shared with an interrupt service routine?

These should be local to queue. At which point it is no longer necessary for them to be volatile...

volatile int bcda ; // define bcd digital inputs from HT12
volatile int bcdb;
volatile int bcdc;
volatile int bcdd;

At the moment I am using the ISR to receive and queue subsequent commands while the announcement is playing and showing.

Then when the audio track is finished, I want to check if there is anything in the queue,

The main loop has to refresh the video shift registers ( its a 1280 x 720 HD display I am syncing to ) and doesn't like too much extra work, or I lose sync...

But perhaps I will try looking for the vt input during the bottom half of the screen, where there is no video, and I have a spare 8 milliseconds to decode and queue it....

That idea ( dropping the interrupt ) didnt work, but I have tweaked the original and its now working, except it drops one message from the queue if there is more than 2 !

It will do for now while I get the pcb done as I am sure I can sort it out with the software.

Use direct port manipulation, you will gain something like 40-80 clock cycles between direct port access and the digitalWrite/Read functions.

Thanks, I have heard about direct port access, and had a quick look.
I am still a newbie and feeling my way round the normal arduino type simple stuff.

This project I am on is actually rather complicated for a beginner but a client saw my prototype and is pushing me for a working model, so I have to get this going asap.

Once I have that out I can rewrite the software at my leisure, if I don't get sidetracked by another project.............