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
+16 -13
View File
@@ -1,6 +1,8 @@
#ifndef MOTOR_CONTROLLER_H
#define MOTOR_CONTROLLER_H
#include <stdint.h>
#include "rotary_encoder_driver.h"
#include "motor_driver.h"
#include "p_controller.h"
@@ -14,7 +16,8 @@ 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
//static const uint8_t LED_PIN = 5; // PB5 = D13 = LED_BUILTIN
static constexpr uint8_t LED_PIN = Digital_out::STATUS_LED;
State* current_state;
@@ -23,9 +26,9 @@ private:
State& operational_state;
State& stopped_state;
RotaryEncoderDriver& encoder;
MotorDriver& motor;
P_controller* controller;
RotaryEncoderDriver &encoder;
MotorDriver &motor;
P_controller *controller;
Digital_out led;
@@ -38,13 +41,13 @@ private:
public:
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
);
@@ -54,7 +57,7 @@ public:
void command(char c);
void transition_to(State& new_state);
void transition_to(State &new_state);
void to_initialization();
@@ -85,7 +88,7 @@ public:
void set_Ti(double value);
void set_controller(P_controller& new_controller);
void set_controller(P_controller &new_controller);
void led_on();