SwitchMode
Dependencies: BEAR_Protocol InverseLeg iSerial mbed
main.cpp@1:183e6088a1fa, 2016-01-22 (annotated)
- Committer:
- icyzkungz
- Date:
- Fri Jan 22 08:03:29 2016 +0000
- Revision:
- 1:183e6088a1fa
- Parent:
- 0:f73c80b36c20
- Child:
- 2:d6be1c49d9d5
Fixed Push Button problem
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
icyzkungz | 0:f73c80b36c20 | 1 | #include "string" |
icyzkungz | 0:f73c80b36c20 | 2 | #include "BEAR_Protocol.h" |
icyzkungz | 0:f73c80b36c20 | 3 | #include "Kinematic.h" |
icyzkungz | 0:f73c80b36c20 | 4 | |
icyzkungz | 0:f73c80b36c20 | 5 | Serial pc(SERIAL_TX,SERIAL_RX); |
icyzkungz | 0:f73c80b36c20 | 6 | Bear_Communicate bcom(PA_15,PB_7,115200); |
icyzkungz | 0:f73c80b36c20 | 7 | |
icyzkungz | 0:f73c80b36c20 | 8 | DigitalIn button(USER_BUTTON); |
icyzkungz | 0:f73c80b36c20 | 9 | |
icyzkungz | 0:f73c80b36c20 | 10 | #define LEFT_SIDE 0x01 |
icyzkungz | 0:f73c80b36c20 | 11 | #define RIGHT_SIDE 0x02 |
icyzkungz | 0:f73c80b36c20 | 12 | |
icyzkungz | 0:f73c80b36c20 | 13 | void SwMode() |
icyzkungz | 0:f73c80b36c20 | 14 | { |
icyzkungz | 0:f73c80b36c20 | 15 | int option; // user's entered option will be saved in this variable |
icyzkungz | 0:f73c80b36c20 | 16 | float temp; |
icyzkungz | 0:f73c80b36c20 | 17 | float LH,LK,RH,RK; |
icyzkungz | 0:f73c80b36c20 | 18 | float LLink[2],RLink[2]; |
icyzkungz | 0:f73c80b36c20 | 19 | struct max_ang { |
icyzkungz | 0:f73c80b36c20 | 20 | float Hip; |
icyzkungz | 0:f73c80b36c20 | 21 | float Knee; |
icyzkungz | 0:f73c80b36c20 | 22 | }; |
icyzkungz | 0:f73c80b36c20 | 23 | struct min_ang { |
icyzkungz | 0:f73c80b36c20 | 24 | float Hip; |
icyzkungz | 0:f73c80b36c20 | 25 | float Knee; |
icyzkungz | 0:f73c80b36c20 | 26 | }; |
icyzkungz | 0:f73c80b36c20 | 27 | max_ang Lmax,Lmin; |
icyzkungz | 0:f73c80b36c20 | 28 | min_ang Rmax,Rmin; |
icyzkungz | 1:183e6088a1fa | 29 | Lmax.Knee = Lmax.Hip = Lmin.Knee = Lmin.Hip = Rmax.Knee = Rmax.Hip = Rmin.Knee = Rmin.Hip = 0; |
icyzkungz | 0:f73c80b36c20 | 30 | bool a,b,c,d; |
icyzkungz | 0:f73c80b36c20 | 31 | a = b = c = d = false; |
icyzkungz | 0:f73c80b36c20 | 32 | float temp_LH=0,temp_LK=0,temp_RH=0,temp_RK=0; |
icyzkungz | 0:f73c80b36c20 | 33 | do { // do-while loop starts here.that display menu again and again until user select to exit program |
icyzkungz | 0:f73c80b36c20 | 34 | // Displaying Options for the menu |
icyzkungz | 0:f73c80b36c20 | 35 | pc.printf("************Don't Forget to Save Data************\n"); |
icyzkungz | 0:f73c80b36c20 | 36 | pc.printf("*\t1) Motor Left Hip \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 37 | pc.printf("*\t2) Motor Left Knee \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 38 | pc.printf("*\t3) Motor Right Hip \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 39 | pc.printf("*\t4) Motor Right Knee \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 40 | pc.printf("*\t5) Kp : Left Hip \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 41 | pc.printf("*\t6) Ki : Left Hip \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 42 | pc.printf("*\t7) Kd : Left Hip \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 43 | pc.printf("*\t8) Save Left Hip(p,i,d) data\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 44 | pc.printf("*\t9) Kp : Left Knee \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 45 | pc.printf("*\t10) Ki : Left Knee \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 46 | pc.printf("*\t11) Kd : Left Knee \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 47 | pc.printf("*\t12) Save Left Knee(p,i,d) data\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 48 | pc.printf("*\t13) Kp : Right Hip \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 49 | pc.printf("*\t14) Ki : Right Hip \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 50 | pc.printf("*\t15) Kd : Right Hip \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 51 | pc.printf("*\t16) Save Right Hip(p,i,d) data\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 52 | pc.printf("*\t17) Kp : Right Knee \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 53 | pc.printf("*\t18) Ki : Right Knee \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 54 | pc.printf("*\t19) Kd : Right Knee \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 55 | pc.printf("*\t20) Save Right Knee data\t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 56 | pc.printf("*\t21) Set Left Hip Margin\n"); |
icyzkungz | 0:f73c80b36c20 | 57 | pc.printf("*\t22) Set Left Knee Margin\n"); |
icyzkungz | 0:f73c80b36c20 | 58 | pc.printf("*\t23) Set Right Hip Margin\n"); |
icyzkungz | 0:f73c80b36c20 | 59 | pc.printf("*\t24) Set Right Knee Margin\n"); |
icyzkungz | 1:183e6088a1fa | 60 | pc.printf("*\t25) Set Offset\n"); |
icyzkungz | 1:183e6088a1fa | 61 | pc.printf("*\t26) Set Body Lenght of Left Side\n"); |
icyzkungz | 1:183e6088a1fa | 62 | pc.printf("*\t27) Set Body Lenght of Right Side\n"); |
icyzkungz | 1:183e6088a1fa | 63 | pc.printf("*\t28) Set Maximum Hip Angle Range\n"); |
icyzkungz | 1:183e6088a1fa | 64 | pc.printf("*\t29) Set Minimum Hip Angle Range\n"); |
icyzkungz | 1:183e6088a1fa | 65 | pc.printf("*\t30) Set Maximum Knee Angle Range\n"); |
icyzkungz | 1:183e6088a1fa | 66 | pc.printf("*\t31) Set Minimum Knee Angle Range\n"); |
icyzkungz | 0:f73c80b36c20 | 67 | |
icyzkungz | 0:f73c80b36c20 | 68 | pc.printf("*\t40) Exit Program \t\t\t*\n"); |
icyzkungz | 0:f73c80b36c20 | 69 | pc.printf("************Don't Forget to Save Data************\n"); |
icyzkungz | 0:f73c80b36c20 | 70 | // Prompting user to enter an option according to menu |
icyzkungz | 0:f73c80b36c20 | 71 | pc.printf("Please select an option : "); |
icyzkungz | 0:f73c80b36c20 | 72 | |
icyzkungz | 0:f73c80b36c20 | 73 | pc.scanf("%d",&option); |
icyzkungz | 0:f73c80b36c20 | 74 | |
icyzkungz | 0:f73c80b36c20 | 75 | pc.printf("\n"); |
icyzkungz | 0:f73c80b36c20 | 76 | |
icyzkungz | 0:f73c80b36c20 | 77 | if(option == 1)// Left Hip |
icyzkungz | 0:f73c80b36c20 | 78 | do { |
icyzkungz | 0:f73c80b36c20 | 79 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 80 | //Send Position to Motor |
icyzkungz | 0:f73c80b36c20 | 81 | pc.printf("Input Degree : \n"); |
icyzkungz | 0:f73c80b36c20 | 82 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 83 | if(temp!=9999) { |
icyzkungz | 0:f73c80b36c20 | 84 | LH = temp; |
icyzkungz | 0:f73c80b36c20 | 85 | pc.printf("Move Left Hip Motor to %f Degree\n",LH); |
icyzkungz | 0:f73c80b36c20 | 86 | |
icyzkungz | 0:f73c80b36c20 | 87 | bcom.setMotorPos(LEFT_SIDE,LH,temp_LK); |
icyzkungz | 0:f73c80b36c20 | 88 | temp_LH = LH; |
icyzkungz | 0:f73c80b36c20 | 89 | |
icyzkungz | 0:f73c80b36c20 | 90 | /********************Save Data*********************/ |
icyzkungz | 0:f73c80b36c20 | 91 | } else bcom.saveDataToEEPROM(LEFT_SIDE,MOTOR_UPPER_ANG); |
icyzkungz | 0:f73c80b36c20 | 92 | |
icyzkungz | 0:f73c80b36c20 | 93 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 94 | |
icyzkungz | 0:f73c80b36c20 | 95 | else if(option == 2) //Left Knee |
icyzkungz | 0:f73c80b36c20 | 96 | do { |
icyzkungz | 0:f73c80b36c20 | 97 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 98 | |
icyzkungz | 0:f73c80b36c20 | 99 | //Send Position to Motor |
icyzkungz | 0:f73c80b36c20 | 100 | pc.printf("Input Degree : \n"); |
icyzkungz | 0:f73c80b36c20 | 101 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 102 | if(temp!=9999) { |
icyzkungz | 0:f73c80b36c20 | 103 | LK = temp; |
icyzkungz | 0:f73c80b36c20 | 104 | pc.printf("Move Left Knee Motor to %f Degree\n",LK); |
icyzkungz | 0:f73c80b36c20 | 105 | |
icyzkungz | 0:f73c80b36c20 | 106 | bcom.setMotorPos(LEFT_SIDE,temp_LH,LK); |
icyzkungz | 0:f73c80b36c20 | 107 | temp_LK = LK; |
icyzkungz | 0:f73c80b36c20 | 108 | |
icyzkungz | 0:f73c80b36c20 | 109 | |
icyzkungz | 0:f73c80b36c20 | 110 | /********************Save Data*********************/ |
icyzkungz | 0:f73c80b36c20 | 111 | } else bcom.saveDataToEEPROM(LEFT_SIDE,MOTOR_LOWER_ANG); |
icyzkungz | 0:f73c80b36c20 | 112 | |
icyzkungz | 0:f73c80b36c20 | 113 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 114 | |
icyzkungz | 0:f73c80b36c20 | 115 | |
icyzkungz | 0:f73c80b36c20 | 116 | else if(option == 3) { //Right Hip |
icyzkungz | 0:f73c80b36c20 | 117 | do { |
icyzkungz | 0:f73c80b36c20 | 118 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 119 | |
icyzkungz | 0:f73c80b36c20 | 120 | //Send Position to Motor |
icyzkungz | 0:f73c80b36c20 | 121 | pc.printf("Input Degree : \n"); |
icyzkungz | 0:f73c80b36c20 | 122 | pc.scanf("%f",&RH); |
icyzkungz | 0:f73c80b36c20 | 123 | if(temp!=9999) { |
icyzkungz | 0:f73c80b36c20 | 124 | RH = temp; |
icyzkungz | 0:f73c80b36c20 | 125 | pc.printf("Move Right Hip Motor to %f Degree\n",RH); |
icyzkungz | 0:f73c80b36c20 | 126 | |
icyzkungz | 0:f73c80b36c20 | 127 | bcom.setMotorPos(RIGHT_SIDE,RH,temp_RK); |
icyzkungz | 0:f73c80b36c20 | 128 | temp_RH = RH; |
icyzkungz | 0:f73c80b36c20 | 129 | |
icyzkungz | 0:f73c80b36c20 | 130 | |
icyzkungz | 0:f73c80b36c20 | 131 | /********************Save Data*********************/ |
icyzkungz | 0:f73c80b36c20 | 132 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,MOTOR_UPPER_ANG); |
icyzkungz | 0:f73c80b36c20 | 133 | |
icyzkungz | 0:f73c80b36c20 | 134 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 135 | |
icyzkungz | 0:f73c80b36c20 | 136 | } else if(option == 4) { //Right Knee |
icyzkungz | 0:f73c80b36c20 | 137 | do { |
icyzkungz | 0:f73c80b36c20 | 138 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 139 | |
icyzkungz | 0:f73c80b36c20 | 140 | //Send Position to Motor |
icyzkungz | 0:f73c80b36c20 | 141 | pc.printf("Input Degree : \n"); |
icyzkungz | 0:f73c80b36c20 | 142 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 143 | |
icyzkungz | 0:f73c80b36c20 | 144 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 145 | RK = temp; |
icyzkungz | 0:f73c80b36c20 | 146 | pc.printf("Move Right Knee Motor to %f Degree\n",RK); |
icyzkungz | 0:f73c80b36c20 | 147 | |
icyzkungz | 0:f73c80b36c20 | 148 | bcom.setMotorPos(RIGHT_SIDE,temp_RH,RK); |
icyzkungz | 0:f73c80b36c20 | 149 | temp_RK = RK; |
icyzkungz | 0:f73c80b36c20 | 150 | |
icyzkungz | 0:f73c80b36c20 | 151 | |
icyzkungz | 0:f73c80b36c20 | 152 | /********************Save Data*********************/ |
icyzkungz | 0:f73c80b36c20 | 153 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,MOTOR_LOWER_ANG); |
icyzkungz | 0:f73c80b36c20 | 154 | |
icyzkungz | 0:f73c80b36c20 | 155 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 156 | |
icyzkungz | 0:f73c80b36c20 | 157 | } else if(option == 5) { //Left Hip |
icyzkungz | 0:f73c80b36c20 | 158 | do { |
icyzkungz | 0:f73c80b36c20 | 159 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 160 | pc.printf("\nInput Kp of Left Hip\n"); |
icyzkungz | 0:f73c80b36c20 | 161 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 162 | |
icyzkungz | 0:f73c80b36c20 | 163 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 164 | pc.printf("\nChange Kp of Left Hip to %f",temp); |
icyzkungz | 0:f73c80b36c20 | 165 | |
icyzkungz | 0:f73c80b36c20 | 166 | bcom.setUpMotorKp(LEFT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 167 | } else bcom.saveDataToEEPROM(LEFT_SIDE,KP_UPPER_MOTOR); |
icyzkungz | 0:f73c80b36c20 | 168 | |
icyzkungz | 0:f73c80b36c20 | 169 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 170 | |
icyzkungz | 0:f73c80b36c20 | 171 | } else if(option == 6) { //Left Hip |
icyzkungz | 0:f73c80b36c20 | 172 | do { |
icyzkungz | 0:f73c80b36c20 | 173 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 174 | pc.printf("\nInput Ki of Left Hip\n"); |
icyzkungz | 0:f73c80b36c20 | 175 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 176 | |
icyzkungz | 0:f73c80b36c20 | 177 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 178 | pc.printf("\nChange Ki of Left Hip to %f",temp); |
icyzkungz | 0:f73c80b36c20 | 179 | |
icyzkungz | 0:f73c80b36c20 | 180 | bcom.setUpMotorKi(LEFT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 181 | } else bcom.saveDataToEEPROM(LEFT_SIDE,KI_UPPER_MOTOR); |
icyzkungz | 0:f73c80b36c20 | 182 | |
icyzkungz | 0:f73c80b36c20 | 183 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 184 | |
icyzkungz | 0:f73c80b36c20 | 185 | } else if(option == 7) { //Left Hip |
icyzkungz | 0:f73c80b36c20 | 186 | do { |
icyzkungz | 0:f73c80b36c20 | 187 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 188 | pc.printf("\nInput Kd of Left Hip\n"); |
icyzkungz | 0:f73c80b36c20 | 189 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 190 | |
icyzkungz | 0:f73c80b36c20 | 191 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 192 | pc.printf("\nChange Kd of Left Hip to %f",temp); |
icyzkungz | 0:f73c80b36c20 | 193 | |
icyzkungz | 0:f73c80b36c20 | 194 | bcom.setUpMotorKd(LEFT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 195 | } else bcom.saveDataToEEPROM(LEFT_SIDE,KD_UPPER_MOTOR); |
icyzkungz | 0:f73c80b36c20 | 196 | |
icyzkungz | 0:f73c80b36c20 | 197 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 198 | |
icyzkungz | 0:f73c80b36c20 | 199 | } else if(option == 8) { |
icyzkungz | 0:f73c80b36c20 | 200 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 201 | /*******************************Save Left Hip data*************************************/ |
icyzkungz | 0:f73c80b36c20 | 202 | |
icyzkungz | 0:f73c80b36c20 | 203 | } else if(option == 9) { //Left Knee |
icyzkungz | 0:f73c80b36c20 | 204 | do { |
icyzkungz | 0:f73c80b36c20 | 205 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 206 | pc.printf("\nInput Kp of Left Knee\n"); |
icyzkungz | 0:f73c80b36c20 | 207 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 208 | |
icyzkungz | 0:f73c80b36c20 | 209 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 210 | pc.printf("\nChange Kp of Left Knee to %f",temp); |
icyzkungz | 0:f73c80b36c20 | 211 | |
icyzkungz | 0:f73c80b36c20 | 212 | bcom.setLowMotorKp(LEFT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 213 | } else bcom.saveDataToEEPROM(LEFT_SIDE,KP_LOWER_MOTOR); |
icyzkungz | 0:f73c80b36c20 | 214 | |
icyzkungz | 0:f73c80b36c20 | 215 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 216 | |
icyzkungz | 0:f73c80b36c20 | 217 | } else if(option == 10) { //Left Knee |
icyzkungz | 0:f73c80b36c20 | 218 | do { |
icyzkungz | 0:f73c80b36c20 | 219 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 220 | pc.printf("\nInput Ki of Left Knee\n"); |
icyzkungz | 0:f73c80b36c20 | 221 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 222 | |
icyzkungz | 0:f73c80b36c20 | 223 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 224 | pc.printf("\nChange Ki of Left Knee to %f",temp); |
icyzkungz | 0:f73c80b36c20 | 225 | |
icyzkungz | 0:f73c80b36c20 | 226 | bcom.setLowMotorKi(LEFT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 227 | } else bcom.saveDataToEEPROM(LEFT_SIDE,KI_LOWER_MOTOR); |
icyzkungz | 0:f73c80b36c20 | 228 | |
icyzkungz | 0:f73c80b36c20 | 229 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 230 | |
icyzkungz | 0:f73c80b36c20 | 231 | } else if(option == 11) { //Left Knee |
icyzkungz | 0:f73c80b36c20 | 232 | do { |
icyzkungz | 0:f73c80b36c20 | 233 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 234 | pc.printf("\nInput Kd of Left Knee\n"); |
icyzkungz | 0:f73c80b36c20 | 235 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 236 | |
icyzkungz | 0:f73c80b36c20 | 237 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 238 | pc.printf("\nChange Kd of Left Knee to %f",temp); |
icyzkungz | 0:f73c80b36c20 | 239 | |
icyzkungz | 0:f73c80b36c20 | 240 | bcom.setLowMotorKd(LEFT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 241 | } else bcom.saveDataToEEPROM(LEFT_SIDE,KD_LOWER_MOTOR); |
icyzkungz | 0:f73c80b36c20 | 242 | |
icyzkungz | 0:f73c80b36c20 | 243 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 244 | |
icyzkungz | 0:f73c80b36c20 | 245 | |
icyzkungz | 0:f73c80b36c20 | 246 | } else if(option == 12) { |
icyzkungz | 0:f73c80b36c20 | 247 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 248 | /*******************************Save Left Knee data*************************************/ |
icyzkungz | 0:f73c80b36c20 | 249 | |
icyzkungz | 0:f73c80b36c20 | 250 | |
icyzkungz | 0:f73c80b36c20 | 251 | } else if(option == 13) { //Right Hip |
icyzkungz | 0:f73c80b36c20 | 252 | do { |
icyzkungz | 0:f73c80b36c20 | 253 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 254 | pc.printf("\nInput Kp of Right Hip\n"); |
icyzkungz | 0:f73c80b36c20 | 255 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 256 | |
icyzkungz | 0:f73c80b36c20 | 257 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 258 | pc.printf("\nChange Kp of Right Hip to %f",temp); |
icyzkungz | 0:f73c80b36c20 | 259 | |
icyzkungz | 0:f73c80b36c20 | 260 | bcom.setUpMotorKp(RIGHT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 261 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,KP_UPPER_MOTOR); |
icyzkungz | 0:f73c80b36c20 | 262 | |
icyzkungz | 0:f73c80b36c20 | 263 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 264 | |
icyzkungz | 0:f73c80b36c20 | 265 | } else if(option == 14) { //Right Hip |
icyzkungz | 0:f73c80b36c20 | 266 | do { |
icyzkungz | 0:f73c80b36c20 | 267 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 268 | pc.printf("\nInput Ki of Right Hip\n"); |
icyzkungz | 0:f73c80b36c20 | 269 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 270 | |
icyzkungz | 0:f73c80b36c20 | 271 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 272 | pc.printf("\nChange Ki of Right Hip to %f",temp); |
icyzkungz | 0:f73c80b36c20 | 273 | |
icyzkungz | 0:f73c80b36c20 | 274 | bcom.setUpMotorKi(RIGHT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 275 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,KI_UPPER_MOTOR); |
icyzkungz | 0:f73c80b36c20 | 276 | |
icyzkungz | 0:f73c80b36c20 | 277 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 278 | |
icyzkungz | 0:f73c80b36c20 | 279 | } else if(option == 15) { //Right Hip |
icyzkungz | 0:f73c80b36c20 | 280 | do { |
icyzkungz | 0:f73c80b36c20 | 281 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 282 | pc.printf("\nInput Kd of Right Hip\n"); |
icyzkungz | 0:f73c80b36c20 | 283 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 284 | |
icyzkungz | 0:f73c80b36c20 | 285 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 286 | pc.printf("\nChange Kd of Right Hip to %f",temp); |
icyzkungz | 0:f73c80b36c20 | 287 | |
icyzkungz | 0:f73c80b36c20 | 288 | bcom.setUpMotorKd(RIGHT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 289 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,KD_UPPER_MOTOR); |
icyzkungz | 0:f73c80b36c20 | 290 | |
icyzkungz | 0:f73c80b36c20 | 291 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 292 | |
icyzkungz | 0:f73c80b36c20 | 293 | |
icyzkungz | 0:f73c80b36c20 | 294 | } else if(option == 16) { |
icyzkungz | 0:f73c80b36c20 | 295 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 296 | /*******************************Save Right Hip data*************************************/ |
icyzkungz | 0:f73c80b36c20 | 297 | |
icyzkungz | 0:f73c80b36c20 | 298 | |
icyzkungz | 0:f73c80b36c20 | 299 | } else if(option == 17) { //Right Knee |
icyzkungz | 0:f73c80b36c20 | 300 | do { |
icyzkungz | 0:f73c80b36c20 | 301 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 302 | pc.printf("\nInput Kp of Right Knee\n"); |
icyzkungz | 0:f73c80b36c20 | 303 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 304 | |
icyzkungz | 0:f73c80b36c20 | 305 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 306 | pc.printf("\nChange Kp of Right Knee to %f",temp); |
icyzkungz | 0:f73c80b36c20 | 307 | |
icyzkungz | 0:f73c80b36c20 | 308 | bcom.setLowMotorKp(RIGHT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 309 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,KP_LOWER_MOTOR); |
icyzkungz | 0:f73c80b36c20 | 310 | |
icyzkungz | 0:f73c80b36c20 | 311 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 312 | |
icyzkungz | 0:f73c80b36c20 | 313 | } else if(option == 18) { //Right Knee |
icyzkungz | 0:f73c80b36c20 | 314 | do { |
icyzkungz | 0:f73c80b36c20 | 315 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 316 | pc.printf("\nInput Ki of Right Knee\n"); |
icyzkungz | 0:f73c80b36c20 | 317 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 318 | |
icyzkungz | 0:f73c80b36c20 | 319 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 320 | pc.printf("\nChange Ki of Right Knee to %f Degree\n",temp); |
icyzkungz | 0:f73c80b36c20 | 321 | |
icyzkungz | 0:f73c80b36c20 | 322 | bcom.setLowMotorKi(RIGHT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 323 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,KI_LOWER_MOTOR); |
icyzkungz | 0:f73c80b36c20 | 324 | |
icyzkungz | 0:f73c80b36c20 | 325 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 326 | |
icyzkungz | 0:f73c80b36c20 | 327 | } else if(option == 19) { //Right Knee |
icyzkungz | 0:f73c80b36c20 | 328 | do { |
icyzkungz | 0:f73c80b36c20 | 329 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 330 | pc.printf("\nInput Kd of Right Knee\n"); |
icyzkungz | 0:f73c80b36c20 | 331 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 332 | |
icyzkungz | 0:f73c80b36c20 | 333 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 334 | pc.printf("\nChange Kd of Right Knee to %f",temp); |
icyzkungz | 0:f73c80b36c20 | 335 | |
icyzkungz | 0:f73c80b36c20 | 336 | bcom.setLowMotorKd(RIGHT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 337 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,KD_LOWER_MOTOR); |
icyzkungz | 0:f73c80b36c20 | 338 | |
icyzkungz | 0:f73c80b36c20 | 339 | } while(temp != 9999); |
icyzkungz | 0:f73c80b36c20 | 340 | |
icyzkungz | 0:f73c80b36c20 | 341 | } else if(option == 20) { |
icyzkungz | 0:f73c80b36c20 | 342 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 343 | /*******************************Save Right Knee data*************************************/ |
icyzkungz | 0:f73c80b36c20 | 344 | |
icyzkungz | 0:f73c80b36c20 | 345 | |
icyzkungz | 0:f73c80b36c20 | 346 | } else if(option == 21) { //Left Hip Margin |
icyzkungz | 0:f73c80b36c20 | 347 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 348 | pc.printf("Input Margin\n"); |
icyzkungz | 0:f73c80b36c20 | 349 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 350 | |
icyzkungz | 0:f73c80b36c20 | 351 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 352 | pc.printf("\nChange Left Hip Margin to %f\n",temp); |
icyzkungz | 0:f73c80b36c20 | 353 | bcom.setUpMargin(LEFT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 354 | } else bcom.saveDataToEEPROM(LEFT_SIDE,UP_MARGIN); |
icyzkungz | 0:f73c80b36c20 | 355 | } |
icyzkungz | 0:f73c80b36c20 | 356 | |
icyzkungz | 0:f73c80b36c20 | 357 | else if(option == 22) { //Left Knee Margin |
icyzkungz | 0:f73c80b36c20 | 358 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 359 | pc.printf("Input Margin\n"); |
icyzkungz | 0:f73c80b36c20 | 360 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 361 | |
icyzkungz | 0:f73c80b36c20 | 362 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 363 | pc.printf("\nChange Left Knee Margin to %f\n",temp); |
icyzkungz | 0:f73c80b36c20 | 364 | bcom.setLowMargin(LEFT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 365 | } else bcom.saveDataToEEPROM(LEFT_SIDE,LOW_MARGIN); |
icyzkungz | 0:f73c80b36c20 | 366 | } |
icyzkungz | 0:f73c80b36c20 | 367 | |
icyzkungz | 0:f73c80b36c20 | 368 | else if(option == 23) { //Right Hip Margin |
icyzkungz | 0:f73c80b36c20 | 369 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 370 | pc.printf("Input Margin\n"); |
icyzkungz | 0:f73c80b36c20 | 371 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 372 | |
icyzkungz | 0:f73c80b36c20 | 373 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 374 | pc.printf("\nChange Right Hip Margin to %f\n",temp); |
icyzkungz | 0:f73c80b36c20 | 375 | bcom.setUpMargin(RIGHT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 376 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,UP_MARGIN); |
icyzkungz | 0:f73c80b36c20 | 377 | } |
icyzkungz | 0:f73c80b36c20 | 378 | |
icyzkungz | 0:f73c80b36c20 | 379 | else if(option == 24) { //Right Knee Margin |
icyzkungz | 0:f73c80b36c20 | 380 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 381 | pc.printf("Input Margin\n"); |
icyzkungz | 0:f73c80b36c20 | 382 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 383 | |
icyzkungz | 0:f73c80b36c20 | 384 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 385 | pc.printf("\nChange Right Knee Margin to %f\n",temp); |
icyzkungz | 0:f73c80b36c20 | 386 | bcom.setLowMargin(RIGHT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 387 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,LOW_MARGIN); |
icyzkungz | 0:f73c80b36c20 | 388 | } |
icyzkungz | 0:f73c80b36c20 | 389 | |
icyzkungz | 1:183e6088a1fa | 390 | else if(option == 25) { //Offset |
icyzkungz | 0:f73c80b36c20 | 391 | if(a == true && b == true && c == true && d == true) { |
icyzkungz | 0:f73c80b36c20 | 392 | //float HipAngle[2],KneeAngle[2]; |
icyzkungz | 0:f73c80b36c20 | 393 | float LHipAngle,LKneeAngle; |
icyzkungz | 0:f73c80b36c20 | 394 | float RHipAngle,RKneeAngle; |
icyzkungz | 0:f73c80b36c20 | 395 | bcom.getMotorPos(LEFT_SIDE,&LHipAngle,&LKneeAngle); |
icyzkungz | 0:f73c80b36c20 | 396 | bcom.getMotorPos(RIGHT_SIDE,&RHipAngle,&RKneeAngle); |
icyzkungz | 0:f73c80b36c20 | 397 | |
icyzkungz | 0:f73c80b36c20 | 398 | Kinematic L( 'Z', LLink[0], LLink[1], LHipAngle, LKneeAngle); |
icyzkungz | 0:f73c80b36c20 | 399 | Kinematic R( 'Z', RLink[0], RLink[1], RHipAngle, RKneeAngle); |
icyzkungz | 0:f73c80b36c20 | 400 | |
icyzkungz | 0:f73c80b36c20 | 401 | L.ForwardKinematicCalculation(); |
icyzkungz | 0:f73c80b36c20 | 402 | R.ForwardKinematicCalculation(); |
icyzkungz | 0:f73c80b36c20 | 403 | |
icyzkungz | 0:f73c80b36c20 | 404 | float offset_Y,offset_Z; |
icyzkungz | 0:f73c80b36c20 | 405 | offset_Y = L.get_Position_Y()-R.get_Position_Y(); |
icyzkungz | 0:f73c80b36c20 | 406 | offset_Z = L.get_Position_Z()-R.get_Position_Z(); |
icyzkungz | 0:f73c80b36c20 | 407 | |
icyzkungz | 0:f73c80b36c20 | 408 | bcom.setOffset(LEFT_SIDE,offset_Y,offset_Z); |
icyzkungz | 0:f73c80b36c20 | 409 | bcom.saveDataToEEPROM(LEFT_SIDE,OFFSET); |
icyzkungz | 0:f73c80b36c20 | 410 | |
icyzkungz | 0:f73c80b36c20 | 411 | } else pc.printf("\nYou have to do choice 25-28 first\n\n"); |
icyzkungz | 0:f73c80b36c20 | 412 | } |
icyzkungz | 0:f73c80b36c20 | 413 | |
icyzkungz | 1:183e6088a1fa | 414 | else if(option == 26) { //Body Lenght of Left Side |
icyzkungz | 0:f73c80b36c20 | 415 | do { |
icyzkungz | 0:f73c80b36c20 | 416 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 417 | pc.printf("Input Body Lenght of Left Side\n"); |
icyzkungz | 0:f73c80b36c20 | 418 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 419 | |
icyzkungz | 0:f73c80b36c20 | 420 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 421 | pc.printf("\nBody Lenght = %f\n",temp); |
icyzkungz | 0:f73c80b36c20 | 422 | bcom.setBodyLength(LEFT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 423 | } else bcom.saveDataToEEPROM(LEFT_SIDE,BODY_LENGTH); |
icyzkungz | 0:f73c80b36c20 | 424 | |
icyzkungz | 0:f73c80b36c20 | 425 | } while(temp!=9999); |
icyzkungz | 0:f73c80b36c20 | 426 | } |
icyzkungz | 0:f73c80b36c20 | 427 | |
icyzkungz | 1:183e6088a1fa | 428 | else if(option == 27) { //Body Lenght of Right Side |
icyzkungz | 0:f73c80b36c20 | 429 | do { |
icyzkungz | 0:f73c80b36c20 | 430 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 431 | pc.printf("Input Body Lenght of Right Side\n"); |
icyzkungz | 0:f73c80b36c20 | 432 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 433 | |
icyzkungz | 0:f73c80b36c20 | 434 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 435 | pc.printf("\nBody Lenght = %f\n",temp); |
icyzkungz | 0:f73c80b36c20 | 436 | bcom.setBodyLength(RIGHT_SIDE,temp); |
icyzkungz | 0:f73c80b36c20 | 437 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,BODY_LENGTH); |
icyzkungz | 0:f73c80b36c20 | 438 | |
icyzkungz | 0:f73c80b36c20 | 439 | } while(temp!=9999); |
icyzkungz | 0:f73c80b36c20 | 440 | } |
icyzkungz | 0:f73c80b36c20 | 441 | |
icyzkungz | 1:183e6088a1fa | 442 | else if(option == 28) { //Set Maximum Hip Angle Range |
icyzkungz | 0:f73c80b36c20 | 443 | do { |
icyzkungz | 0:f73c80b36c20 | 444 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 445 | pc.printf("1) Left Side\n"); |
icyzkungz | 0:f73c80b36c20 | 446 | pc.printf("2) Right Side\n"); |
icyzkungz | 0:f73c80b36c20 | 447 | pc.scanf("%f\n",&temp); |
icyzkungz | 0:f73c80b36c20 | 448 | |
icyzkungz | 0:f73c80b36c20 | 449 | if(temp==1) { //Left |
icyzkungz | 0:f73c80b36c20 | 450 | pc.printf("Input Maximum Hip Angle Range of Left Side\n"); |
icyzkungz | 0:f73c80b36c20 | 451 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 452 | |
icyzkungz | 0:f73c80b36c20 | 453 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 454 | pc.printf("\nMaximum Hip Angle Range of Left Side = %f\n",temp); |
icyzkungz | 0:f73c80b36c20 | 455 | bcom.setUpAngleRange(LEFT_SIDE,temp,Lmin.Hip); |
icyzkungz | 0:f73c80b36c20 | 456 | Lmax.Hip = temp; |
icyzkungz | 0:f73c80b36c20 | 457 | } else bcom.saveDataToEEPROM(LEFT_SIDE,ANGLE_RANGE_UP); |
icyzkungz | 0:f73c80b36c20 | 458 | |
icyzkungz | 0:f73c80b36c20 | 459 | } else if(temp==2) { //Right |
icyzkungz | 0:f73c80b36c20 | 460 | pc.printf("Input Maximum Hip Angle Range of Right Side\n"); |
icyzkungz | 0:f73c80b36c20 | 461 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 462 | |
icyzkungz | 0:f73c80b36c20 | 463 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 464 | pc.printf("\nMaximum Hip Angle Range of Right Side = %f\n",temp); |
icyzkungz | 0:f73c80b36c20 | 465 | bcom.setUpAngleRange(RIGHT_SIDE,temp,Rmin.Hip); |
icyzkungz | 0:f73c80b36c20 | 466 | Rmax.Hip = temp; |
icyzkungz | 0:f73c80b36c20 | 467 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,ANGLE_RANGE_UP); |
icyzkungz | 0:f73c80b36c20 | 468 | } |
icyzkungz | 0:f73c80b36c20 | 469 | } while(temp!=9999); |
icyzkungz | 0:f73c80b36c20 | 470 | } |
icyzkungz | 0:f73c80b36c20 | 471 | |
icyzkungz | 1:183e6088a1fa | 472 | else if(option == 29) { //Set Minumum Hip Angle Range |
icyzkungz | 0:f73c80b36c20 | 473 | do { |
icyzkungz | 0:f73c80b36c20 | 474 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 475 | pc.printf("1) Left Side\n"); |
icyzkungz | 0:f73c80b36c20 | 476 | pc.printf("2) Right Side\n"); |
icyzkungz | 0:f73c80b36c20 | 477 | pc.scanf("%f\n",&temp); |
icyzkungz | 0:f73c80b36c20 | 478 | |
icyzkungz | 0:f73c80b36c20 | 479 | if(temp==1) { //Left |
icyzkungz | 0:f73c80b36c20 | 480 | pc.printf("Input Minumum Hip Angle Range of Left Side\n"); |
icyzkungz | 0:f73c80b36c20 | 481 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 482 | |
icyzkungz | 0:f73c80b36c20 | 483 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 484 | pc.printf("\nMinumum Hip Angle Range of Left Side = %f\n",temp); |
icyzkungz | 0:f73c80b36c20 | 485 | bcom.setLowAngleRange(LEFT_SIDE,Lmax.Hip,temp); |
icyzkungz | 0:f73c80b36c20 | 486 | Lmin.Hip = temp; |
icyzkungz | 0:f73c80b36c20 | 487 | } else bcom.saveDataToEEPROM(LEFT_SIDE,ANGLE_RANGE_UP); |
icyzkungz | 0:f73c80b36c20 | 488 | |
icyzkungz | 0:f73c80b36c20 | 489 | } else if(temp==2) { //Right |
icyzkungz | 0:f73c80b36c20 | 490 | pc.printf("Input Minumum Hip Angle Range of Right Side\n"); |
icyzkungz | 0:f73c80b36c20 | 491 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 492 | |
icyzkungz | 0:f73c80b36c20 | 493 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 494 | pc.printf("\nMinumum Hip Angle Range of Right Side = %f\n",temp); |
icyzkungz | 0:f73c80b36c20 | 495 | bcom.setLowAngleRange(RIGHT_SIDE,Rmax.Hip,temp); |
icyzkungz | 0:f73c80b36c20 | 496 | Rmin.Hip = temp; |
icyzkungz | 0:f73c80b36c20 | 497 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,ANGLE_RANGE_UP); |
icyzkungz | 0:f73c80b36c20 | 498 | } |
icyzkungz | 0:f73c80b36c20 | 499 | } while(temp!=9999); |
icyzkungz | 0:f73c80b36c20 | 500 | } |
icyzkungz | 0:f73c80b36c20 | 501 | |
icyzkungz | 0:f73c80b36c20 | 502 | |
icyzkungz | 1:183e6088a1fa | 503 | else if(option == 30) { //Set Maximum Knee Angle Range |
icyzkungz | 0:f73c80b36c20 | 504 | do { |
icyzkungz | 0:f73c80b36c20 | 505 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 506 | pc.printf("1) Left Side\n"); |
icyzkungz | 0:f73c80b36c20 | 507 | pc.printf("2) Right Side\n"); |
icyzkungz | 0:f73c80b36c20 | 508 | pc.scanf("%f\n",&temp); |
icyzkungz | 0:f73c80b36c20 | 509 | |
icyzkungz | 0:f73c80b36c20 | 510 | if(temp==1) { //Left |
icyzkungz | 0:f73c80b36c20 | 511 | pc.printf("Input Maximum Knee Angle Range of Left Side\n"); |
icyzkungz | 0:f73c80b36c20 | 512 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 513 | |
icyzkungz | 0:f73c80b36c20 | 514 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 515 | pc.printf("\nMaximum Knee Angle Range of Left Side = %f\n",temp); |
icyzkungz | 0:f73c80b36c20 | 516 | bcom.setLowAngleRange(LEFT_SIDE,temp,Lmin.Knee); |
icyzkungz | 0:f73c80b36c20 | 517 | Lmax.Knee = temp; |
icyzkungz | 0:f73c80b36c20 | 518 | } else bcom.saveDataToEEPROM(LEFT_SIDE,ANGLE_RANGE_LOW); |
icyzkungz | 0:f73c80b36c20 | 519 | |
icyzkungz | 0:f73c80b36c20 | 520 | } else if(temp==2) { //Right |
icyzkungz | 0:f73c80b36c20 | 521 | pc.printf("Input Maximum Knee Angle Range of Right Side\n"); |
icyzkungz | 0:f73c80b36c20 | 522 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 523 | |
icyzkungz | 0:f73c80b36c20 | 524 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 525 | pc.printf("\nMaximum Knee Angle Range of Right Side = %f\n",temp); |
icyzkungz | 0:f73c80b36c20 | 526 | bcom.setLowAngleRange(RIGHT_SIDE,temp,Rmin.Knee); |
icyzkungz | 0:f73c80b36c20 | 527 | Rmax.Knee = temp; |
icyzkungz | 0:f73c80b36c20 | 528 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,ANGLE_RANGE_LOW); |
icyzkungz | 0:f73c80b36c20 | 529 | } |
icyzkungz | 0:f73c80b36c20 | 530 | } while(temp!=9999); |
icyzkungz | 0:f73c80b36c20 | 531 | } |
icyzkungz | 0:f73c80b36c20 | 532 | |
icyzkungz | 1:183e6088a1fa | 533 | else if(option == 28) { //Set Minumum Knee Angle Range |
icyzkungz | 0:f73c80b36c20 | 534 | do { |
icyzkungz | 0:f73c80b36c20 | 535 | pc.printf("\nType 9999 to Exit to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 536 | pc.printf("1) Left Side\n"); |
icyzkungz | 0:f73c80b36c20 | 537 | pc.printf("2) Right Side\n"); |
icyzkungz | 0:f73c80b36c20 | 538 | pc.scanf("%f\n",&temp); |
icyzkungz | 0:f73c80b36c20 | 539 | |
icyzkungz | 0:f73c80b36c20 | 540 | if(temp==1) { //Left |
icyzkungz | 0:f73c80b36c20 | 541 | pc.printf("Input Minumum Knee Angle Range of Left Side\n"); |
icyzkungz | 0:f73c80b36c20 | 542 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 543 | |
icyzkungz | 0:f73c80b36c20 | 544 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 545 | pc.printf("\nMinumum Knee Angle Range of Left Side = %f\n",temp); |
icyzkungz | 0:f73c80b36c20 | 546 | bcom.setLowAngleRange(LEFT_SIDE,Lmax.Knee,temp); |
icyzkungz | 0:f73c80b36c20 | 547 | Lmin.Knee = temp; |
icyzkungz | 0:f73c80b36c20 | 548 | } else bcom.saveDataToEEPROM(LEFT_SIDE,ANGLE_RANGE_LOW); |
icyzkungz | 0:f73c80b36c20 | 549 | |
icyzkungz | 0:f73c80b36c20 | 550 | } else if(temp==2) { //Right |
icyzkungz | 0:f73c80b36c20 | 551 | pc.printf("Input Minumum Knee Angle Range of Right Side\n"); |
icyzkungz | 0:f73c80b36c20 | 552 | pc.scanf("%f",&temp); |
icyzkungz | 0:f73c80b36c20 | 553 | |
icyzkungz | 0:f73c80b36c20 | 554 | if(temp != 9999) { |
icyzkungz | 0:f73c80b36c20 | 555 | pc.printf("\nMinumum Knee Angle Range of Right Side = %f\n",temp); |
icyzkungz | 0:f73c80b36c20 | 556 | bcom.setLowAngleRange(RIGHT_SIDE,Rmax.Knee,temp); |
icyzkungz | 0:f73c80b36c20 | 557 | Rmin.Knee = temp; |
icyzkungz | 0:f73c80b36c20 | 558 | } else bcom.saveDataToEEPROM(RIGHT_SIDE,ANGLE_RANGE_LOW); |
icyzkungz | 0:f73c80b36c20 | 559 | } |
icyzkungz | 0:f73c80b36c20 | 560 | } while(temp!=9999); |
icyzkungz | 0:f73c80b36c20 | 561 | } |
icyzkungz | 0:f73c80b36c20 | 562 | |
icyzkungz | 0:f73c80b36c20 | 563 | |
icyzkungz | 0:f73c80b36c20 | 564 | |
icyzkungz | 0:f73c80b36c20 | 565 | |
icyzkungz | 0:f73c80b36c20 | 566 | |
icyzkungz | 0:f73c80b36c20 | 567 | |
icyzkungz | 1:183e6088a1fa | 568 | else if(option == 40) { |
icyzkungz | 0:f73c80b36c20 | 569 | pc.printf("Are You Sure ?\n"); |
icyzkungz | 0:f73c80b36c20 | 570 | pc.printf("\n1) Yes\n"); |
icyzkungz | 0:f73c80b36c20 | 571 | pc.printf("2) No\n"); |
icyzkungz | 0:f73c80b36c20 | 572 | |
icyzkungz | 0:f73c80b36c20 | 573 | pc.scanf("%d",&option); |
icyzkungz | 0:f73c80b36c20 | 574 | if(option==1) { |
icyzkungz | 1:183e6088a1fa | 575 | option = 40; |
icyzkungz | 0:f73c80b36c20 | 576 | pc.printf("Please Push Button Restart\n"); |
icyzkungz | 0:f73c80b36c20 | 577 | } else pc.printf("Return to Main Menu\n"); |
icyzkungz | 0:f73c80b36c20 | 578 | |
icyzkungz | 0:f73c80b36c20 | 579 | } |
icyzkungz | 0:f73c80b36c20 | 580 | |
icyzkungz | 0:f73c80b36c20 | 581 | |
icyzkungz | 0:f73c80b36c20 | 582 | else { // if user has entered invalid choice (other than 1,2,3 or 4) |
icyzkungz | 0:f73c80b36c20 | 583 | // Displaying error message |
icyzkungz | 1:183e6088a1fa | 584 | pc.printf("\nInvalid Option entered\n"); |
icyzkungz | 0:f73c80b36c20 | 585 | } |
icyzkungz | 0:f73c80b36c20 | 586 | } while(option != 40); // condition of do-while loop |
icyzkungz | 0:f73c80b36c20 | 587 | |
icyzkungz | 0:f73c80b36c20 | 588 | } |
icyzkungz | 0:f73c80b36c20 | 589 | |
icyzkungz | 0:f73c80b36c20 | 590 | int main() |
icyzkungz | 0:f73c80b36c20 | 591 | { |
icyzkungz | 0:f73c80b36c20 | 592 | pc.baud(115200); |
icyzkungz | 1:183e6088a1fa | 593 | pc.printf("Start\n"); |
icyzkungz | 0:f73c80b36c20 | 594 | |
icyzkungz | 1:183e6088a1fa | 595 | if(!button) { |
icyzkungz | 1:183e6088a1fa | 596 | while(!button); |
icyzkungz | 0:f73c80b36c20 | 597 | SwMode(); |
icyzkungz | 1:183e6088a1fa | 598 | } |
icyzkungz | 1:183e6088a1fa | 599 | |
icyzkungz | 0:f73c80b36c20 | 600 | } |
icyzkungz | 0:f73c80b36c20 | 601 | |
icyzkungz | 0:f73c80b36c20 | 602 | /*int main() |
icyzkungz | 0:f73c80b36c20 | 603 | { |
icyzkungz | 0:f73c80b36c20 | 604 | pc.baud(115200); |
icyzkungz | 0:f73c80b36c20 | 605 | int num; |
icyzkungz | 0:f73c80b36c20 | 606 | do { |
icyzkungz | 0:f73c80b36c20 | 607 | //float num; |
icyzkungz | 0:f73c80b36c20 | 608 | //Float number --> Working |
icyzkungz | 0:f73c80b36c20 | 609 | pc.printf("Start\n"); |
icyzkungz | 0:f73c80b36c20 | 610 | pc.scanf("%d",&num); |
icyzkungz | 0:f73c80b36c20 | 611 | pc.printf("temp : %d\n",num); |
icyzkungz | 0:f73c80b36c20 | 612 | if( num == 15 ) |
icyzkungz | 0:f73c80b36c20 | 613 | pc.printf("Yes\n"); |
icyzkungz | 0:f73c80b36c20 | 614 | pc.printf("End\n"); |
icyzkungz | 0:f73c80b36c20 | 615 | } while(num!=20); |
icyzkungz | 0:f73c80b36c20 | 616 | }*/ |