Small refactoring
This commit is contained in:
parent
c9c87ae704
commit
8bc7a5242f
@ -1,5 +1,7 @@
|
||||
#include "OSCRemote.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
//! --- Start of onfiguration ---
|
||||
//#define DEBUG // Enables CM prints if commented
|
||||
|
||||
@ -25,25 +27,25 @@ const float vyFactor = 0.1;
|
||||
const float wFactor = 10;
|
||||
|
||||
void remoteMsgParser(OSCMessage &msg, int offset) {
|
||||
char topic[20];
|
||||
msg.getAddress(topic);
|
||||
Serial.println(topic);
|
||||
std::array<char, 20> topic;
|
||||
msg.getAddress(topic.data());
|
||||
Serial.println(topic.data());
|
||||
|
||||
if (!strcmp(topic, "/att/xy")) {
|
||||
if (!strcmp(topic.data(), "/att/xy")) {
|
||||
pOutput->attitude.pitch = msg.getFloat(0) * pitchFactor;
|
||||
pOutput->attitude.roll = msg.getFloat(1) * rollFactor;
|
||||
}
|
||||
else if (!strcmp(topic, "/att/z")) {
|
||||
else if (!strcmp(topic.data(), "/att/z")) {
|
||||
pOutput->attitude.yaw = msg.getFloat(0) * yawFactor;
|
||||
}
|
||||
else if (!strcmp(topic, "/att/e")) {
|
||||
else if (!strcmp(topic.data(), "/att/e")) {
|
||||
pOutput->attitude.elevator = msg.getFloat(0) * elevatorFactor;
|
||||
}
|
||||
else if (!strcmp(topic, "/mov/xy")) {
|
||||
else if (!strcmp(topic.data(), "/mov/xy")) {
|
||||
pOutput->movement.vy = msg.getFloat(0) * vxFactor;
|
||||
pOutput->movement.vx = msg.getFloat(1) * vyFactor;
|
||||
}
|
||||
else if (!strcmp(topic, "/mov/z")) {
|
||||
else if (!strcmp(topic.data(), "/mov/z")) {
|
||||
pOutput->movement.w = msg.getFloat(0) * wFactor;
|
||||
}
|
||||
else {
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "body.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
//! --- Start of onfiguration ---
|
||||
const char *hostname = "Hexapod";
|
||||
@ -13,7 +14,7 @@ const char *hostname = "Hexapod";
|
||||
|
||||
Body body = Body::instance();
|
||||
Config config;
|
||||
IRemote *remote;
|
||||
std::unique_ptr<IRemote> remote;
|
||||
Vbat vbat;
|
||||
|
||||
void servoTest() {
|
||||
@ -71,7 +72,7 @@ void setup() {
|
||||
Serial.printf("SSID: %s\n", config.data().wifiSSID);
|
||||
Serial.printf("pass: %s\n", config.data().wifiPass);
|
||||
connectWiFi();
|
||||
remote = new OSCRemote(vbat);
|
||||
remote.reset(new OSCRemote(vbat));
|
||||
remote->registerCallback(testRemoteCallback);
|
||||
// remote->init();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user