style: fix missing formatting

This commit is contained in:
Julien Oculi 2025-06-10 22:44:51 +02:00
parent 0dcbe05688
commit 633d9006fb
5 changed files with 45 additions and 44 deletions

View file

@ -5,22 +5,22 @@ double degToRad(double deg) { return deg * M_PI / 180.0; }
double radToDeg(double rad) { return rad * 180.0 / M_PI; } double radToDeg(double rad) { return rad * 180.0 / M_PI; }
void angleToStep(Turret::StepRatio stepRatio, vec2<double> angle, vec2<long> &step) { void angleToStep(Turret::StepRatio stepRatio, vec2<double> angle,
vec2<long> &step) {
step.x = angle.x * stepRatio.x; step.x = angle.x * stepRatio.x;
step.y = angle.y * stepRatio.y; step.y = angle.y * stepRatio.y;
} }
void cartesianToPolar(Turret::StepRatio stepRatio, Turret::Offset offset, vec2<long> zero, vec3<double> position, vec2<long> &step) { void cartesianToPolar(Turret::StepRatio stepRatio, Turret::Offset offset,
vec2<long> zero, vec3<double> position,
vec2<long> &step) {
// x = -x; // natural axis direction // x = -x; // natural axis direction
position.y = -position.y; // natural axis direction position.y = -position.y; // natural axis direction
double dX = position.x + offset.x; double dX = position.x + offset.x;
double dY = position.y + offset.y; double dY = position.y + offset.y;
double dZ = position.z + offset.z; double dZ = position.z + offset.z;
vec2<double> angle( vec2<double> angle(atan2(dZ, dY) - M_PI / 2, atan2(dZ, dX) - M_PI / 2);
atan2(dZ, dY) - M_PI / 2,
atan2(dZ, dX) - M_PI / 2
);
angleToStep(stepRatio, angle, step); angleToStep(stepRatio, angle, step);
} }

View file

@ -2,5 +2,7 @@
double degToRad(double deg); double degToRad(double deg);
double radToDeg(double rad); double radToDeg(double rad);
void angleToStep(Turret::StepRatio stepRatio, vec2<double> angle, vec2<long> &step); void angleToStep(Turret::StepRatio stepRatio, vec2<double> angle,
void cartesianToPolar(Turret::StepRatio stepRatio, Turret::Offset offset, vec2<long> zero, vec3<double> position, vec2<long> &step); vec2<long> &step);
void cartesianToPolar(Turret::StepRatio stepRatio, Turret::Offset offset,
vec2<long> zero, vec3<double> position, vec2<long> &step);

View file

@ -2,14 +2,14 @@
#include "maths.h" #include "maths.h"
#include <kissStepper.h> #include <kissStepper.h>
Turret::Turret(StepRatio step_ratio, Offset offset, PinMap pin_map_x, PinMap pin_map_y) Turret::Turret(StepRatio step_ratio, Offset offset, PinMap pin_map_x,
: _stepper( PinMap pin_map_y)
kissStepper(static_cast<uint8_t>(pin_map_x.direction), : _stepper(kissStepper(static_cast<uint8_t>(pin_map_x.direction),
static_cast<uint8_t>(pin_map_x.pulse), static_cast<uint8_t>(pin_map_x.pulse),
static_cast<uint8_t>(pin_map_x.enable)), static_cast<uint8_t>(pin_map_x.enable)),
kissStepper(static_cast<uint8_t>(pin_map_y.direction), kissStepper(static_cast<uint8_t>(pin_map_y.direction),
static_cast<uint8_t>(pin_map_y.pulse), static_cast<uint8_t>(pin_map_y.pulse),
static_cast<uint8_t>(pin_map_y.enable))) { static_cast<uint8_t>(pin_map_y.enable))) {
_pin.x = pin_map_x; _pin.x = pin_map_x;
_pin.y = pin_map_y; _pin.y = pin_map_y;
@ -121,11 +121,11 @@ Turret &Turret::moveTo(double x, double y, double z, Unit unit) {
} }
if (unit == Unit::RAD) { if (unit == Unit::RAD) {
angleToStep(_step_ratio, vec2<double> (x, y), step); angleToStep(_step_ratio, vec2<double>(x, y), step);
} }
if (unit == Unit::DEG) { if (unit == Unit::DEG) {
angleToStep(_step_ratio, vec2<double> (degToRad(x), degToRad(y)), step); angleToStep(_step_ratio, vec2<double>(degToRad(x), degToRad(y)), step);
} }
// TODO min(valueI, -_homeI); // TODO min(valueI, -_homeI);

View file

@ -3,23 +3,21 @@
#include <kissStepper.h> #include <kissStepper.h>
template <typename T> template <typename T> struct vec3 {
struct vec3 { T x;
T x; T y;
T y; T z;
T z;
vec3() : x(T()), y(T()), z(T()) {} vec3() : x(T()), y(T()), z(T()) {}
vec3(T _x, T _y, T _z) : x(_x), y(_y), z(_z) {} vec3(T _x, T _y, T _z) : x(_x), y(_y), z(_z) {}
}; };
template <typename T> template <typename T> struct vec2 {
struct vec2 { T x;
T x; T y;
T y;
vec2() : x(T()), y(T()) {} vec2() : x(T()), y(T()) {}
vec2(T _x, T _y) : x(_x), y(_y) {} vec2(T _x, T _y) : x(_x), y(_y) {}
}; };
class Turret { class Turret {
@ -28,8 +26,8 @@ public:
using StepRatio = vec2<double>; using StepRatio = vec2<double>;
using Offset = vec3<double>; using Offset = vec3<double>;
//x -> turret to screen // x -> turret to screen
//y -> laser to stand // y -> laser to stand
// z -> unused // z -> unused
struct PinMap { struct PinMap {
@ -40,7 +38,8 @@ public:
int laser; int laser;
}; };
Turret(StepRatio step_ratio, Offset offset, PinMap pin_map_x, PinMap pin_map_y); Turret(StepRatio step_ratio, Offset offset, PinMap pin_map_x,
PinMap pin_map_y);
Turret &init(); Turret &init();
Turret &gotoHome(); Turret &gotoHome();

View file

@ -2,19 +2,19 @@
#include "turret.h" #include "turret.h"
Turret::PinMap pinX = { Turret::PinMap pinX = {
.home = PIN_X_HOME, .home = PIN_X_HOME,
.direction = PIN_X_DIRECTION, .direction = PIN_X_DIRECTION,
.pulse = PIN_X_PULSE, .pulse = PIN_X_PULSE,
.enable = PIN_X_ENABLE, .enable = PIN_X_ENABLE,
.laser = PIN_LASER, .laser = PIN_LASER,
}; };
Turret::PinMap pinY = { Turret::PinMap pinY = {
.home = PIN_Y_HOME, .home = PIN_Y_HOME,
.direction = PIN_Y_DIRECTION, .direction = PIN_Y_DIRECTION,
.pulse = PIN_Y_PULSE, .pulse = PIN_Y_PULSE,
.enable = PIN_Y_ENABLE, .enable = PIN_Y_ENABLE,
.laser = PIN_LASER, .laser = PIN_LASER,
}; };
Turret::StepRatio stepRatio(STEP_RATIO_X, STEP_RATIO_Y); Turret::StepRatio stepRatio(STEP_RATIO_X, STEP_RATIO_Y);