more functions needed for hoverbrett

This commit is contained in:
interfisch 2022-03-28 21:49:19 +02:00
parent 97630cfcff
commit 2bb9f3d672
2 changed files with 18 additions and 1 deletions

View File

@ -7,11 +7,25 @@ ESCSerialComm::ESCSerialComm(HardwareSerial &_serialRef) { //constructor
wheelcircumference=0.5278; //8.4cm radius -> 0.084m*2*Pi wheelcircumference=0.5278; //8.4cm radius -> 0.084m*2*Pi
} }
void ESCSerialComm::init() {
serialRef->begin(SERIAL_CONTROL_BAUD);
}
void ESCSerialComm::setSpeed(int16_t uSpeedLeft, int16_t uSpeedRight) void ESCSerialComm::setSpeed(int16_t uSpeedLeft, int16_t uSpeedRight)
{ {
Motorparams.cmdL=uSpeedLeft; Motorparams.cmdL=uSpeedLeft;
Motorparams.cmdR=uSpeedRight; Motorparams.cmdR=uSpeedRight;
} }
int16_t ESCSerialComm::getCmdL() {
return Motorparams.cmdL;
}
int16_t ESCSerialComm::getCmdR() {
return Motorparams.cmdR;
}
bool ESCSerialComm::sendPending(long millis) {
return (millis - last_send > SENDPERIOD);
}
bool ESCSerialComm::update(long millis) //returns true if something was sent or received bool ESCSerialComm::update(long millis) //returns true if something was sent or received
{ {

View File

@ -8,7 +8,6 @@ int sort_desc(const void *cmp1, const void *cmp2);
float filterMedian(int16_t* values); float filterMedian(int16_t* values);
#define SERIAL_CONTROL_BAUD 115200 // [-] Baud rate for HoverSerial (used to communicate with the hoverboard) #define SERIAL_CONTROL_BAUD 115200 // [-] Baud rate for HoverSerial (used to communicate with the hoverboard)
#define SERIAL_BAUD 115200 // [-] Baud rate for built-in Serial (used for the Serial Monitor)
#define START_FRAME 0xABCD // [-] Start frme definition for reliable serial communication #define START_FRAME 0xABCD // [-] Start frme definition for reliable serial communication
@ -74,9 +73,13 @@ class ESCSerialComm
{ {
public: public:
ESCSerialComm(HardwareSerial& _SerialRef); //constructor ESCSerialComm(HardwareSerial& _SerialRef); //constructor
void init();
bool update(long millis); bool update(long millis);
bool feedbackAvailable(); bool feedbackAvailable();
void setSpeed(int16_t uSpeedLeft, int16_t uSpeedRight); void setSpeed(int16_t uSpeedLeft, int16_t uSpeedRight);
int16_t getCmdL();
int16_t getCmdR();
bool sendPending(long millis);
private: private:
unsigned long loopmillis; unsigned long loopmillis;