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:55548ca76fc4, 2020-12-07 (annotated)
- Committer:
- sshogo
- Date:
- Mon Dec 07 07:41:34 2020 +0000
- Revision:
- 15:55548ca76fc4
- Parent:
- 3:c004c3d1c349
add functions:; - resetall() ; Reset all parameters; - getConnectStatus() ; Get connecting status from receiver to mbed; - connstatus ; Connecting status from receiver to mbed
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" |
sshogo | 0:e2bc011508c7 | 5 | |
sshogo | 0:e2bc011508c7 | 6 | class SBUS { |
sshogo | 0:e2bc011508c7 | 7 | public: |
sshogo | 3:c004c3d1c349 | 8 | // @parm tx communication tx pin |
sshogo | 3:c004c3d1c349 | 9 | // rx communocation rx pin |
sshogo | 0:e2bc011508c7 | 10 | SBUS(PinName tx, PinName rx); |
sshogo | 0:e2bc011508c7 | 11 | |
sshogo | 3:c004c3d1c349 | 12 | // channel array elements tag |
sshogo | 0:e2bc011508c7 | 13 | enum channelTag { right_RL, left_UD, right_UD, left_RL, sw1, sw2, sw3, sw4, sw5, sw6 }; |
sshogo | 0:e2bc011508c7 | 14 | |
sshogo | 3:c004c3d1c349 | 15 | // stick value array elements tag |
sshogo | 0:e2bc011508c7 | 16 | enum stickName { |
sshogo | 0:e2bc011508c7 | 17 | analog_rx, |
sshogo | 0:e2bc011508c7 | 18 | analog_ry, |
sshogo | 0:e2bc011508c7 | 19 | analog_lx, |
sshogo | 0:e2bc011508c7 | 20 | analog_ly |
sshogo | 0:e2bc011508c7 | 21 | }; |
sshogo | 0:e2bc011508c7 | 22 | |
sshogo | 3:c004c3d1c349 | 23 | // switch position tag |
sshogo | 0:e2bc011508c7 | 24 | enum switchPosition { |
sshogo | 2:493d10424466 | 25 | Low, |
sshogo | 0:e2bc011508c7 | 26 | Neutral, |
sshogo | 2:493d10424466 | 27 | High |
sshogo | 0:e2bc011508c7 | 28 | }; |
sshogo | 0:e2bc011508c7 | 29 | |
sshogo | 3:c004c3d1c349 | 30 | // switchF position tag |
sshogo | 0:e2bc011508c7 | 31 | enum switchFPosition { |
sshogo | 0:e2bc011508c7 | 32 | FHigh, |
sshogo | 0:e2bc011508c7 | 33 | FLow |
sshogo | 0:e2bc011508c7 | 34 | }; |
sshogo | 0:e2bc011508c7 | 35 | |
sshogo | 3:c004c3d1c349 | 36 | // function of getting stick value |
sshogo | 3:c004c3d1c349 | 37 | // @parm tag stickName |
sshogo | 0:e2bc011508c7 | 38 | float getStickValue(int tag); |
sshogo | 0:e2bc011508c7 | 39 | |
sshogo | 3:c004c3d1c349 | 40 | // function of getting switch value |
sshogo | 3:c004c3d1c349 | 41 | // @parm tag 0-12 |
sshogo | 0:e2bc011508c7 | 42 | int getSwitchValue(int tag); |
sshogo | 0:e2bc011508c7 | 43 | |
sshogo | 3:c004c3d1c349 | 44 | // function of getting channel value |
sshogo | 3:c004c3d1c349 | 45 | // @parm tag 0-25 |
sshogo | 0:e2bc011508c7 | 46 | int getChannelValue(int tag); |
sshogo | 15:55548ca76fc4 | 47 | |
sshogo | 15:55548ca76fc4 | 48 | // function of getting connecting status |
sshogo | 15:55548ca76fc4 | 49 | bool getConnectStatus(); |
sshogo | 0:e2bc011508c7 | 50 | |
sshogo | 0:e2bc011508c7 | 51 | private: |
sshogo | 0:e2bc011508c7 | 52 | Serial com; |
sshogo | 0:e2bc011508c7 | 53 | |
sshogo | 0:e2bc011508c7 | 54 | int stickMaximumValue; |
sshogo | 0:e2bc011508c7 | 55 | int stickNeutralValue; |
sshogo | 0:e2bc011508c7 | 56 | int stickMinimumValue; |
sshogo | 0:e2bc011508c7 | 57 | int stickResolution; |
sshogo | 15:55548ca76fc4 | 58 | bool connstatus; |
sshogo | 0:e2bc011508c7 | 59 | |
sshogo | 0:e2bc011508c7 | 60 | int channel[16]; |
sshogo | 0:e2bc011508c7 | 61 | int receivedData[50]; |
sshogo | 0:e2bc011508c7 | 62 | float stickValue[4]; |
sshogo | 0:e2bc011508c7 | 63 | int switchFPositionValue[2]; |
sshogo | 0:e2bc011508c7 | 64 | int switchPositionValue[3]; |
sshogo | 0:e2bc011508c7 | 65 | int switchValue[12]; |
sshogo | 0:e2bc011508c7 | 66 | |
sshogo | 0:e2bc011508c7 | 67 | void receiveData(); |
sshogo | 0:e2bc011508c7 | 68 | |
sshogo | 0:e2bc011508c7 | 69 | void decordReceivedData(); |
sshogo | 0:e2bc011508c7 | 70 | |
sshogo | 0:e2bc011508c7 | 71 | void convertReceivedData(); |
sshogo | 15:55548ca76fc4 | 72 | |
sshogo | 15:55548ca76fc4 | 73 | void resetall(); |
sshogo | 0:e2bc011508c7 | 74 | }; |
sshogo | 0:e2bc011508c7 | 75 | |
sshogo | 0:e2bc011508c7 | 76 | #endif |