Nýjir kóðar og uppfærðir gamlir kóðar fyrir arduino yfir í zephyr

This commit is contained in:
2026-10-08 15:18:32 +00:00
parent 53091f68df
commit c2d8780478
24 changed files with 922 additions and 338 deletions
+12 -14
View File
@@ -1,17 +1,17 @@
#include "motor_controller.h"
#include "state.h"
#include <Arduino.h>
//#include <Arduino.h>
MotorController::MotorController(
RotaryEncoderDriver& encoder,
MotorDriver& motor,
P_controller& controller,
State& initialization,
State& pre_operational,
State& operational,
State& stopped
RotaryEncoderDriver &encoder,
MotorDriver &motor,
P_controller &controller,
State &initialization,
State &pre_operational,
State &operational,
State &stopped
)
: current_state(nullptr),
initialization_state(initialization),
@@ -54,15 +54,13 @@ void MotorController::begin()
}
void MotorController::transition_to(State& new_state)
void MotorController::transition_to(State &new_state)
{
if (current_state != nullptr)
{
if (current_state != nullptr) {
current_state->exit();
}
current_state = &new_state;
current_state->enter();
}
@@ -109,9 +107,9 @@ bool MotorController::run_speed_controller()
return false;
}
double actual = encoder.rpm();
const double actual = encoder.rpm();
double pwm_percent =
const double pwm_percent =
controller->update(reference_rpm, actual);
double pwm =