Luka Slapnik / sbus_decode1

Dependents:   CyberbotV1

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SBUS.h Source File

SBUS.h

00001 #ifndef INCLUDED_SBUS_H
00002 #define INCLUDED_SBUS_H
00003 
00004 #include "mbed.h"
00005 #include "BufferedSerial.h"
00006 
00007 class SBUS {
00008     public:
00009         // @parm    tx  communication tx pin
00010         //          rx  communocation rx pin
00011         SBUS(PinName tx, PinName rx);
00012         
00013         // function of getting stick value
00014         // @parm    tag stickName
00015         float getStickValue(int tag);
00016         
00017         // function of getting channel value
00018         // @parm    tag 0-25
00019         int getChannelValue(int tag);
00020         
00021         // checks failsafe timer, returns 1 if data was received in last 100ms, 
00022         // 0 if there was no data in last 100ms
00023         int checkFailsafeTimer();
00024         
00025         int failSafeTimerMs();
00026         
00027         Timer failsafetimer;
00028     
00029     private:
00030         Serial sbus;
00031         //BufferedSerial sbus;
00032         
00033         int sbusMaximumValue;
00034         int sbusNeutralValue;
00035         int sbusMinimumValue;
00036         int sbusDeadband;
00037 
00038         int channel[16];
00039         int receivedData[50];
00040         float stickValue[16];
00041         
00042         void receiveData();
00043         
00044         void decordReceivedData();
00045         
00046         void convertReceivedData();
00047         
00048         int failsafetime;
00049         int lastreadtime;
00050         int reportreadtime;
00051 };
00052 
00053 #endif