Final Project files for mBed development.

Dependencies:   m3pi mbed

Committer:
alecguertin
Date:
Mon Dec 08 05:00:23 2014 +0000
Revision:
27:44a4a0abc8ee
Parent:
26:a74edc4c6acb
Child:
28:9976a94efa83
changed ending

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lsaristo 1:7e0243c27ecb 1 /**
lsaristo 1:7e0243c27ecb 2 * @file driver.c
lsaristo 1:7e0243c27ecb 3 * @brief Basic driver program for our robot's controller logic.
lsaristo 1:7e0243c27ecb 4 *
lsaristo 1:7e0243c27ecb 5 * Maybe add lots of stuff here or maybe split it off into
lsaristo 1:7e0243c27ecb 6 * multiple subfiles?
lsaristo 1:7e0243c27ecb 7 *
alecguertin 19:47759cf4f9b9 8 * @author John Wilkey - aw hells no! you ain't takin' credit for all this!
lsaristo 1:7e0243c27ecb 9 */
lsaristo 9:3a0433c391cb 10 #include "main.h"
lsaristo 10:94b068b2ce1d 11 #include "control.h"
John Wilkey 5:01882c3de2dc 12
alecguertin 26:a74edc4c6acb 13 /* These are global data Used externally in all other files */
lsaristo 7:6e5cc24e1ce7 14 m3pi pi;
lsaristo 12:1aa6b8a74136 15 Timer timer;
lsaristo 9:3a0433c391cb 16
alecguertin 26:a74edc4c6acb 17 /* Digital inputs to the mBed */
lsaristo 10:94b068b2ce1d 18 DigitalIn start_button(p21);
lsaristo 9:3a0433c391cb 19
alecguertin 26:a74edc4c6acb 20 /*
alecguertin 26:a74edc4c6acb 21 * Digital outputs from the mBed. Note that by default these are
alecguertin 26:a74edc4c6acb 22 * used to drive the 8 LED's on the top board.
alecguertin 26:a74edc4c6acb 23 */
alecguertin 25:2c7717684d09 24 DigitalOut pin13(p13);
alecguertin 25:2c7717684d09 25 DigitalOut pin14(p14);
lsaristo 7:6e5cc24e1ce7 26 DigitalOut pin15(p15);
lsaristo 7:6e5cc24e1ce7 27 DigitalOut pin16(p16);
lsaristo 7:6e5cc24e1ce7 28 DigitalOut pin17(p17);
lsaristo 7:6e5cc24e1ce7 29 DigitalOut pin18(p18);
lsaristo 7:6e5cc24e1ce7 30 DigitalOut pin19(p19);
lsaristo 7:6e5cc24e1ce7 31 DigitalOut pin20(p20);
lsaristo 7:6e5cc24e1ce7 32
alecguertin 26:a74edc4c6acb 33 /* mBed onboard LEDs */
lsaristo 9:3a0433c391cb 34 DigitalOut oled_1(LED1);
lsaristo 9:3a0433c391cb 35 DigitalOut oled_2(LED2);
lsaristo 9:3a0433c391cb 36 DigitalOut oled_3(LED3);
lsaristo 9:3a0433c391cb 37 DigitalOut oled_4(LED4);
lsaristo 9:3a0433c391cb 38
alecguertin 15:14d4e7021125 39 /* Local File System */
alecguertin 15:14d4e7021125 40 LocalFileSystem local("local");
lsaristo 9:3a0433c391cb 41
alecguertin 17:c72c092fcdf7 42 /* Boolean for drawing/moving. */
alecguertin 17:c72c092fcdf7 43 int draw;
alecguertin 17:c72c092fcdf7 44
John Wilkey 5:01882c3de2dc 45 /**
John Wilkey 5:01882c3de2dc 46 * @brief Entry point. Main loop.
John Wilkey 5:01882c3de2dc 47 */
John Wilkey 5:01882c3de2dc 48 int main()
John Wilkey 5:01882c3de2dc 49 {
alecguertin 17:c72c092fcdf7 50 FILE *ps_file;
alecguertin 17:c72c092fcdf7 51 int instbuflen = 250;
alecguertin 17:c72c092fcdf7 52 char instbuf[instbuflen];
alecguertin 17:c72c092fcdf7 53
lsaristo 9:3a0433c391cb 54 // Basic setup information
lsaristo 10:94b068b2ce1d 55 start_button.mode(PullUp);
lsaristo 12:1aa6b8a74136 56
lsaristo 21:0c80a5d89ea3 57 pi.cls();
lsaristo 21:0c80a5d89ea3 58 pi.locate(0,0);
lsaristo 21:0c80a5d89ea3 59 pi.printf("PiCO");
lsaristo 21:0c80a5d89ea3 60 pi.locate(0,1);
lsaristo 21:0c80a5d89ea3 61 pi.printf("%f mV", pi.battery());
lsaristo 21:0c80a5d89ea3 62 wait(.5);
lsaristo 21:0c80a5d89ea3 63
lsaristo 13:070846d87d4a 64 // Drawing environment calibration.
lsaristo 12:1aa6b8a74136 65 pi.sensor_auto_calibrate();
alecguertin 15:14d4e7021125 66 float pos = 0;
alecguertin 15:14d4e7021125 67 float over_thresh = 0.05;
alecguertin 15:14d4e7021125 68 float correction = 0.2*DRIVE_SPEED;
alecguertin 19:47759cf4f9b9 69 float cal_time;
alecguertin 15:14d4e7021125 70 wait(1);
alecguertin 26:a74edc4c6acb 71
lsaristo 21:0c80a5d89ea3 72 do {
lsaristo 21:0c80a5d89ea3 73 pos = pi.line_position();
lsaristo 21:0c80a5d89ea3 74 if(pos > over_thresh) {
lsaristo 21:0c80a5d89ea3 75 pi.right_motor(CAL_SPEED);
lsaristo 21:0c80a5d89ea3 76 pi.left_motor(CAL_SPEED-correction);
lsaristo 21:0c80a5d89ea3 77 } else if(pos < -over_thresh) {
lsaristo 21:0c80a5d89ea3 78 pi.left_motor(CAL_SPEED);
lsaristo 21:0c80a5d89ea3 79 pi.right_motor(CAL_SPEED-correction);
lsaristo 21:0c80a5d89ea3 80 } else {
lsaristo 21:0c80a5d89ea3 81 pi.right_motor(CAL_SPEED);
lsaristo 21:0c80a5d89ea3 82 pi.left_motor(CAL_SPEED);
lsaristo 21:0c80a5d89ea3 83 }
lsaristo 21:0c80a5d89ea3 84 pi.cls();
lsaristo 21:0c80a5d89ea3 85 pi.locate(0,0);
lsaristo 21:0c80a5d89ea3 86 pi.printf("Pos: %f", pos);
lsaristo 21:0c80a5d89ea3 87 } while(pos != -1 && pos > -0.3);
lsaristo 21:0c80a5d89ea3 88 pi.stop();
lsaristo 21:0c80a5d89ea3 89 if(pos != -1) {
lsaristo 21:0c80a5d89ea3 90 timer.stop();
lsaristo 21:0c80a5d89ea3 91 } else {
lsaristo 21:0c80a5d89ea3 92 return 1;
lsaristo 21:0c80a5d89ea3 93 }
lsaristo 21:0c80a5d89ea3 94 right(180);
alecguertin 22:46b9d9b2e35c 95 Timer caltimer;
alecguertin 22:46b9d9b2e35c 96 caltimer.start();
lsaristo 12:1aa6b8a74136 97 do {
lsaristo 12:1aa6b8a74136 98 pos = pi.line_position();
lsaristo 13:070846d87d4a 99 if(pos > over_thresh) {
lsaristo 21:0c80a5d89ea3 100 pi.right_motor(CAL_SPEED);
lsaristo 21:0c80a5d89ea3 101 pi.left_motor(CAL_SPEED-correction);
lsaristo 13:070846d87d4a 102 } else if(pos < -over_thresh) {
lsaristo 21:0c80a5d89ea3 103 pi.left_motor(CAL_SPEED);
lsaristo 21:0c80a5d89ea3 104 pi.right_motor(CAL_SPEED-correction);
lsaristo 13:070846d87d4a 105 } else {
lsaristo 21:0c80a5d89ea3 106 pi.right_motor(CAL_SPEED);
lsaristo 21:0c80a5d89ea3 107 pi.left_motor(CAL_SPEED);
alecguertin 15:14d4e7021125 108 }
alecguertin 15:14d4e7021125 109 pi.cls();
alecguertin 15:14d4e7021125 110 pi.locate(0,0);
alecguertin 15:14d4e7021125 111 pi.printf("Pos: %f", pos);
alecguertin 15:14d4e7021125 112 } while(pos != -1 && pos <= 0.3);
alecguertin 22:46b9d9b2e35c 113 caltimer.stop();
alecguertin 22:46b9d9b2e35c 114 cal_time = caltimer.read_ms();
alecguertin 15:14d4e7021125 115 pi.stop();
alecguertin 15:14d4e7021125 116 if(pos != -1) {
alecguertin 15:14d4e7021125 117 timer.stop();
alecguertin 15:14d4e7021125 118 } else {
alecguertin 15:14d4e7021125 119 return 1;
alecguertin 15:14d4e7021125 120 }
lsaristo 21:0c80a5d89ea3 121 right(180);
alecguertin 22:46b9d9b2e35c 122 timerWait(.5);
alecguertin 22:46b9d9b2e35c 123 while(fabs(pos = pi.line_position()) > CLOSE_ENOUGH) {
alecguertin 22:46b9d9b2e35c 124 pi.right((pos < 0 ? -.6*CAL_SPEED : .6*CAL_SPEED));
alecguertin 22:46b9d9b2e35c 125 pi.cls();
alecguertin 22:46b9d9b2e35c 126 pi.locate(0,0);
alecguertin 22:46b9d9b2e35c 127 pi.printf("O: %f", pos);
alecguertin 22:46b9d9b2e35c 128 }
alecguertin 22:46b9d9b2e35c 129 pi.stop();
alecguertin 22:46b9d9b2e35c 130 timerWait(2);
alecguertin 26:a74edc4c6acb 131
alecguertin 22:46b9d9b2e35c 132 backward(500);
alecguertin 22:46b9d9b2e35c 133 timerWait(.5);
alecguertin 22:46b9d9b2e35c 134 while(fabs(pos = pi.line_position()) > CLOSE_ENOUGH) {
alecguertin 22:46b9d9b2e35c 135 pi.right((pos < 0 ? -.6*CAL_SPEED : .6*CAL_SPEED));
alecguertin 22:46b9d9b2e35c 136 pi.cls();
alecguertin 22:46b9d9b2e35c 137 pi.locate(0,0);
alecguertin 22:46b9d9b2e35c 138 pi.printf("O: %f", pos);
alecguertin 22:46b9d9b2e35c 139 }
alecguertin 22:46b9d9b2e35c 140 pi.stop();
alecguertin 22:46b9d9b2e35c 141 timerWait(2);
alecguertin 26:a74edc4c6acb 142
alecguertin 22:46b9d9b2e35c 143 timerWait(1);
lsaristo 12:1aa6b8a74136 144
lsaristo 9:3a0433c391cb 145 // Main program loop.
alecguertin 17:c72c092fcdf7 146 size_t bytes_read = 0;
alecguertin 22:46b9d9b2e35c 147 int err, x, y, last_x, last_y, delta_x, delta_y;
alecguertin 22:46b9d9b2e35c 148 float delta_a;
alecguertin 19:47759cf4f9b9 149 int dim_x, dim_y;
alecguertin 17:c72c092fcdf7 150 int offset = 0;
alecguertin 17:c72c092fcdf7 151 char *cur, *next;
alecguertin 19:47759cf4f9b9 152 float angle;
alecguertin 19:47759cf4f9b9 153 double dist, theta;
alecguertin 18:eab7b0e89398 154 angle = 0;
alecguertin 18:eab7b0e89398 155 theta = 0;
alecguertin 19:47759cf4f9b9 156 last_x = 0;
alecguertin 19:47759cf4f9b9 157 last_y = 0;
alecguertin 15:14d4e7021125 158 ps_file = fopen("/local/test.ps", "r");
chstrchu 20:76718145b403 159 if (ps_file == NULL) {
chstrchu 20:76718145b403 160 return 1;
chstrchu 20:76718145b403 161 }
alecguertin 25:2c7717684d09 162
alecguertin 17:c72c092fcdf7 163 /* PS parsing loop. */
alecguertin 19:47759cf4f9b9 164 memset(instbuf, 0, instbuflen);
chstrchu 20:76718145b403 165 bytes_read = fread(instbuf, sizeof(char), instbuflen-1, ps_file);
alecguertin 22:46b9d9b2e35c 166 if (bytes_read == 0) {
alecguertin 22:46b9d9b2e35c 167 return 1;
alecguertin 22:46b9d9b2e35c 168 }
alecguertin 19:47759cf4f9b9 169 err = sscanf(instbuf, "%d/%d", &dim_x, &dim_y);
alecguertin 19:47759cf4f9b9 170 if (err != 2) {
chstrchu 20:76718145b403 171 pi.cls();
chstrchu 20:76718145b403 172 pi.locate(0,0);
chstrchu 20:76718145b403 173 pi.printf("sscanf1");
alecguertin 19:47759cf4f9b9 174 return 1;
alecguertin 19:47759cf4f9b9 175 }
alecguertin 19:47759cf4f9b9 176 cur = strchr(instbuf, '\n');
chstrchu 20:76718145b403 177 cur++;
alecguertin 22:46b9d9b2e35c 178 offset = instbuf+instbuflen-cur-1;
chstrchu 20:76718145b403 179 memcpy(instbuf, cur, offset);
alecguertin 17:c72c092fcdf7 180 while (1) {
alecguertin 17:c72c092fcdf7 181 memset(instbuf+offset, 0, instbuflen-offset);
alecguertin 17:c72c092fcdf7 182 bytes_read = fread(instbuf+offset, sizeof(char), instbuflen-1-offset, ps_file);
alecguertin 27:44a4a0abc8ee 183 if (instbuf[0] == '\0') {
alecguertin 27:44a4a0abc8ee 184 break;
alecguertin 27:44a4a0abc8ee 185 }
alecguertin 17:c72c092fcdf7 186 cur = instbuf;
alecguertin 22:46b9d9b2e35c 187 err = retrieve_inst(instbuf, &x, &y, &draw);
alecguertin 22:46b9d9b2e35c 188 if (err == 0) {
chstrchu 20:76718145b403 189 pi.cls();
chstrchu 20:76718145b403 190 pi.locate(0,0);
alecguertin 22:46b9d9b2e35c 191 pi.printf("noinst");
alecguertin 22:46b9d9b2e35c 192 return 1;
alecguertin 22:46b9d9b2e35c 193 }
alecguertin 22:46b9d9b2e35c 194 delta_x = x-last_x;
alecguertin 22:46b9d9b2e35c 195 delta_y = y-last_y;
alecguertin 22:46b9d9b2e35c 196
alecguertin 22:46b9d9b2e35c 197 /* Compute turn angle and turn. */
alecguertin 25:2c7717684d09 198 theta = atan(((double) delta_y)/((double) delta_x));
alecguertin 22:46b9d9b2e35c 199 theta *= 57.29;
alecguertin 27:44a4a0abc8ee 200 if (delta_x < 0 && delta_y > 0) {
alecguertin 27:44a4a0abc8ee 201 theta += 180;
alecguertin 27:44a4a0abc8ee 202 }
alecguertin 22:46b9d9b2e35c 203 delta_a = theta-angle;
alecguertin 23:e4616259a7f0 204 if (delta_x < 0 && delta_y < 0) {
alecguertin 23:e4616259a7f0 205 delta_a += 180;
alecguertin 23:e4616259a7f0 206 }
alecguertin 25:2c7717684d09 207 angle += delta_a;
alecguertin 25:2c7717684d09 208 //pi.cls();
alecguertin 25:2c7717684d09 209 //pi.locate(0,0);
alecguertin 25:2c7717684d09 210 //pi.printf("a:%f", delta_a);
alecguertin 25:2c7717684d09 211 //timerWait(1.5);
alecguertin 25:2c7717684d09 212 left(delta_a);
alecguertin 19:47759cf4f9b9 213
alecguertin 22:46b9d9b2e35c 214 /* Put pen into position. */
alecguertin 22:46b9d9b2e35c 215 if (draw) {
alecguertin 22:46b9d9b2e35c 216 oled_1 = 1;
alecguertin 22:46b9d9b2e35c 217 } else {
alecguertin 22:46b9d9b2e35c 218 oled_1 = 0;
alecguertin 22:46b9d9b2e35c 219 }
alecguertin 22:46b9d9b2e35c 220
alecguertin 22:46b9d9b2e35c 221 /* Compute drive time and move forward. */
alecguertin 22:46b9d9b2e35c 222 dist = sqrt(pow((double) (delta_x),2) + pow((double) (delta_y), 2));
alecguertin 22:46b9d9b2e35c 223 if (dist < 0) {
alecguertin 22:46b9d9b2e35c 224 dist *= -1;
alecguertin 22:46b9d9b2e35c 225 }
alecguertin 25:2c7717684d09 226 //pi.cls();
alecguertin 25:2c7717684d09 227 //pi.locate(0,0);
alecguertin 25:2c7717684d09 228 //pi.printf("d:%f", 0.4*cal_time*(dist/(double)dim_x));
alecguertin 25:2c7717684d09 229 //timerWait(1.5);
alecguertin 22:46b9d9b2e35c 230 forward(0.4*cal_time*(dist/(double)dim_x));
alecguertin 22:46b9d9b2e35c 231
alecguertin 22:46b9d9b2e35c 232 last_x = x;
alecguertin 22:46b9d9b2e35c 233 last_y = y;
alecguertin 22:46b9d9b2e35c 234 next = strchr(cur, '\n');
alecguertin 22:46b9d9b2e35c 235 if (next == NULL) {
chstrchu 20:76718145b403 236 pi.cls();
chstrchu 20:76718145b403 237 pi.locate(0,0);
alecguertin 22:46b9d9b2e35c 238 pi.printf("nonext");
alecguertin 22:46b9d9b2e35c 239 break;
alecguertin 17:c72c092fcdf7 240 }
alecguertin 22:46b9d9b2e35c 241 cur = next+1;
alecguertin 22:46b9d9b2e35c 242 offset = instbuf+instbuflen-cur-1;
alecguertin 17:c72c092fcdf7 243 memcpy(instbuf, cur, offset);
alecguertin 15:14d4e7021125 244 }
chstrchu 20:76718145b403 245 pi.cls();
chstrchu 20:76718145b403 246 pi.locate(0,0);
chstrchu 20:76718145b403 247 pi.printf("done");
alecguertin 27:44a4a0abc8ee 248 while (1);
alecguertin 15:14d4e7021125 249 return 0;
John Wilkey 5:01882c3de2dc 250 }
lsaristo 8:12d780f7443e 251
alecguertin 17:c72c092fcdf7 252 int retrieve_inst(char *buf, int *x, int *y, int *draw)
alecguertin 17:c72c092fcdf7 253 {
alecguertin 17:c72c092fcdf7 254 int matches;
alecguertin 17:c72c092fcdf7 255 char *srch;
alecguertin 17:c72c092fcdf7 256 matches = sscanf(buf, "%d %d", x, y);
alecguertin 17:c72c092fcdf7 257 if (matches != 2) {
chstrchu 20:76718145b403 258 pi.cls();
chstrchu 20:76718145b403 259 pi.locate(0,0);
chstrchu 20:76718145b403 260 pi.printf("nomatch");
alecguertin 17:c72c092fcdf7 261 return 0;
alecguertin 17:c72c092fcdf7 262 }
alecguertin 17:c72c092fcdf7 263 srch = strchr(buf, ' ');
alecguertin 17:c72c092fcdf7 264 srch++;
chstrchu 20:76718145b403 265 srch = strchr(srch, ' ');
alecguertin 17:c72c092fcdf7 266 srch++;
alecguertin 17:c72c092fcdf7 267 if (srch[0] == 'm') {
alecguertin 17:c72c092fcdf7 268 *draw = 0;
chstrchu 20:76718145b403 269 } else if (srch[0] == 'l') {
alecguertin 17:c72c092fcdf7 270 *draw = 1;
alecguertin 17:c72c092fcdf7 271 } else {
chstrchu 20:76718145b403 272 pi.cls();
chstrchu 20:76718145b403 273 pi.locate(0,0);
chstrchu 20:76718145b403 274 pi.printf("%.8s", srch);
alecguertin 17:c72c092fcdf7 275 return 0;
alecguertin 17:c72c092fcdf7 276 }
alecguertin 17:c72c092fcdf7 277 return 1;
alecguertin 17:c72c092fcdf7 278 }
alecguertin 17:c72c092fcdf7 279
lsaristo 9:3a0433c391cb 280 int forward(int amt)
lsaristo 8:12d780f7443e 281 {
lsaristo 12:1aa6b8a74136 282 Timer t;
lsaristo 9:3a0433c391cb 283 pi.locate(0,0);
lsaristo 9:3a0433c391cb 284 pi.printf("Fwd %d", amt);
lsaristo 21:0c80a5d89ea3 285 pi.left_motor(DRIVE_SPEED+.0023);
lsaristo 21:0c80a5d89ea3 286 pi.right_motor(DRIVE_SPEED);
alecguertin 25:2c7717684d09 287 t.start();
alecguertin 25:2c7717684d09 288 while(t.read_ms() < amt);
lsaristo 21:0c80a5d89ea3 289 pi.left_motor(.7*DRIVE_SPEED+.0023);
lsaristo 21:0c80a5d89ea3 290 pi.right_motor(.7*DRIVE_SPEED);
lsaristo 12:1aa6b8a74136 291 t.stop();
lsaristo 12:1aa6b8a74136 292 pi.stop();
lsaristo 8:12d780f7443e 293 return EXIT_SUCCESS;
lsaristo 8:12d780f7443e 294 }
lsaristo 8:12d780f7443e 295
lsaristo 9:3a0433c391cb 296 int backward(int amt)
lsaristo 8:12d780f7443e 297 {
lsaristo 12:1aa6b8a74136 298 Timer t;
lsaristo 12:1aa6b8a74136 299 t.start();
alecguertin 22:46b9d9b2e35c 300 pi.backward(.5*DRIVE_SPEED);
alecguertin 22:46b9d9b2e35c 301 while(t.read_ms() < (amt-500));
alecguertin 22:46b9d9b2e35c 302 pi.backward(.5*DRIVE_SPEED);
chstrchu 20:76718145b403 303 while(t.read_ms() < amt);
lsaristo 12:1aa6b8a74136 304 t.stop();
lsaristo 12:1aa6b8a74136 305 pi.stop();
lsaristo 8:12d780f7443e 306 return EXIT_SUCCESS;
lsaristo 8:12d780f7443e 307 }
lsaristo 8:12d780f7443e 308
lsaristo 8:12d780f7443e 309 int right(float deg)
lsaristo 8:12d780f7443e 310 {
lsaristo 24:b797563776fc 311 if(deg < 0) {
lsaristo 24:b797563776fc 312 return left(-1*deg);
lsaristo 24:b797563776fc 313 }
lsaristo 12:1aa6b8a74136 314 Timer t;
lsaristo 8:12d780f7443e 315 pi.right(TURN_SPEED);
lsaristo 12:1aa6b8a74136 316 t.start();
alecguertin 22:46b9d9b2e35c 317 while(t.read_ms() < ((float)(deg/360)*TIME_FACT));
lsaristo 12:1aa6b8a74136 318 t.stop();
lsaristo 12:1aa6b8a74136 319 pi.stop();
lsaristo 8:12d780f7443e 320 return EXIT_SUCCESS;
lsaristo 8:12d780f7443e 321 }
lsaristo 8:12d780f7443e 322
lsaristo 21:0c80a5d89ea3 323 void timerWait(float seconds)
lsaristo 21:0c80a5d89ea3 324 {
lsaristo 21:0c80a5d89ea3 325 Timer t;
lsaristo 21:0c80a5d89ea3 326 t.start();
lsaristo 21:0c80a5d89ea3 327 while(t.read_us() < 1000000*seconds);
lsaristo 21:0c80a5d89ea3 328 t.stop();
lsaristo 21:0c80a5d89ea3 329 }
lsaristo 21:0c80a5d89ea3 330
lsaristo 8:12d780f7443e 331 int left(float deg)
lsaristo 8:12d780f7443e 332 {
lsaristo 24:b797563776fc 333 if(deg < 0) {
lsaristo 24:b797563776fc 334 return right(-1*deg);
lsaristo 24:b797563776fc 335 }
lsaristo 12:1aa6b8a74136 336 Timer t;
lsaristo 8:12d780f7443e 337 pi.left(TURN_SPEED);
lsaristo 12:1aa6b8a74136 338 t.start();
alecguertin 22:46b9d9b2e35c 339 while(t.read_ms() < ((float)(deg/360)*TIME_FACT));
lsaristo 12:1aa6b8a74136 340 t.stop();
lsaristo 12:1aa6b8a74136 341 pi.stop();
lsaristo 8:12d780f7443e 342 return EXIT_SUCCESS;
lsaristo 10:94b068b2ce1d 343 }
lsaristo 10:94b068b2ce1d 344
lsaristo 10:94b068b2ce1d 345 void pen_down()
lsaristo 10:94b068b2ce1d 346 {
lsaristo 10:94b068b2ce1d 347 oled_1 = 1;
lsaristo 10:94b068b2ce1d 348 }
lsaristo 10:94b068b2ce1d 349
lsaristo 10:94b068b2ce1d 350 void pen_up()
lsaristo 10:94b068b2ce1d 351 {
lsaristo 10:94b068b2ce1d 352 oled_1 = 0;
lsaristo 9:3a0433c391cb 353 }