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.
HbUserOpe.cpp
- Committer:
- MasashiNomura
- Date:
- 2018-12-21
- Revision:
- 33:eb260dbfc22a
- Parent:
- 31:56c554c560c1
- Child:
- 34:234b87f3e6ce
File content as of revision 33:eb260dbfc22a:
#include "HbUserOpe.h"
#include "fpga.h"
//=========================================
//コンストラクタ
//=========================================
HbUserOpe::HbUserOpe(){
oldOpe.w = curOpe.w = 0;
}
//=========================================
//デストラクタ
//=========================================
HbUserOpe::~HbUserOpe(){
}
typUserSw HbUserOpe::GetUserOpe()
{
oldOpe = curOpe;
curOpe.w = fpgaGetUserSw();
return curOpe;
}
INT16 HbUserOpe::GetAinAccel()
{
// max rpm 8500 ユーザー使用分として7000をマックスとする
// 0 ~ 1.00 -> 0.05 ~ 0.95を使用する(遊び分として)
INT16 ret = 0;
float anaval = AinAxl.read();
if(0.01 > anaval){
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{
ret = 0;
}
if(gf_DbgPrint.bf.ana1 == true){
sp.printf("Axl Rpm=%d val=%f\r\n",ret,anaval);
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 == 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 == ALL_STOP){return curOpe.bf.all_stop;}
else {return false;}
}
bool HbUserOpe::ChkCtrlSwAny()
{
UINT16 mask = 0x1;
for(int i = 0; i < 5; ++i){
if(curOpe.w & mask){
return true;
}
mask = mask << 1;
}
return false;
}
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;}
else{return false;}
}