Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SBUS.h@15:c96df23cad7d, 2020-06-29 (annotated)
- Committer:
- sllez
- Date:
- Mon Jun 29 15:54:10 2020 +0000
- Revision:
- 15:c96df23cad7d
- Parent:
- 3:c004c3d1c349
koncno
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sshogo | 0:e2bc011508c7 | 1 | #ifndef INCLUDED_SBUS_H |
sshogo | 0:e2bc011508c7 | 2 | #define INCLUDED_SBUS_H |
sshogo | 0:e2bc011508c7 | 3 | |
sshogo | 0:e2bc011508c7 | 4 | #include "mbed.h" |
sllez | 15:c96df23cad7d | 5 | #include "BufferedSerial.h" |
sshogo | 0:e2bc011508c7 | 6 | |
sshogo | 0:e2bc011508c7 | 7 | class SBUS { |
sshogo | 0:e2bc011508c7 | 8 | public: |
sshogo | 3:c004c3d1c349 | 9 | // @parm tx communication tx pin |
sshogo | 3:c004c3d1c349 | 10 | // rx communocation rx pin |
sshogo | 0:e2bc011508c7 | 11 | SBUS(PinName tx, PinName rx); |
sshogo | 0:e2bc011508c7 | 12 | |
sshogo | 3:c004c3d1c349 | 13 | // function of getting stick value |
sshogo | 3:c004c3d1c349 | 14 | // @parm tag stickName |
sshogo | 0:e2bc011508c7 | 15 | float getStickValue(int tag); |
sshogo | 0:e2bc011508c7 | 16 | |
sshogo | 3:c004c3d1c349 | 17 | // function of getting channel value |
sshogo | 3:c004c3d1c349 | 18 | // @parm tag 0-25 |
sshogo | 0:e2bc011508c7 | 19 | int getChannelValue(int tag); |
sllez | 15:c96df23cad7d | 20 | |
sllez | 15:c96df23cad7d | 21 | // checks failsafe timer, returns 1 if data was received in last 100ms, |
sllez | 15:c96df23cad7d | 22 | // 0 if there was no data in last 100ms |
sllez | 15:c96df23cad7d | 23 | int checkFailsafeTimer(); |
sllez | 15:c96df23cad7d | 24 | |
sllez | 15:c96df23cad7d | 25 | int failSafeTimerMs(); |
sllez | 15:c96df23cad7d | 26 | |
sllez | 15:c96df23cad7d | 27 | Timer failsafetimer; |
sshogo | 0:e2bc011508c7 | 28 | |
sshogo | 0:e2bc011508c7 | 29 | private: |
sllez | 15:c96df23cad7d | 30 | Serial sbus; |
sllez | 15:c96df23cad7d | 31 | //BufferedSerial sbus; |
sshogo | 0:e2bc011508c7 | 32 | |
sllez | 15:c96df23cad7d | 33 | int sbusMaximumValue; |
sllez | 15:c96df23cad7d | 34 | int sbusNeutralValue; |
sllez | 15:c96df23cad7d | 35 | int sbusMinimumValue; |
sllez | 15:c96df23cad7d | 36 | int sbusDeadband; |
sllez | 15:c96df23cad7d | 37 | |
sshogo | 0:e2bc011508c7 | 38 | int channel[16]; |
sshogo | 0:e2bc011508c7 | 39 | int receivedData[50]; |
sllez | 15:c96df23cad7d | 40 | float stickValue[16]; |
sshogo | 0:e2bc011508c7 | 41 | |
sshogo | 0:e2bc011508c7 | 42 | void receiveData(); |
sshogo | 0:e2bc011508c7 | 43 | |
sshogo | 0:e2bc011508c7 | 44 | void decordReceivedData(); |
sshogo | 0:e2bc011508c7 | 45 | |
sshogo | 0:e2bc011508c7 | 46 | void convertReceivedData(); |
sllez | 15:c96df23cad7d | 47 | |
sllez | 15:c96df23cad7d | 48 | int failsafetime; |
sllez | 15:c96df23cad7d | 49 | int lastreadtime; |
sllez | 15:c96df23cad7d | 50 | int reportreadtime; |
sshogo | 0:e2bc011508c7 | 51 | }; |
sshogo | 0:e2bc011508c7 | 52 | |
sshogo | 0:e2bc011508c7 | 53 | #endif |