Hi
I have had some success with your gyro module and Wixels and Maestro.
But getting stuck on a C programming approach.
The problem is that adcRead returns a uint16 how do I sent this as a byte array with usbComTxSend.
Simply how do I convert uint16 to uint8 XDATA * ?
The code block below throws away most of the resolution and chops off the upper 128 values.
I should be able to use something like itoa and send that with usbComTxSend.
void txGyroState()
{
uint8 XDATA * txBuf;
static uint8 lastTx = 0;
if ((uint8)(getMs() - lastTx) > TX_INTERVAL )
{
uint16 fx, fz;
uint8 com;
fx = adcRead(2 | ADC_BITS_12) / 8; // read 0 to 2047 divide by 8 to range
fz = adcRead(1 | ADC_BITS_12) / 8;
//txBuf[0] = (int8)fx;
//txBuf[1] = (int8)fz;
com = usbComTxAvailable(); // todo test later
usbComTxSendByte((int8)fx);
usbComTxSendByte((int8)fz);
//usbComTxSend(txBuf,2)
lastTx = getMs();
}
}
I am reading the virtual com port with terminal.
Thank you,
James