Inclui api en el la src
This commit is contained in:
parent
0e6fa0c037
commit
1501a7c492
115
lib/api/api.cpp
115
lib/api/api.cpp
|
|
@ -1,124 +1,31 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
|
#include "mm.hpp"
|
||||||
|
|
||||||
#include <cstdlib>
|
/* TO DO
|
||||||
#include <iostream>
|
* Terminar las funciones wallfront, wallright, wallleft
|
||||||
|
* Definir los pines usados en mm.hpp
|
||||||
int API::mazeWidth() {
|
*/
|
||||||
std::cout << "mazeWidth" << std::endl;
|
|
||||||
std::string response;
|
|
||||||
std::cin >> response;
|
|
||||||
return atoi(response.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
int API::mazeHeight() {
|
|
||||||
std::cout << "mazeHeight" << std::endl;
|
|
||||||
std::string response;
|
|
||||||
std::cin >> response;
|
|
||||||
return atoi(response.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool API::wallFront() {
|
bool API::wallFront() {
|
||||||
std::cout << "wallFront" << std::endl;
|
bool wallfront;
|
||||||
std::string response;
|
return wallfront;
|
||||||
std::cin >> response;
|
|
||||||
return response == "true";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool API::wallRight() {
|
bool API::wallRight() {
|
||||||
std::cout << "wallRight" << std::endl;
|
bool wallright;
|
||||||
std::string response;
|
return wallright;
|
||||||
std::cin >> response;
|
|
||||||
return response == "true";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool API::wallLeft() {
|
bool API::wallLeft() {
|
||||||
std::cout << "wallLeft" << std::endl;
|
bool wallleft;
|
||||||
std::string response;
|
return wallleft;
|
||||||
std::cin >> response;
|
|
||||||
return response == "true";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void API::moveForward(int distance) {
|
void API::moveForward(int distance) {
|
||||||
std::cout << "moveForward ";
|
|
||||||
// Don't print distance argument unless explicitly specified, for
|
|
||||||
// backwards compatibility with older versions of the simulator
|
|
||||||
if (distance != 1) {
|
|
||||||
std::cout << distance;
|
|
||||||
}
|
|
||||||
std::cout << std::endl;
|
|
||||||
std::string response;
|
|
||||||
std::cin >> response;
|
|
||||||
if (response != "ack") {
|
|
||||||
std::cerr << response << std::endl;
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void API::turnRight() {
|
void API::turnRight() {
|
||||||
std::cout << "turnRight" << std::endl;
|
|
||||||
std::string ack;
|
|
||||||
std::cin >> ack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void API::turnLeft() {
|
void API::turnLeft() {
|
||||||
std::cout << "turnLeft" << std::endl;
|
|
||||||
std::string ack;
|
|
||||||
std::cin >> ack;
|
|
||||||
}
|
|
||||||
|
|
||||||
void API::setWall(int x, int y, char direction) {
|
|
||||||
std::cout << "setWall " << x << " " << y << " " << direction << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void API::clearWall(int x, int y, char direction) {
|
|
||||||
std::cout << "clearWall " << x << " " << y << " " << direction << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void API::setColor(int x, int y, char color) {
|
|
||||||
std::cout << "setColor " << x << " " << y << " " << color << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void API::clearColor(int x, int y) {
|
|
||||||
std::cout << "clearColor " << x << " " << y << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void API::clearAllColor() {
|
|
||||||
std::cout << "clearAllColor" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void API::setText(int x, int y, const std::string& text) {
|
|
||||||
std::cout << "setText " << x << " " << y << " " << text << std::endl;
|
|
||||||
}
|
|
||||||
void API::setText(int x, int y, const int& text) {
|
|
||||||
std::cout << "setText " << x << " " << y << " " << text << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void API::clearText(int x, int y) {
|
|
||||||
std::cout << "clearText " << x << " " << y << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void API::clearAllText() {
|
|
||||||
std::cout << "clearAllText" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool API::wasReset() {
|
|
||||||
std::cout << "wasReset" << std::endl;
|
|
||||||
std::string response;
|
|
||||||
std::cin >> response;
|
|
||||||
return response == "true";
|
|
||||||
}
|
|
||||||
|
|
||||||
void API::ackReset() {
|
|
||||||
std::cout << "ackReset" << std::endl;
|
|
||||||
std::string ack;
|
|
||||||
std::cin >> ack;
|
|
||||||
}
|
|
||||||
void log(const std::string& text) {
|
|
||||||
std::cerr << text << std::endl;
|
|
||||||
}
|
|
||||||
void log(const char& text) {
|
|
||||||
std::cerr << text << std::endl;
|
|
||||||
}
|
|
||||||
void log(const int& num) {
|
|
||||||
std::cerr << num << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class API {
|
class API {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static int mazeWidth();
|
|
||||||
static int mazeHeight();
|
|
||||||
|
|
||||||
static bool wallFront();
|
static bool wallFront();
|
||||||
static bool wallRight();
|
static bool wallRight();
|
||||||
static bool wallLeft();
|
static bool wallLeft();
|
||||||
|
|
@ -17,22 +12,4 @@ public:
|
||||||
static void turnRight();
|
static void turnRight();
|
||||||
static void turnLeft();
|
static void turnLeft();
|
||||||
|
|
||||||
static void setWall(int x, int y, char direction);
|
|
||||||
static void clearWall(int x, int y, char direction);
|
|
||||||
|
|
||||||
static void setColor(int x, int y, char color);
|
|
||||||
static void clearColor(int x, int y);
|
|
||||||
static void clearAllColor();
|
|
||||||
|
|
||||||
static void setText(int x, int y, const std::string& text);
|
|
||||||
static void setText(int x, int y, const int& text);
|
|
||||||
static void clearText(int x, int y);
|
|
||||||
static void clearAllText();
|
|
||||||
|
|
||||||
static bool wasReset();
|
|
||||||
static void ackReset();
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void log(const std::string&);
|
|
||||||
void log(const int&);
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "esp32-hal-gpio.h"
|
#include "esp32-hal-gpio.h"
|
||||||
#include "mm.hpp" /* Archivos header ubicados en include/ */
|
#include "mm.hpp" /* Archivos header ubicados en include/ */
|
||||||
|
#include <api.h>
|
||||||
|
|
||||||
void m1handler();
|
void m1handler();
|
||||||
void m2handler();
|
void m2handler();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user