/***************************************************/ /* COP libray based on the NexT Byte Codes library */ /***************************************************/ /*****************************************************************************/ /* SensorAPI */ /*****************************************************************************/ /* IN_MODE_RAW 0x00 */ /* IN_MODE_BOOLEAN 0x20 */ /* IN_MODE_TRANSITIONCNT 0x40 */ /* IN_MODE_PERIODCOUNTER 0x60 */ /* IN_MODE_PCTFULLSCALE 0x80 */ /* IN_MODE_CELSIUS 0xA0 */ /* IN_MODE_FAHRENHEIT 0xC0 */ /* IN_MODE_ANGLESTEP 0xE0 */ /* IN_MODE_SLOPEMASK 0x1F */ /* IN_MODE_MODEMASK 0xE0 */ /**/ /**/ /**/ /*******************************/ /* this function initializes */ /* all sensors */ /* */ /*******************************/ void COP_InitSensors(void) { /* touch */ inline "SetSensorTouch(0x00)"; inline "SetSensorMode(0x00,0x20)"; inline "ClearSensor(0x00)"; /* sound */ inline "SetSensorSound(0x01)"; inline "SetSensorMode(0x01,0x00)"; inline "ClearSensor(0x01)"; /* light */ inline "SetSensorLight(0x02)"; inline "SetSensorMode(0x02,0x00)"; inline "ClearSensor(0x02)"; /* ultrasonic */ inline "SetSensorUltrasonic(0x03)"; inline "SetSensorMode(0x03,0x00)"; inline "ClearSensor(0x03)"; } void COP_SetSensorModeSound_pct(void) { inline "SetSensorMode(0x01,0x80)"; } void COP_SetSensorModeSound_raw(void) { inline "SetSensorMode(0x01,0x00)"; } void COP_SetSensorModeLight_pct(void) { inline "SetSensorMode(0x02,0x80)"; } void COP_SetSensorModeLight_raw(void) { inline "SetSensorMode(0x02,0x00)"; } void COP_SetSensorModeUltraSonic_pct(void) { inline "SetSensorMode(0x03,0x80)"; } void COP_SetSensorModeUltraSonic_raw(void) { inline "SetSensorMode(0x03,0x00)"; } /**/ /**/ /**/ /*******************************/ /* this function reads the */ /* current value of the */ /* microphone */ /*******************************/ int COP_ReadSoundDetector(void) { int value; /* IN_2 */ inline "ReadSensor(0x01,COP_ReadSoundDetector_value)"; return(value); } /**/ /**/ /**/ /*******************************/ /* this function reads the */ /* current value of the */ /* ultrasonic captor */ /*******************************/ int COP_ReadUltraSonicDetector(void) { int value; /* IN_4 */ inline "ReadSensorUS(0x03,COP_ReadUltraSonicDetector_value)"; return(value); } /**/ /**/ /**/ /*******************************/ /* this function reads the */ /* current value of the */ /* light detector */ /*******************************/ int COP_ReadLightDetector(void) { int value; /* IN_3 */ inline "ReadSensor(0x02,COP_ReadLightDetector_value)"; return(value); } /**/ /**/ /**/ /*******************************/ /* this function reads the */ /* current value of the */ /* touch detector */ /*******************************/ int COP_ReadTouchDetector(void) { int value; /* IN_1 */ inline "ReadSensor(0x00,COP_ReadTouchDetector_value)"; return(value); } /**/ /**/ /**/ /*******************************/ /* this function resets the */ /* sensor */ /*******************************/ void COP_ResetTouchDetector(void) { inline "ResetSensor(0x00)"; } void COP_ResetSoundDetector(void) { inline "ResetSensor(0x01)"; } void COP_ResetLightDetector(void) { inline "ResetSensor(0x02)"; } void COP_ResetUltraSonicDetector(void) { inline "ResetSensor(0x03)"; }