58 lines
1007 B
C
58 lines
1007 B
C
//
|
|
// Created by nano on 5/14/25.
|
|
//
|
|
|
|
#include <ctype.h>
|
|
#include <stdio.h>
|
|
|
|
#include "robot.h"
|
|
#include "../communication/communication.h"
|
|
#include "../communication/utils.h"
|
|
#include "../leelib/leelib.h"
|
|
|
|
void simple_control() {
|
|
robot r;
|
|
printf("Where are we starting? ");
|
|
readStation(&r.pos.x,&r.pos.y);
|
|
r.dir=getStartDirection(r.pos);
|
|
|
|
comm_init_communication();
|
|
char in;
|
|
int run = 1;
|
|
while (run) {
|
|
printf("Move? ");
|
|
scanf("%c", &in);
|
|
switch (tolower(in)) {
|
|
case 'f':
|
|
printf("going forward\n");
|
|
forward(&r);
|
|
break;
|
|
case 'b':
|
|
printf("going backward\n");
|
|
backward(&r);
|
|
break;
|
|
case 'l':
|
|
printf("going left\n");
|
|
turnLeft(&r);
|
|
break;
|
|
case 'r':
|
|
printf("turning right\n");
|
|
turnRight(&r);
|
|
break;
|
|
case 'a':
|
|
printf("turning around\n");
|
|
turnAround(&r);
|
|
break;
|
|
case 'e':
|
|
printf("exiting\n");
|
|
run = 0;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
//byte b;
|
|
//comm_await_crossing(&b,50);
|
|
}
|
|
comm_end_communication();
|
|
}
|