Luka Slapnik / sbus_decode
Revision:
15:c96df23cad7d
Parent:
3:c004c3d1c349
diff -r 481c23f2e4eb -r c96df23cad7d SBUS.h
--- a/SBUS.h	Mon Jul 15 09:05:23 2019 +0000
+++ b/SBUS.h	Mon Jun 29 15:54:10 2020 +0000
@@ -2,6 +2,7 @@
 #define INCLUDED_SBUS_H
 
 #include "mbed.h"
+#include "BufferedSerial.h"
 
 class SBUS {
     public:
@@ -9,62 +10,44 @@
         //          rx  communocation rx pin
         SBUS(PinName tx, PinName rx);
         
-        // channel array elements tag
-        enum channelTag { right_RL, left_UD, right_UD, left_RL, sw1, sw2, sw3, sw4, sw5, sw6 };
-        
-        // stick value array elements tag
-        enum stickName {
-            analog_rx,
-            analog_ry,
-            analog_lx,
-            analog_ly
-        };
-        
-        // switch position tag
-        enum switchPosition {
-            Low,
-            Neutral,
-            High
-        };
-        
-        // switchF position tag
-        enum switchFPosition {
-            FHigh,
-            FLow
-        };
-        
         // function of getting stick value
         // @parm    tag stickName
         float getStickValue(int tag);
         
-        // function of getting switch value
-        // @parm    tag 0-12
-        int getSwitchValue(int tag);
-        
         // function of getting channel value
         // @parm    tag 0-25
         int getChannelValue(int tag);
+        
+        // checks failsafe timer, returns 1 if data was received in last 100ms, 
+        // 0 if there was no data in last 100ms
+        int checkFailsafeTimer();
+        
+        int failSafeTimerMs();
+        
+        Timer failsafetimer;
     
     private:
-        Serial com;
+        Serial sbus;
+        //BufferedSerial sbus;
         
-        int stickMaximumValue;
-        int stickNeutralValue;
-        int stickMinimumValue;
-        int stickResolution;
-        
+        int sbusMaximumValue;
+        int sbusNeutralValue;
+        int sbusMinimumValue;
+        int sbusDeadband;
+
         int channel[16];
         int receivedData[50];
-        float stickValue[4];
-        int switchFPositionValue[2];
-        int switchPositionValue[3];
-        int switchValue[12];
+        float stickValue[16];
         
         void receiveData();
         
         void decordReceivedData();
         
         void convertReceivedData();
+        
+        int failsafetime;
+        int lastreadtime;
+        int reportreadtime;
 };
 
 #endif