diff --git a/.vscode/arduino.json b/.vscode/arduino.json index 470c2cf..e8e6b14 100644 --- a/.vscode/arduino.json +++ b/.vscode/arduino.json @@ -1,6 +1,6 @@ { "board": "bsfrance:avr:lora32u4", "sketch": "crossbow/crossbow.ino", - "port": "COM3", + "port": "COM7", "output": "../build" } \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 5a0e42f..fc1a11f 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -20,7 +20,10 @@ "intelliSenseMode": "msvc-x64", "cStandard": "c11", "cppStandard": "c++17", - "compilerPath": "/usr/bin/clang" + "compilerPath": "/usr/bin/clang", + "defines": [ + "FEATURE_TX_INPUT_SBUS" + ] }, { "name": "Mac", diff --git a/crossbow/crossbow.ino b/crossbow/crossbow.ino index f9a6d10..0a6ba41 100644 --- a/crossbow/crossbow.ino +++ b/crossbow/crossbow.ino @@ -8,7 +8,6 @@ Copyright (c) 20xx, MPL Contributor1 contrib1@example.net #include "config.h" - #include "lora.h" #include "variables.h" #include "main_variables.h" diff --git a/crossbow/sbus.cpp b/crossbow/sbus.cpp index c1fb430..881ccbc 100644 --- a/crossbow/sbus.cpp +++ b/crossbow/sbus.cpp @@ -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){