Code: /*
RXMux Demo Program and Driver Written by Scott Briscoe 01/26/2008 Modified by Nitin Patil 02/05/2008 Modified by Scott Briscoe 11/03/2008
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Registry Information:
0x7E RXMux Address
0xFF No Channel 0xFE Channel 1 0xFd Channel 2 0xFB Channel 3 0xF7 Channel 4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ RXmuxChannel(const tSensors RXMuxPort, byte RXMuxChannel, TSensorTypes ChannelSensorType, TSensorModes ChannelSensorMode)
RXMuxPort: Port where RXMux is connected. RXMuxChannel: RXMux Channel you want to select. * use numbers 1 through 4 ChannelSensorType: Sensor type of the sensor on the chosen channel. * use RobotC defined sensor types * sensorReflection * sensorTouch * sensorTemperature * sensorRotation ChannelSensorMode: Sensor mode of the sensor on the chosen channel. * use RobotC defined sensor modes * modeBoolean * modeDummy * modeEdgeCount * modePercentage * modePulseCount * modeRaw * modeRotation * modeTemperatureC * modeTemperatureF
Example: RXmuxChannel(S1, 1, sensorReflection, modePercentage); Will set port S1 to a light sensor on channel 1 and set the port to read the sensor in percent mode.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
void RXmuxOff(const tSensors RXMuxPort) //Turn RXMux off, Channel 0 { SensorType[RXMuxPort] = sensorI2CCustom9V; byte RXMuxMSG[] = {2, 0x7E, 0xFF}; // Array message to send
while (nI2CStatus[RXMuxPort] == STAT_COMM_PENDING) { wait1Msec(2); // Wait for I2C bus to be ready } sendI2CMsg(RXMuxPort, RXMuxMSG[0], 0); // Send the message }
void RXmuxChannel(const tSensors RXMuxPort, byte RXMuxChannel, TSensorTypes ChannelSensorType,TSensorModes ChannelSensorMode) { if (RXMuxChannel==1) RXMuxChannel = 0xFE; //Set RXMux channel 1-4 else if (RXMuxChannel==2) RXMuxChannel = 0xFD; else if (RXMuxChannel==3) RXMuxChannel = 0xFB; else if (RXMuxChannel==4) RXMuxChannel = 0xF7;
SensorType[RXMuxPort] = sensorI2CCustom9V; byte RXMuxMSG[] = {2, 0x7E, RXMuxChannel}; // Array message to send
while (nI2CStatus[RXMuxPort] == STAT_COMM_PENDING) { wait1Msec(2); // Wait for I2C bus to be ready } sendI2CMsg(RXMuxPort, RXMuxMSG[0], 0); // Send the message wait1Msec(5); // have to have wait or sensor wont read proper values SensorType[RXMuxPort] = ChannelSensorType; // Sensor Type on the chosen channel SensorMode[RXMuxPort] = ChannelSensorMode; // Sensor Mode on the chosen channel
}
|