forked from bolderflight/sbus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed channels and lostFrames to uint16_t data types to more accura…
…tely match the data type being used. Modified the scale and bias for the readCal() function to be single precision floats instead of doubles. Changed the example and README to match the code changes.
- Loading branch information
1 parent
91d6d74
commit 56325b3
Showing
4 changed files
with
25 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
SBUS.cpp | ||
Brian R Taylor | ||
[email protected] | ||
2016-09-19 | ||
2016-09-21 | ||
Copyright (c) 2016 Bolder Flight Systems | ||
|
@@ -72,8 +72,8 @@ void SBUS::begin(){ | |
} | ||
|
||
/* read the SBUS data and calibrate it to +/- 1 */ | ||
bool SBUS::readCal(float* calChannels, uint8_t* failsafe, int* lostFrames){ | ||
int16_t channels[16]; | ||
bool SBUS::readCal(float* calChannels, uint8_t* failsafe, uint16_t* lostFrames){ | ||
uint16_t channels[16]; | ||
|
||
// read the SBUS data | ||
if(read(&channels[0],failsafe,lostFrames)){ | ||
|
@@ -94,7 +94,7 @@ bool SBUS::readCal(float* calChannels, uint8_t* failsafe, int* lostFrames){ | |
} | ||
|
||
/* read the SBUS data */ | ||
bool SBUS::read(int16_t* channels, uint8_t* failsafe, int* lostFrames){ | ||
bool SBUS::read(uint16_t* channels, uint8_t* failsafe, uint16_t* lostFrames){ | ||
|
||
// parse the SBUS packet | ||
if(parse()){ | ||
|
@@ -182,7 +182,7 @@ bool SBUS::parse(){ | |
} | ||
|
||
/* write SBUS packets */ | ||
void SBUS::write(int16_t* channels){ | ||
void SBUS::write(uint16_t* channels){ | ||
uint8_t packet[25]; | ||
|
||
/* assemble the SBUS packet */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
SBUS.h | ||
Brian R Taylor | ||
[email protected] | ||
2016-09-02 | ||
2016-09-21 | ||
Copyright (c) 2016 Bolder Flight Systems | ||
|
@@ -31,14 +31,14 @@ class SBUS{ | |
public: | ||
SBUS(int bus); | ||
void begin(); | ||
bool read(int16_t* channels, uint8_t* failsafe, int* lostFrames); | ||
bool readCal(float* calChannels, uint8_t* failsafe, int* lostFrames); | ||
void write(int16_t* channels); | ||
bool read(uint16_t* channels, uint8_t* failsafe, uint16_t* lostFrames); | ||
bool readCal(float* calChannels, uint8_t* failsafe, uint16_t* lostFrames); | ||
void write(uint16_t* channels); | ||
private: | ||
int _bus; | ||
int _fpos; | ||
const double _sbusScale = 0.0012202562538133; | ||
const double _sbusBias = -1.20988407565589; | ||
const float _sbusScale = 0.00122025625f; | ||
const float _sbusBias = -1.2098840f; | ||
static const uint8_t _sbusHeader = 0x0F; | ||
static const uint8_t _sbusFooter = 0x00; | ||
static const uint8_t _sbusLostFrame = 0x20; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
SBUS_example.ino | ||
Brian R Taylor | ||
[email protected] | ||
2016-07-12 | ||
2016-09-21 | ||
Copyright (c) 2016 Bolder Flight Systems | ||
|
@@ -40,9 +40,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SO | |
SBUS x8r(1); | ||
|
||
// channel, fail safe, and lost frames data | ||
int16_t channels[16]; | ||
uint16_t channels[16]; | ||
uint8_t failSafe; | ||
int lostFrames = 0; | ||
uint16_t lostFrames = 0; | ||
|
||
void setup() { | ||
// begin the SBUS communication | ||
|