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

@@ -1,6 +1,6 @@
{ {
"board": "bsfrance:avr:lora32u4", "board": "bsfrance:avr:lora32u4",
"sketch": "crossbow/crossbow.ino", "sketch": "crossbow/crossbow.ino",
"port": "COM3", "port": "COM7",
"output": "../build" "output": "../build"
} }

View File

@@ -14,7 +14,10 @@
"intelliSenseMode": "msvc-x64", "intelliSenseMode": "msvc-x64",
"cStandard": "c11", "cStandard": "c11",
"cppStandard": "c++17", "cppStandard": "c++17",
"compilerPath": "/usr/bin/clang" "compilerPath": "/usr/bin/clang",
"defines": [
"FEATURE_TX_INPUT_SBUS"
]
}, },
{ {
"name": "Mac", "name": "Mac",

View File

@@ -8,7 +8,6 @@ Copyright (c) 20xx, MPL Contributor1 contrib1@example.net
#include "config.h" #include "config.h"
#include "lora.h" #include "lora.h"
#include "variables.h" #include "variables.h"
#include "main_variables.h" #include "main_variables.h"

View File

@@ -21,12 +21,14 @@ equivalent to
map(channels[i], RC_CHANNEL_MIN, RC_CHANNEL_MAX, SBUS_MIN_OFFSET, SBUS_MAX_OFFSET); map(channels[i], RC_CHANNEL_MIN, RC_CHANNEL_MAX, SBUS_MIN_OFFSET, SBUS_MAX_OFFSET);
*/ */
int mapChannelToSbus(int in) { 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) { int mapSbusToChannel(int in) {
//TODO, speed up this processing return (((long) in - 173l) * 1020l / 1638l) + 990;
return map(in, 173, 1811, 990, 2010);
} }
void sbusPreparePacket(uint8_t packet[], int16_t channels[], bool isSignalLoss, bool isFailsafe){ void sbusPreparePacket(uint8_t packet[], int16_t channels[], bool isSignalLoss, bool isFailsafe){