improed processing of sbus frames

This commit is contained in:
Pawel Spychalski (DzikuVx)
2018-04-19 11:18:36 +02:00
parent 6ee2caf68d
commit 66693914d1
4 changed files with 10 additions and 6 deletions

View File

@@ -21,12 +21,14 @@ equivalent to
map(channels[i], RC_CHANNEL_MIN, RC_CHANNEL_MAX, SBUS_MIN_OFFSET, SBUS_MAX_OFFSET);
*/
int mapChannelToSbus(int in) {
return (((long) in * 1605l) / 1000l) - 1417;
return ((long) in * 1605l / 1000l) - 1417;
}
/*
Precomputed mapping from 173:1811 to 990-2010
*/
int mapSbusToChannel(int in) {
//TODO, speed up this processing
return map(in, 173, 1811, 990, 2010);
return (((long) in - 173l) * 1020l / 1638l) + 990;
}
void sbusPreparePacket(uint8_t packet[], int16_t channels[], bool isSignalLoss, bool isFailsafe){