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@34:234b87f3e6ce, 2018-12-22 (annotated)
- Committer:
- MasashiNomura
- Date:
- Sat Dec 22 09:08:10 2018 +0000
- Revision:
- 34:234b87f3e6ce
- Parent:
- 33:eb260dbfc22a
- Child:
- 36:2cc739c7e4cb
12/22 Modify SW etc
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| MasashiNomura | 22:24c9c2dedca9 | 1 | #include "HbUserOpe.h" |
| MasashiNomura | 22:24c9c2dedca9 | 2 | #include "fpga.h" |
| MasashiNomura | 22:24c9c2dedca9 | 3 | //========================================= |
| MasashiNomura | 22:24c9c2dedca9 | 4 | //コンストラクタ |
| MasashiNomura | 22:24c9c2dedca9 | 5 | //========================================= |
| MasashiNomura | 22:24c9c2dedca9 | 6 | HbUserOpe::HbUserOpe(){ |
| MasashiNomura | 22:24c9c2dedca9 | 7 | oldOpe.w = curOpe.w = 0; |
| MasashiNomura | 34:234b87f3e6ce | 8 | AinAxlVal = 0; |
| MasashiNomura | 22:24c9c2dedca9 | 9 | } |
| MasashiNomura | 22:24c9c2dedca9 | 10 | |
| MasashiNomura | 22:24c9c2dedca9 | 11 | //========================================= |
| MasashiNomura | 22:24c9c2dedca9 | 12 | //デストラクタ |
| MasashiNomura | 22:24c9c2dedca9 | 13 | //========================================= |
| MasashiNomura | 22:24c9c2dedca9 | 14 | HbUserOpe::~HbUserOpe(){ |
| MasashiNomura | 22:24c9c2dedca9 | 15 | } |
| MasashiNomura | 22:24c9c2dedca9 | 16 | |
| MasashiNomura | 22:24c9c2dedca9 | 17 | typUserSw HbUserOpe::GetUserOpe() |
| MasashiNomura | 22:24c9c2dedca9 | 18 | { |
| MasashiNomura | 22:24c9c2dedca9 | 19 | oldOpe = curOpe; |
| MasashiNomura | 22:24c9c2dedca9 | 20 | curOpe.w = fpgaGetUserSw(); |
| MasashiNomura | 22:24c9c2dedca9 | 21 | return curOpe; |
| MasashiNomura | 23:79e20be4bc5b | 22 | } |
| MasashiNomura | 33:eb260dbfc22a | 23 | INT16 HbUserOpe::GetAinAccel() |
| MasashiNomura | 33:eb260dbfc22a | 24 | { |
| MasashiNomura | 34:234b87f3e6ce | 25 | // max rpm 8500 ユーザー使用分として7000をマックスとする(仮) |
| MasashiNomura | 34:234b87f3e6ce | 26 | // 0 ~ 1.00 -> 0.01 ~ 0.97を使用する(遊び分として) |
| MasashiNomura | 33:eb260dbfc22a | 27 | INT16 ret = 0; |
| MasashiNomura | 34:234b87f3e6ce | 28 | AinAxlVal = AinAxl.read(); |
| MasashiNomura | 34:234b87f3e6ce | 29 | if(MIN_EFF_ANA_VAL > AinAxlVal){ |
| MasashiNomura | 33:eb260dbfc22a | 30 | ret = 0; |
| MasashiNomura | 34:234b87f3e6ce | 31 | } else if(AinAxlVal >= MIN_EFF_ANA_VAL && AinAxlVal <= MAX_EFF_ANA_VAL){ |
| MasashiNomura | 34:234b87f3e6ce | 32 | ret = (MAX_RPM_USERSET - MIN_RPM_TOTAL) * (AinAxlVal - MIN_EFF_ANA_VAL) / (MAX_EFF_ANA_VAL - MIN_EFF_ANA_VAL) + MIN_RPM_TOTAL; |
| MasashiNomura | 34:234b87f3e6ce | 33 | } else if(AinAxlVal > MAX_EFF_ANA_VAL){ |
| MasashiNomura | 34:234b87f3e6ce | 34 | ret = MAX_RPM_USERSET; |
| MasashiNomura | 33:eb260dbfc22a | 35 | }else{ |
| MasashiNomura | 33:eb260dbfc22a | 36 | ret = 0; |
| MasashiNomura | 33:eb260dbfc22a | 37 | } |
| MasashiNomura | 33:eb260dbfc22a | 38 | if(gf_DbgPrint.bf.ana1 == true){ |
| MasashiNomura | 34:234b87f3e6ce | 39 | sp.printf("Axl Rpm=%d val=%f\r\n",ret,AinAxlVal); |
| MasashiNomura | 33:eb260dbfc22a | 40 | gf_DbgPrint.bf.ana1 = false; |
| MasashiNomura | 33:eb260dbfc22a | 41 | } |
| MasashiNomura | 33:eb260dbfc22a | 42 | //sp.printf("Axl Rpm=%d val=%f\r\n",ret,anaval); |
| MasashiNomura | 33:eb260dbfc22a | 43 | return ret; |
| MasashiNomura | 33:eb260dbfc22a | 44 | } |
| MasashiNomura | 34:234b87f3e6ce | 45 | |
| MasashiNomura | 23:79e20be4bc5b | 46 | bool HbUserOpe::ChkCtrlSW(SW_TYPE styp) |
| MasashiNomura | 23:79e20be4bc5b | 47 | { |
| MasashiNomura | 30:13ada1a24c59 | 48 | if(styp == BRK_L) {return curOpe.bf.brk_l;} |
| MasashiNomura | 30:13ada1a24c59 | 49 | else if(styp == BRK_R) {return curOpe.bf.brk_r;} |
| MasashiNomura | 34:234b87f3e6ce | 50 | else if(styp == FLT_ON) {return curOpe.bf.flt_on;} |
| MasashiNomura | 34:234b87f3e6ce | 51 | else if(styp == FLT_OFF) {return curOpe.bf.flt_off;} |
| MasashiNomura | 34:234b87f3e6ce | 52 | else if(styp == FL_BRK) {return curOpe.bf.full_brk;} |
| MasashiNomura | 30:13ada1a24c59 | 53 | else if(styp == MOT_STOP){return curOpe.bf.mot_stop;} |
| MasashiNomura | 34:234b87f3e6ce | 54 | else if(styp == R_1) {return curOpe.bf.rsv_1;} |
| MasashiNomura | 34:234b87f3e6ce | 55 | else if(styp == R_2) {return curOpe.bf.rsv_2;} |
| MasashiNomura | 34:234b87f3e6ce | 56 | else if(styp == R_3) {return curOpe.bf.rsv_3;} |
| MasashiNomura | 30:13ada1a24c59 | 57 | else if(styp == ALL_STOP){return curOpe.bf.all_stop;} |
| MasashiNomura | 31:56c554c560c1 | 58 | else {return false;} |
| MasashiNomura | 26:732bc37fbefd | 59 | } |
| MasashiNomura | 23:79e20be4bc5b | 60 | bool HbUserOpe::ChkCtrlSwAny() |
| MasashiNomura | 23:79e20be4bc5b | 61 | { |
| MasashiNomura | 23:79e20be4bc5b | 62 | UINT16 mask = 0x1; |
| MasashiNomura | 34:234b87f3e6ce | 63 | for(int i = 0; i < 10; ++i){ |
| MasashiNomura | 23:79e20be4bc5b | 64 | if(curOpe.w & mask){ |
| MasashiNomura | 23:79e20be4bc5b | 65 | return true; |
| MasashiNomura | 23:79e20be4bc5b | 66 | } |
| MasashiNomura | 23:79e20be4bc5b | 67 | mask = mask << 1; |
| MasashiNomura | 23:79e20be4bc5b | 68 | } |
| MasashiNomura | 23:79e20be4bc5b | 69 | return false; |
| MasashiNomura | 23:79e20be4bc5b | 70 | } |
| MasashiNomura | 30:13ada1a24c59 | 71 | bool HbUserOpe::ChkCtrlSwRiseEdge(SW_TYPE styp) |
| MasashiNomura | 26:732bc37fbefd | 72 | { |
| MasashiNomura | 34:234b87f3e6ce | 73 | if(styp == BRK_L) {return curOpe.bf.brk_l && !oldOpe.bf.brk_l;} |
| MasashiNomura | 34:234b87f3e6ce | 74 | else if(styp == BRK_R) {return curOpe.bf.brk_r && !oldOpe.bf.brk_r;} |
| MasashiNomura | 34:234b87f3e6ce | 75 | else if(styp == FLT_ON) {return curOpe.bf.flt_on && !oldOpe.bf.flt_on;} |
| MasashiNomura | 34:234b87f3e6ce | 76 | else if(styp == FLT_OFF) {return curOpe.bf.flt_off && !oldOpe.bf.flt_off;} |
| MasashiNomura | 34:234b87f3e6ce | 77 | else if(styp == FL_BRK) {return curOpe.bf.full_brk && !oldOpe.bf.full_brk;} |
| MasashiNomura | 34:234b87f3e6ce | 78 | else if(styp == MOT_STOP) {return curOpe.bf.mot_stop && !oldOpe.bf.mot_stop;} |
| MasashiNomura | 34:234b87f3e6ce | 79 | else if(styp == R_1) {return curOpe.bf.rsv_1 && !oldOpe.bf.rsv_1;} |
| MasashiNomura | 34:234b87f3e6ce | 80 | else if(styp == R_2) {return curOpe.bf.rsv_2 && !oldOpe.bf.rsv_2;} |
| MasashiNomura | 34:234b87f3e6ce | 81 | else if(styp == R_3) {return curOpe.bf.rsv_3 && !oldOpe.bf.rsv_3;} |
| MasashiNomura | 34:234b87f3e6ce | 82 | else if(styp == ALL_STOP) {return curOpe.bf.all_stop && !oldOpe.bf.all_stop;} |
| MasashiNomura | 31:56c554c560c1 | 83 | else{return false;} |
| MasashiNomura | 26:732bc37fbefd | 84 | } |