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.
Diff: HbUserOpe.cpp
- Revision:
- 34:234b87f3e6ce
- Parent:
- 33:eb260dbfc22a
- Child:
- 36:2cc739c7e4cb
--- a/HbUserOpe.cpp Fri Dec 21 12:31:17 2018 +0000
+++ b/HbUserOpe.cpp Sat Dec 22 09:08:10 2018 +0000
@@ -5,6 +5,7 @@
//=========================================
HbUserOpe::HbUserOpe(){
oldOpe.w = curOpe.w = 0;
+ AinAxlVal = 0;
}
//=========================================
@@ -21,54 +22,45 @@
}
INT16 HbUserOpe::GetAinAccel()
{
- // max rpm 8500 ユーザー使用分として7000をマックスとする
- // 0 ~ 1.00 -> 0.05 ~ 0.95を使用する(遊び分として)
+ // max rpm 8500 ユーザー使用分として7000をマックスとする(仮)
+ // 0 ~ 1.00 -> 0.01 ~ 0.97を使用する(遊び分として)
INT16 ret = 0;
- float anaval = AinAxl.read();
- if(0.01 > anaval){
+ AinAxlVal = AinAxl.read();
+ if(MIN_EFF_ANA_VAL > AinAxlVal){
ret = 0;
- } else if(anaval >= 0.01 && anaval <= 0.97){
- ret = 5500 * (anaval - 0.01) / 0.96 + 1500;
- } else if(anaval > 0.97){
- ret = 7000;
+ } else if(AinAxlVal >= MIN_EFF_ANA_VAL && AinAxlVal <= MAX_EFF_ANA_VAL){
+ ret = (MAX_RPM_USERSET - MIN_RPM_TOTAL) * (AinAxlVal - MIN_EFF_ANA_VAL) / (MAX_EFF_ANA_VAL - MIN_EFF_ANA_VAL) + MIN_RPM_TOTAL;
+ } else if(AinAxlVal > MAX_EFF_ANA_VAL){
+ ret = MAX_RPM_USERSET;
}else{
ret = 0;
}
if(gf_DbgPrint.bf.ana1 == true){
- sp.printf("Axl Rpm=%d val=%f\r\n",ret,anaval);
+ sp.printf("Axl Rpm=%d val=%f\r\n",ret,AinAxlVal);
gf_DbgPrint.bf.ana1 = false;
}
//sp.printf("Axl Rpm=%d val=%f\r\n",ret,anaval);
return ret;
}
-// bool HbUserOpe::ChkCtrlSW(SW_TYPE styp)
-// {
-// if(styp == ACCEL_R){return curOpe.bf.brk_l;}
-// else if(styp == ACCEL_L){return curOpe.bf.axl_l;}
-// else if(styp == STOP){return curOpe.bf.stop;}
-// else if(styp == YAW_CTRL){return curOpe.bf.y_ctrl;}
-// else/*if(styp == ENG_STOP)*/{return curOpe.bf.eng_stop;}
-// // UINT16 mask = 0x1 << styp;
-// // return curOpe.w & mask;
-// }
+
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 == R_1) {return curOpe.bf.resv_1;}
- else if(styp == R_2) {return curOpe.bf.resv_2;}
+ 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_3) {return curOpe.bf.resv_3;}
- else if(styp == R_4) {return curOpe.bf.resv_4;}
- else if(styp == R_5) {return curOpe.bf.resv_5;}
- else if(styp == R_6) {return curOpe.bf.resv_6;}
+ 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 {return false;}
}
bool HbUserOpe::ChkCtrlSwAny()
{
UINT16 mask = 0x1;
- for(int i = 0; i < 5; ++i){
+ for(int i = 0; i < 10; ++i){
if(curOpe.w & mask){
return true;
}
@@ -78,15 +70,15 @@
}
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 == R_1) {return curOpe.bf.resv_1 && !oldOpe.bf.resv_1;}
- else if(styp == R_2) {return curOpe.bf.resv_2 && !oldOpe.bf.resv_2;}
- else if(styp == MOT_STOP){return curOpe.bf.mot_stop && !oldOpe.bf.mot_stop;}
- else if(styp == R_3) {return curOpe.bf.resv_3 && !oldOpe.bf.resv_3;}
- else if(styp == R_4) {return curOpe.bf.resv_4 && !oldOpe.bf.resv_4;}
- else if(styp == R_5) {return curOpe.bf.resv_5 && !oldOpe.bf.resv_5;}
- else if(styp == R_6) {return curOpe.bf.resv_6 && !oldOpe.bf.resv_6;}
- else if(styp == ALL_STOP){return curOpe.bf.all_stop && !oldOpe.bf.all_stop;}
+ 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 == ALL_STOP) {return curOpe.bf.all_stop && !oldOpe.bf.all_stop;}
else{return false;}
}