
/*  flash_led.c
    Stephen D. Anderson --- July 30, 1994

    Part of tm40.c.  Used for testing hardware.  This function flashes 
the "power" and "xmit" LEDs on a PRIMM.  It also flashes the "trunk" 
LED on a PRIMMPLEX.  On entry it puts up a message saying that the LEDs 
are being flashed.  Then it goes into a loop that is stopped when a
key is pressed or mouse clicked.  Within the loop RTS and DTR are
turned ON to turn on the PRIMM LEDs.  Then 100 bytes of 0xff are
transmitted to turn on the PRIMMPLEX trunk LED.  RTS and DTR are then
turned OFF for 2 seconds.  A key press or mouse click is checked
every 0.5 second during this time.  On exit RTS is left OFF and DTR is
left ON for proper operation of the PRIMM.  The window announcing
LED flashing is closed.

    ON ENTRY:
    There are no arguments.

    ON EXIT:
    Nothing is returned.

    REVISION LOG:


*/

#include "tm40.h"

void flash_led()

{
    extern byte send[];
    extern COM com;

    int i;

    WpopUp(CNT_CNT,6,18,12,62,1,WHITE|_CYAN,WHITE|_CYAN);
    WputCen("\nFlashing LEDs");
    WputCen("\n\nHit any key to Continue");

    for (i=0; i<100; ++i) send[i]=0xff;  /*  set up send buffer. */

    while (!KeyEvent())
    {
        ComRts(com, 1);     /*  lights on.  */
        ComDtr(com, 1);

        ComOut(com, send, 100);
        /*  wait until done or key pressed. */
        while (ComLenTx(com)) {if (KeyEvent()) break;}
        ComTxWait(com);

        ComRts(com, 0);     /*  lights off. */
        ComDtr(com, 0);

        /*  delay 2 seconds if key not pressed. */
        if (!KeyEvent()) delay(500);
        if (!KeyEvent()) delay(500);
        if (!KeyEvent()) delay(500);
        if (!KeyEvent()) delay(500);

    }
    /*  leave RTS off and DTR on at exit. */
    ComRts(com, 0);
    ComDtr(com, 1);
    Wclose();
}

