mirror of
https://github.com/usatiuk/EggbotWireless.git
synced 2025-10-26 08:47:49 +01:00
status now always reports position
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
#ifndef COMMANDS_H
|
||||
#define COMMANDS_H
|
||||
|
||||
constexpr int i2cFloatSize{4}, i2cCmdFloats{7},
|
||||
i2cCmdBytes{i2cFloatSize * i2cCmdFloats};
|
||||
#include "common/Util.h"
|
||||
|
||||
constexpr int i2cCmdFloats{7}, i2cCmdBytes{i2cFloatSize * i2cCmdFloats};
|
||||
|
||||
enum bcAxis {
|
||||
X = 1,
|
||||
@@ -10,13 +11,6 @@ enum bcAxis {
|
||||
Z = 3,
|
||||
};
|
||||
|
||||
enum class I2CStatusMsg {
|
||||
WAIT = 0,
|
||||
NEXT,
|
||||
TIMEOUT,
|
||||
ERR,
|
||||
};
|
||||
|
||||
enum PosMsg {
|
||||
servoRot,
|
||||
eggRot,
|
||||
@@ -43,14 +37,7 @@ struct Command {
|
||||
|
||||
Command(CommandType type = CommandType::unk, float arg1 = NAN,
|
||||
float arg2 = NAN, float arg3 = NAN, float arg4 = NAN,
|
||||
float arg5 = NAN, float arg6 = NAN)
|
||||
: type(type),
|
||||
arg1(arg1),
|
||||
arg2(arg2),
|
||||
arg3(arg3),
|
||||
arg4(arg4),
|
||||
arg5(arg5),
|
||||
arg6(arg6){};
|
||||
float arg5 = NAN, float arg6 = NAN);
|
||||
|
||||
Command(float *floats);
|
||||
void fromFloats(float *floats);
|
||||
@@ -61,7 +48,4 @@ struct Command {
|
||||
void toBytes(byte *bytes);
|
||||
};
|
||||
|
||||
void bytesToFloat(float *target, byte *val);
|
||||
void floatToBytes(byte *target, float val);
|
||||
|
||||
#endif
|
||||
39
Firmware/common/Status.h
Normal file
39
Firmware/common/Status.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef STATUS_H
|
||||
#define STATUS_H
|
||||
|
||||
#include "common/Util.h"
|
||||
|
||||
constexpr int i2cStsFloats{8}, i2cStsBytes{i2cFloatSize * i2cStsFloats};
|
||||
|
||||
enum class StatusType {
|
||||
unk = 0,
|
||||
WAIT,
|
||||
NEXT,
|
||||
TIMEOUT,
|
||||
ERR,
|
||||
};
|
||||
|
||||
struct Status {
|
||||
StatusType type = StatusType::unk;
|
||||
float mmS = NAN;
|
||||
float mmE = NAN;
|
||||
float pEng = NAN;
|
||||
float feedrate = NAN;
|
||||
float eggDia = NAN;
|
||||
float eggLen = NAN;
|
||||
float xLim = NAN;
|
||||
|
||||
Status(StatusType type = StatusType::unk, float mmS = NAN, float mmE = NAN,
|
||||
float pEng = NAN, float feedrate = NAN, float eggDia = NAN,
|
||||
float eggLen = NAN, float xLim = NAN);
|
||||
|
||||
Status(float *floats);
|
||||
void fromFloats(float *floats);
|
||||
void toFloats(float *floats);
|
||||
|
||||
Status(byte *bytes);
|
||||
void fromBytes(byte *bytes);
|
||||
void toBytes(byte *bytes);
|
||||
};
|
||||
|
||||
#endif
|
||||
17
Firmware/common/Util.h
Normal file
17
Firmware/common/Util.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
constexpr int i2cFloatSize{4};
|
||||
|
||||
inline void bytesToFloat(float *target, byte *val) {
|
||||
memcpy(target, val, i2cFloatSize);
|
||||
return;
|
||||
}
|
||||
|
||||
inline void floatToBytes(byte *target, float val) {
|
||||
memcpy(target, &val, i2cFloatSize);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user