/************************************************************************

        Title: MIRSVシステム 赤外線モード
        
        File : PS_MODE.C        Ver.1.0  written on Jan.26,1996 by J.W.
                                Ver.1.1             Feb.6,1996
                                
*************************************************************************/
#include "m9401.h"
#include "mathf.h"

extern int Ps_d;
extern float Th;
extern float Th_ref;
extern int flag;
extern int mode;
extern int Act; /* 0:strait 1:turn_left 2:turn_right 3:back 4:stop */

int ps_mode()
{
        static int Pc;
        flag=OFF;
        if(Ps_d==0x01 || Ps_d==0x07){ /* center PS */
                Act=5;
                Pc=0;
        }
        else if(Ps_d==0x02 || Ps_d==0x03){ /* left PS */
                Act=1;
                Pc=0;
        }
        else if(Ps_d==0x04 || Ps_d==0x05){ /* right PS */
                Act=2;
                Pc=0;
        }
        else {
                ++Pc;
                if (Pc>60){
                        flag=ON;
                        mode=NOMAL;
                }
        }
        return(flag);
}