VEXcode IQ C++ Unofficial documentation for version 3.0.4.1
Loading...
Searching...
No Matches
vex::generic Class Reference
Inheritance diagram for vex::generic:
vex::device

Public Types

enum  _i2cRegType {
  kRegAsciiVersion = 0x00 , kRegAsciiVendor = 0x08 , kRegAsciiDeviceId = 0x10 , kRegUserVendorId = 0x18 ,
  kRegUserProductId = 0x19 , kRegFirmwareVersion = 0x20 , kRegDeviceType = 0x21 , kRegDeviceId = 0x22 ,
  kRegDeviceStatus = 0x23
}
 
typedef enum vex::generic::_i2cRegType i2cRegType
 

Public Member Functions

 generic (int32_t index)
 Creates a new generic sensor object on the port specified in the parameter.
 
bool installed ()
 
int32_t version ()
 Gets the firmware version of the generic sensor.
 
int32_t vendorId ()
 Gets the vendor id of the generic sensor.
 
int32_t productId ()
 Gets the product id of the generic sensor.
 
int32_t readByte (uint8_t reg)
 Read 1 byte from the generic sensor.
 
int32_t writeByte (uint8_t reg, uint8_t value)
 Write 1 byte to the generic sensor.
 
int32_t readWord (uint8_t reg, bool bLittleEndian=false)
 Read 1 word (2 bytes) from the generic sensor.
 
int32_t writeWord (uint8_t reg, uint16_t value, bool bLittleEndian=false)
 Write 1 word (2 bytes) to the generic sensor.
 
bool readReg (uint8_t reg, uint8_t *pBytes, uint8_t nLength)
 Read bytes from the generic sensor.
 
bool writeReg (uint8_t reg, uint8_t *pBytes, uint8_t nLength)
 Write bytes to the generic sensor.
 
bool readRaw (uint8_t addr, uint8_t *pBytes, uint8_t nLength)
 Read bytes from the device.
 
bool writeRaw (uint8_t addr, uint8_t *pBytes, uint8_t nLength)
 Write bytes to the device.
 
void writeRawWait ()
 Wait for raw write to complete usually this is not needed, writeRaw will block when called waiting for previous transactions to complete. but during testing, if errors are occurring, then this method will clears errors and suppress the "I2C error" message.
 
- Public Member Functions inherited from vex::device
 device (int32_t index)
 
IQ_DeviceType type ()
 
int32_t index ()
 
void init (int32_t index)
 
virtual int32_t value ()
 
int32_t readDigitalPin ()
 
int32_t readAnalogPin ()
 

Additional Inherited Members

- Protected Member Functions inherited from vex::device
void setPollInterval (int32_t value)
 
bool pollValid (bool bSave)
 
- Protected Attributes inherited from vex::device
int16_t _index
 

Detailed Description

Definition at line 26 of file vex_generic.h.

Member Enumeration Documentation

◆ _i2cRegType

enum vex::generic::_i2cRegType

Definition at line 108 of file vex_generic.h.

Constructor & Destructor Documentation

◆ generic()

vex::generic::generic ( int32_t index)

Creates a new generic sensor object on the port specified in the parameter.

Parameters
portindex to the brain port.

Member Function Documentation

◆ installed()

bool vex::generic::installed ( )
virtual

Reimplemented from vex::device.

◆ productId()

int32_t vex::generic::productId ( )

Gets the product id of the generic sensor.

Returns
Returns an integer with product id or -1 on error

◆ readByte()

int32_t vex::generic::readByte ( uint8_t reg)

Read 1 byte from the generic sensor.

Parameters
regthe register to read from
Returns
register value on success, -1 if error

◆ readRaw()

bool vex::generic::readRaw ( uint8_t addr,
uint8_t * pBytes,
uint8_t nLength )

Read bytes from the device.

Parameters
addrthe 8 bit i2C address of the device
pBytespointer to buffer to read into
nLengthnumber of bytes to read
Returns
true on success, false if error

◆ readReg()

bool vex::generic::readReg ( uint8_t reg,
uint8_t * pBytes,
uint8_t nLength )

Read bytes from the generic sensor.

Parameters
regthe starting register to read from
pBytespointer to buffer to read into
nLengthnumber of bytes to read
Returns
true on success, false if error

◆ readWord()

int32_t vex::generic::readWord ( uint8_t reg,
bool bLittleEndian = false )

Read 1 word (2 bytes) from the generic sensor.

Parameters
regthe register to read from
bLittleEndianthe endianess of the word in the sensor
Returns
register value on success, -1 if error

◆ vendorId()

int32_t vex::generic::vendorId ( )

Gets the vendor id of the generic sensor.

Returns
Returns an integer with vendor id or -1 on error

◆ version()

int32_t vex::generic::version ( )

Gets the firmware version of the generic sensor.

Returns
Returns an integer with version or -1 on error

◆ writeByte()

int32_t vex::generic::writeByte ( uint8_t reg,
uint8_t value )

Write 1 byte to the generic sensor.

Parameters
regthe register to write to
valuethe data to write
Returns
register value on success, -1 if error

◆ writeRaw()

bool vex::generic::writeRaw ( uint8_t addr,
uint8_t * pBytes,
uint8_t nLength )

Write bytes to the device.

Parameters
addrthe 8 bit i2C address of the device
pBytespointer to buffer with data
nLengthnumber of bytes to write
Returns
true on success, false if error

◆ writeReg()

bool vex::generic::writeReg ( uint8_t reg,
uint8_t * pBytes,
uint8_t nLength )

Write bytes to the generic sensor.

Parameters
regthe starting register to write to
pBytespointer to buffer with data
nLengthnumber of bytes to write
Returns
true on success, false if error

◆ writeWord()

int32_t vex::generic::writeWord ( uint8_t reg,
uint16_t value,
bool bLittleEndian = false )

Write 1 word (2 bytes) to the generic sensor.

Parameters
regthe register to write to
valuethe data to write
bLittleEndianthe endianess of the word in the sensor
Returns
register value on success, -1 if error

The documentation for this class was generated from the following file: