Yuta Togashi / SBUS_STM32

Dependents:   purppo-kudou mbed_kudou_roller

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sbus.h Source File

sbus.h

00001 #ifndef SBUS_H
00002 #define SBUS_H
00003 
00004 #include "mbed.h"
00005 
00006 class Sbus {
00007     public:
00008         Sbus(PinName tx,PinName rx);
00009         
00010         enum STICK_NUMBER {
00011             ANALOG_RX,
00012             ANALOG_RY,
00013             ANALOG_LX,
00014             ANALOG_LY,
00015             ANALOG_NUMBER,  
00016         };
00017         
00018         enum SWITCH_NUMBER {
00019             SW_A,
00020             SW_B,
00021             SW_C,
00022             SW_D,
00023             SW_E,
00024             SW_F,
00025             SW_G,  
00026             SW_H,
00027             VR,
00028             SWITCH_NUMBER,
00029         };
00030         
00031         enum SWITCH_POSITION {
00032             LOW,
00033             NEUTRAL,
00034             HIGH,
00035         };
00036         
00037         enum SBUS_STATUS {
00038             SBUS_SIGNAL_OK,
00039             SBUS_SIGNAL_LOST,
00040             SBUS_SIGNAL_FAILSAFE,
00041         };
00042         
00043         enum SBUS_CH_NUMBER {   
00044             CH5 = 4,
00045             CH6,
00046             CH7,
00047             CH8,
00048             CH9,
00049             CH10,            
00050         };
00051         
00052         void setup(int ch5,int ch6,int ch7,int ch8,int ch9,int ch10);
00053         
00054         float getStickValue(int ch);
00055         float getVolumeValue();
00056         int getSwitchValue(int ch);
00057         
00058         int getFailSafe();
00059         
00060         int getChannelValue(int ch);
00061     private:
00062         Serial com;
00063         Timer  receiveTimer;
00064         
00065         bool enableReceive;
00066         int failsafe;
00067         int stickMaximumValue;
00068         int stickNeutralValue;
00069         int stickMinimumValue;
00070         int stickResolution;
00071         float volumeValue;
00072         int channel[16];
00073         int receiveData[50];
00074 
00075         int swSelectData[6];
00076 
00077         int switchValue[12];
00078         float stickValue[ANALOG_NUMBER];
00079          
00080         
00081         void serialReceiveHandler();
00082         void decordReceiveData();
00083         void convertReceiveData();
00084         void resetAllData();
00085     
00086 };
00087 
00088 #endif