teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

Revision:
36:2cc739c7e4cb
Parent:
34:234b87f3e6ce
Child:
38:24ee50452755
--- a/HbUserOpe.cpp	Tue Dec 25 08:20:17 2018 +0000
+++ b/HbUserOpe.cpp	Wed Jan 16 10:51:07 2019 +0000
@@ -5,7 +5,7 @@
 //=========================================
 HbUserOpe::HbUserOpe(){
     oldOpe.w = curOpe.w = 0;
-    AinAxlVal = 0;
+    AinAxlVal = AinTrtlVal = 0;
 }
 
 //=========================================
@@ -43,18 +43,30 @@
     return ret;
 }
 
+INT16 HbUserOpe::GetAinThrottle()
+{
+    INT16 ret = 0;
+    AinTrtlVal = AinThrottle.read();
+    ret = (INT16)(MAX_12BIT_DATA * AinTrtlVal);
+    if(gf_DbgPrint.bf.ana2 == true){
+        sp.printf("Trottle Val=%d analog val=%f\r\n",ret,AinTrtlVal);
+        gf_DbgPrint.bf.ana2 = false;
+    }
+    return ret;
+}
+
 bool HbUserOpe::ChkCtrlSW(SW_TYPE styp)
 {
-            if(styp == BRK_L)   {return curOpe.bf.brk_l;}
-    else    if(styp == BRK_R)   {return curOpe.bf.brk_r;}
-    else    if(styp == FLT_ON)     {return curOpe.bf.flt_on;}
+            if(styp == BRK_L)       {return curOpe.bf.brk_l;}
+    else    if(styp == BRK_R)       {return curOpe.bf.brk_r;}
+    else    if(styp == FLT_ON)      {return curOpe.bf.flt_on;}
     else    if(styp == FLT_OFF)     {return curOpe.bf.flt_off;}
-    else    if(styp == FL_BRK)     {return curOpe.bf.full_brk;}
-    else    if(styp == MOT_STOP){return curOpe.bf.mot_stop;}
-    else    if(styp == R_1)     {return curOpe.bf.rsv_1;}
-    else    if(styp == R_2)     {return curOpe.bf.rsv_2;}
-    else    if(styp == R_3)     {return curOpe.bf.rsv_3;}
-    else    if(styp == ALL_STOP){return curOpe.bf.all_stop;}
+    else    if(styp == F_ENG_UP)    {return curOpe.bf.f_eng_up;}
+    else    if(styp == F_ENG_DOWN)  {return curOpe.bf.f_eng_down;}
+    else    if(styp == R_ENG_UP)    {return curOpe.bf.r_eng_up;}
+    else    if(styp == R_ENG_DOWN)  {return curOpe.bf.r_eng_down;}
+    else    if(styp == R_1)         {return curOpe.bf.rsv_1;}
+    else    if(styp == ALL_STOP)    {return curOpe.bf.all_stop;}
     else {return false;}
 }
 bool HbUserOpe::ChkCtrlSwAny()
@@ -68,17 +80,47 @@
     }
     return false;
 }
+bool HbUserOpe::ChkCtrlSwBoth(SW_TYPE styp1,SW_TYPE styp2)
+{
+    bool sw1,sw2;
+    sw1 = sw2 = false;
+            if(styp1 == BRK_L)       {sw1 = curOpe.bf.brk_l;}
+    else    if(styp1 == BRK_R)       {sw1 = curOpe.bf.brk_r;}
+    else    if(styp1 == FLT_ON)      {sw1 = curOpe.bf.flt_on;}
+    else    if(styp1 == FLT_OFF)     {sw1 = curOpe.bf.flt_off;}
+    else    if(styp1 == F_ENG_UP)    {sw1 = curOpe.bf.f_eng_up;}
+    else    if(styp1 == F_ENG_DOWN)  {sw1 = curOpe.bf.f_eng_down;}
+    else    if(styp1 == R_ENG_UP)    {sw1 = curOpe.bf.r_eng_up;}
+    else    if(styp1 == R_ENG_DOWN)  {sw1 = curOpe.bf.r_eng_down;}
+    else    if(styp1 == R_1)         {sw1 = curOpe.bf.rsv_1;}
+    else    if(styp1 == ALL_STOP)    {sw1 = curOpe.bf.all_stop;}
+    else {sw1 = false;}
+            if(styp2 == BRK_L)       {sw2 = curOpe.bf.brk_l;}
+    else    if(styp2 == BRK_R)       {sw2 = curOpe.bf.brk_r;}
+    else    if(styp2 == FLT_ON)      {sw2 = curOpe.bf.flt_on;}
+    else    if(styp2 == FLT_OFF)     {sw2 = curOpe.bf.flt_off;}
+    else    if(styp2 == F_ENG_UP)    {sw2 = curOpe.bf.f_eng_up;}
+    else    if(styp2 == F_ENG_DOWN)  {sw2 = curOpe.bf.f_eng_down;}
+    else    if(styp2 == R_ENG_UP)    {sw2 = curOpe.bf.r_eng_up;}
+    else    if(styp2 == R_ENG_DOWN)  {sw2 = curOpe.bf.r_eng_down;}
+    else    if(styp2 == R_1)         {sw2 = curOpe.bf.rsv_1;}
+    else    if(styp2 == ALL_STOP)    {sw2 = curOpe.bf.all_stop;}
+    else {sw2 = false;}
+
+    return sw1 && sw2;
+}
+
 bool HbUserOpe::ChkCtrlSwRiseEdge(SW_TYPE styp)
 {
             if(styp == BRK_L)       {return curOpe.bf.brk_l     && !oldOpe.bf.brk_l;}
     else    if(styp == BRK_R)       {return curOpe.bf.brk_r     && !oldOpe.bf.brk_r;}
     else    if(styp == FLT_ON)      {return curOpe.bf.flt_on    && !oldOpe.bf.flt_on;}
     else    if(styp == FLT_OFF)     {return curOpe.bf.flt_off    && !oldOpe.bf.flt_off;}
-    else    if(styp == FL_BRK)      {return curOpe.bf.full_brk  && !oldOpe.bf.full_brk;}
-    else    if(styp == MOT_STOP)    {return curOpe.bf.mot_stop    && !oldOpe.bf.mot_stop;}
-    else    if(styp == R_1)         {return curOpe.bf.rsv_1    && !oldOpe.bf.rsv_1;}
-    else    if(styp == R_2)         {return curOpe.bf.rsv_2    && !oldOpe.bf.rsv_2;}
-    else    if(styp == R_3)         {return curOpe.bf.rsv_3    && !oldOpe.bf.rsv_3;}
+    else    if(styp == F_ENG_UP)    {return curOpe.bf.f_eng_up  && !oldOpe.bf.f_eng_up;}
+    else    if(styp == F_ENG_DOWN)  {return curOpe.bf.f_eng_down  && !oldOpe.bf.f_eng_down;}
+    else    if(styp == R_ENG_UP)    {return curOpe.bf.r_eng_up  && !oldOpe.bf.r_eng_up;}
+    else    if(styp == R_ENG_DOWN)  {return curOpe.bf.r_eng_down  && !oldOpe.bf.r_eng_down;}
+    else    if(styp == R_1)         {return curOpe.bf.rsv_1     && !oldOpe.bf.rsv_1;}
     else    if(styp == ALL_STOP)    {return curOpe.bf.all_stop  && !oldOpe.bf.all_stop;}
     else{return false;}
 }