Closed user1321 closed 5 years ago
No, the channels are 11 bits wide and you're stuffing them into an array of 8 bit containers. You can see a depiction of how the channels are packed in the array here: https://github.com/bolderflight/SBUS/blob/master/extras/bit-mapping.pdf
Oh, I see. Sorry.
Good Day! Please, correct me if I am wrong, but should that part of code:
void SBUS::write(uint16_t* channels) ..... packet[1] = (uint8_t) ((channels[0] & 0x07FF)); packet[2] = (uint8_t) ((channels[0] & 0x07FF)>>8 | (channels[1] & 0x07FF)<<3); packet[3] = (uint8_t) ((channels[1] & 0x07FF)>>5 | (channels[2] & 0x07FF)<<6); packet[4] = (uint8_t) ((channels[2] & 0x07FF)>>2);
should be like that:
void SBUS::write(uint16_t* channels) .... packet[1] = (uint8_t) ((channels[0] & 0x07FF)); packet[2] = (uint8_t) ((channels[1] & 0x07FF)>>8 | (channels[2] & 0x07FF)<<3); packet[3] = (uint8_t) ((channels[2] & 0x07FF)>>5 | (channels[3] & 0x07FF)<<6); packet[4] = (uint8_t) ((channels[3] & 0x07FF)>>2);
Thank you.