From 633d9006fb3aef51065e294831dc2cb0047550a1 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Tue, 10 Jun 2025 22:44:51 +0200 Subject: [PATCH] style: fix missing formatting --- maths.cpp | 12 ++++++------ maths.h | 6 ++++-- turret.cpp | 20 ++++++++++---------- turret.h | 31 +++++++++++++++---------------- turret_debug.ino | 20 ++++++++++---------- 5 files changed, 45 insertions(+), 44 deletions(-) diff --git a/maths.cpp b/maths.cpp index a0c7acd..2aaff10 100644 --- a/maths.cpp +++ b/maths.cpp @@ -5,22 +5,22 @@ double degToRad(double deg) { return deg * M_PI / 180.0; } double radToDeg(double rad) { return rad * 180.0 / M_PI; } -void angleToStep(Turret::StepRatio stepRatio, vec2 angle, vec2 &step) { +void angleToStep(Turret::StepRatio stepRatio, vec2 angle, + vec2 &step) { step.x = angle.x * stepRatio.x; step.y = angle.y * stepRatio.y; } -void cartesianToPolar(Turret::StepRatio stepRatio, Turret::Offset offset, vec2 zero, vec3 position, vec2 &step) { +void cartesianToPolar(Turret::StepRatio stepRatio, Turret::Offset offset, + vec2 zero, vec3 position, + vec2 &step) { // x = -x; // natural axis direction position.y = -position.y; // natural axis direction double dX = position.x + offset.x; double dY = position.y + offset.y; double dZ = position.z + offset.z; - vec2 angle( - atan2(dZ, dY) - M_PI / 2, - atan2(dZ, dX) - M_PI / 2 - ); + vec2 angle(atan2(dZ, dY) - M_PI / 2, atan2(dZ, dX) - M_PI / 2); angleToStep(stepRatio, angle, step); } diff --git a/maths.h b/maths.h index a6eb16c..b864db8 100644 --- a/maths.h +++ b/maths.h @@ -2,5 +2,7 @@ double degToRad(double deg); double radToDeg(double rad); -void angleToStep(Turret::StepRatio stepRatio, vec2 angle, vec2 &step); -void cartesianToPolar(Turret::StepRatio stepRatio, Turret::Offset offset, vec2 zero, vec3 position, vec2 &step); +void angleToStep(Turret::StepRatio stepRatio, vec2 angle, + vec2 &step); +void cartesianToPolar(Turret::StepRatio stepRatio, Turret::Offset offset, + vec2 zero, vec3 position, vec2 &step); diff --git a/turret.cpp b/turret.cpp index 7c7098e..fde2d4e 100644 --- a/turret.cpp +++ b/turret.cpp @@ -2,14 +2,14 @@ #include "maths.h" #include -Turret::Turret(StepRatio step_ratio, Offset offset, PinMap pin_map_x, PinMap pin_map_y) - : _stepper( - kissStepper(static_cast(pin_map_x.direction), - static_cast(pin_map_x.pulse), - static_cast(pin_map_x.enable)), - kissStepper(static_cast(pin_map_y.direction), - static_cast(pin_map_y.pulse), - static_cast(pin_map_y.enable))) { +Turret::Turret(StepRatio step_ratio, Offset offset, PinMap pin_map_x, + PinMap pin_map_y) + : _stepper(kissStepper(static_cast(pin_map_x.direction), + static_cast(pin_map_x.pulse), + static_cast(pin_map_x.enable)), + kissStepper(static_cast(pin_map_y.direction), + static_cast(pin_map_y.pulse), + static_cast(pin_map_y.enable))) { _pin.x = pin_map_x; _pin.y = pin_map_y; @@ -121,11 +121,11 @@ Turret &Turret::moveTo(double x, double y, double z, Unit unit) { } if (unit == Unit::RAD) { - angleToStep(_step_ratio, vec2 (x, y), step); + angleToStep(_step_ratio, vec2(x, y), step); } if (unit == Unit::DEG) { - angleToStep(_step_ratio, vec2 (degToRad(x), degToRad(y)), step); + angleToStep(_step_ratio, vec2(degToRad(x), degToRad(y)), step); } // TODO min(valueI, -_homeI); diff --git a/turret.h b/turret.h index b50ba69..07de1fc 100644 --- a/turret.h +++ b/turret.h @@ -3,23 +3,21 @@ #include -template -struct vec3 { - T x; - T y; - T z; +template struct vec3 { + T x; + T y; + T z; - vec3() : x(T()), y(T()), z(T()) {} - vec3(T _x, T _y, T _z) : x(_x), y(_y), z(_z) {} + vec3() : x(T()), y(T()), z(T()) {} + vec3(T _x, T _y, T _z) : x(_x), y(_y), z(_z) {} }; -template -struct vec2 { - T x; - T y; +template struct vec2 { + T x; + T y; - vec2() : x(T()), y(T()) {} - vec2(T _x, T _y) : x(_x), y(_y) {} + vec2() : x(T()), y(T()) {} + vec2(T _x, T _y) : x(_x), y(_y) {} }; class Turret { @@ -28,8 +26,8 @@ public: using StepRatio = vec2; using Offset = vec3; - //x -> turret to screen - //y -> laser to stand + // x -> turret to screen + // y -> laser to stand // z -> unused struct PinMap { @@ -40,7 +38,8 @@ public: 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 &gotoHome(); diff --git a/turret_debug.ino b/turret_debug.ino index e3ca96f..6806f71 100644 --- a/turret_debug.ino +++ b/turret_debug.ino @@ -2,19 +2,19 @@ #include "turret.h" Turret::PinMap pinX = { - .home = PIN_X_HOME, - .direction = PIN_X_DIRECTION, - .pulse = PIN_X_PULSE, - .enable = PIN_X_ENABLE, - .laser = PIN_LASER, + .home = PIN_X_HOME, + .direction = PIN_X_DIRECTION, + .pulse = PIN_X_PULSE, + .enable = PIN_X_ENABLE, + .laser = PIN_LASER, }; Turret::PinMap pinY = { - .home = PIN_Y_HOME, - .direction = PIN_Y_DIRECTION, - .pulse = PIN_Y_PULSE, - .enable = PIN_Y_ENABLE, - .laser = PIN_LASER, + .home = PIN_Y_HOME, + .direction = PIN_Y_DIRECTION, + .pulse = PIN_Y_PULSE, + .enable = PIN_Y_ENABLE, + .laser = PIN_LASER, }; Turret::StepRatio stepRatio(STEP_RATIO_X, STEP_RATIO_Y);