Merge pull request #8425 from rotorman/patch-1
Bluetooth: making better use of constants
This commit is contained in:
@@ -217,11 +217,11 @@ void Bluetooth::processTrainerByte(uint8_t data)
|
||||
|
||||
if (bufferIndex >= BLUETOOTH_PACKET_SIZE) {
|
||||
uint8_t crc = 0x00;
|
||||
for (int i=0; i<13; i++) {
|
||||
for (int i=0; i<(BLUETOOTH_PACKET_SIZE-1); i++) {
|
||||
crc ^= buffer[i];
|
||||
}
|
||||
if (crc == buffer[13]) {
|
||||
if (buffer[0] == 0x80) {
|
||||
if (crc == buffer[BLUETOOTH_PACKET_SIZE-1]) {
|
||||
if (buffer[0] == TRAINER_FRAME) {
|
||||
processTrainerFrame(buffer);
|
||||
}
|
||||
}
|
||||
@@ -251,7 +251,7 @@ void Bluetooth::sendTrainer()
|
||||
crc = 0x00;
|
||||
|
||||
buffer[bufferIndex++] = START_STOP; // start byte
|
||||
pushByte(0x80); // trainer frame type?
|
||||
pushByte(TRAINER_FRAME);
|
||||
for (int channel=0; channel<lastCh; channel+=2, cur+=3) {
|
||||
uint16_t channelValue1 = PPM_CH_CENTER(channel) + limit((int16_t)-PPM_range, channelOutputs[channel], (int16_t)PPM_range) / 2;
|
||||
uint16_t channelValue2 = PPM_CH_CENTER(channel+1) + limit((int16_t)-PPM_range, channelOutputs[channel+1], (int16_t)PPM_range) / 2;
|
||||
|
||||
Reference in New Issue
Block a user