/*----------------------------------------------------------------------------
**
**	Sensors.c 
**	
**  Read the various sensors (apart from wheel speed which is done in 
** motion.c), and apply any necessary filetering.
**
**--------------------------------------------------------------------------*/
                    
#include "Hardware.h"
#include "Sensors.h"

// This global is available to all files.
char WhichWayUp = RIGHT_WAY_UP;

/*----------------------------------------------------------------------------
//
//  MercurySwitch
//      
// This function is called every 10ms, so filtering can make use of this.
//  
// Modification Record:
//  24-Jul-00   Paul Hills      First version
-----------------------------------------------------------------------------*/
void MercurySwitch(void)
{                  
    static int Value = 50;
    
    if (WHICH_WAY_UP == RIGHT_WAY_UP)
    {
        if (++Value > 100)
        {
            WhichWayUp = RIGHT_WAY_UP;
            Value = 100;
        }
    }
    else
    {
        if (--Value < 0)
        {
            WhichWayUp = UPSIDE_DOWN;
            Value = 0;
        }
    }                
}


/*----------------------------------------------------------------------------
//
//  ProcessSensors
//      
// This function is called every 10ms, so filtering can make use of this.
//  
// Modification Record:
//  24-Jul-00   Paul Hills      First version
-----------------------------------------------------------------------------*/
void ProcessSensors(void)
{   
    MercurySwitch();    
}