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);
}