SwitchMode

Dependencies:   BEAR_Protocol InverseLeg iSerial mbed

Fork of SwitchMode by Arsapol Manamunchaiyaporn

Committer:
icyzkungz
Date:
Fri Jan 22 08:04:41 2016 +0000
Revision:
2:d6be1c49d9d5
Parent:
1:183e6088a1fa
Child:
3:b7a8a60085c1
delete comment

Who changed what in which revision?

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