Encoder fyrir position í int32, stöðuvél án null-pointera, nefndir fastar, LED gegnum context

This commit is contained in:
2026-09-30 11:55:41 +00:00
parent c46539a57b
commit 1e02205344
8 changed files with 91 additions and 99 deletions
+18 -11
View File
@@ -4,6 +4,7 @@
#include "rotary_encoder_driver.h"
#include "motor_driver.h"
#include "p_controller.h"
#include "digital_out.h"
class State;
@@ -11,15 +12,21 @@ class State;
class MotorController
{
private:
static constexpr double DEFAULT_REFERENCE_RPM = 40.0;
static constexpr double PWM_PER_PERCENT = 255.0 / 100.0;
static const uint8_t LED_PIN = 5; // PB5 = D13 = LED_BUILTIN
State* current_state;
State* initialization_state;
State* operational_state;
State& initialization_state;
State& operational_state;
RotaryEncoderDriver& encoder;
MotorDriver& motor;
P_controller& controller;
Digital_out led;
double reference_rpm;
@@ -27,13 +34,9 @@ public:
MotorController(
RotaryEncoderDriver& encoder,
MotorDriver& motor,
P_controller& controller
);
void set_states(
State* initialization,
State* operational
P_controller& controller,
State& initialization,
State& operational
);
@@ -43,7 +46,7 @@ public:
void command(char c);
void transition_to(State* new_state);
void transition_to(State& new_state);
void to_initialization();
@@ -56,6 +59,10 @@ public:
void stop_motor();
void reset_speed_measurement();
void led_on();
void led_off();
};
#endif
#endif