You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
1.7 KiB
C

2 years ago
// AutoPathRunner.h
#ifndef _AUTOPATHRUNNER_h
#define _AUTOPATHRUNNER_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "OpenMVOpt.h"
#include <Ultrasonic.h>
#include "AccurateMotor.h"
2 years ago
#include "GarageCommand.h"
#include "CommandDecoder.h"
#include "ZigBeeOperator.h"
2 years ago
namespace AutoPathRunner
{
enum class TurnDirection
{
Null,
Left,
Right
};
enum class CarHeadPosition
{
X_Positive,
Y_Positive,
X_Negitive,
Y_Negitive
};
class MapPoint
{
private:
int x, y;
public:
MapPoint();
MapPoint(int x, int y);
public:
int GetX() const;
int GetY() const;
2 years ago
void SetX(int x);
void SetY(int y);
bool NeedTurn(MapPoint next, CarHeadPosition pos);
TurnDirection CalcTurnDirection(MapPoint next, CarHeadPosition pos);
public:
MapPoint operator=(const MapPoint& obj);
bool operator==(const MapPoint& obj);
};
struct PointMapper
{
char name[3] = { 0 };
MapPoint point;
PointMapper();
PointMapper(const char* n, const MapPoint& p);
};
typedef void(*MCRCallback)(String point, CarHeadPosition pos);
2 years ago
MapPoint Mapping(const char* name);
String ReverseMapping(const MapPoint& point);
2 years ago
void ChangePositon(CarHeadPosition& pos, TurnDirection turn);
CarHeadPosition Int2Position(int pos);
bool TrackCallback();
//<2F><><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
MapPoint* DecodeRoute(const char* route, int& point_cnt);
//ִ<><D6B4>·<EFBFBD><C2B7>ָ<EFBFBD><D6B8>
void DoRun(MapPoint* points, int point_cnt, CarHeadPosition pos, MCRCallback cb = nullptr);
2 years ago
//<2F><><EFBFBD><EFBFBD>RFID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>α<EFBFBD>־<EFBFBD><D6BE>
bool IsSpecTerrainItem();
2 years ago
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//a_b_select:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>true -> A, false -> B
void ReversingIntoGarage(bool a_b_select, uint8_t target_floor);
2 years ago
};
#endif