Part 2 nýjir kóðar, fyrir STOP og Fault kerfi
This commit is contained in:
@@ -15,6 +15,7 @@ private:
|
||||
|
||||
State* initialization_state;
|
||||
State* operational_state;
|
||||
State* stopped_state;
|
||||
|
||||
RotaryEncoderDriver& encoder;
|
||||
MotorDriver& motor;
|
||||
@@ -33,7 +34,8 @@ public:
|
||||
|
||||
void set_states(
|
||||
State* initialization,
|
||||
State* operational
|
||||
State* operational,
|
||||
State* stopped
|
||||
);
|
||||
|
||||
|
||||
@@ -50,6 +52,10 @@ public:
|
||||
|
||||
void to_operational();
|
||||
|
||||
void to_stopped();
|
||||
|
||||
bool fault_active();
|
||||
|
||||
|
||||
void run_speed_controller();
|
||||
|
||||
|
||||
@@ -9,10 +9,14 @@ public:
|
||||
void begin();
|
||||
|
||||
void forward();
|
||||
|
||||
void reverse();
|
||||
|
||||
void stop();
|
||||
|
||||
void set(double pwm);
|
||||
|
||||
bool fault_active(); // Fault detection for part 2
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef STOPPED_STATE_H
|
||||
#define STOPPED_STATE_H
|
||||
|
||||
#include "state.h"
|
||||
|
||||
class StoppedState : public State
|
||||
{
|
||||
private:
|
||||
unsigned long previous_time; // Used for blinking LED
|
||||
bool led_state; // Ditto
|
||||
|
||||
public:
|
||||
StoppedState();
|
||||
|
||||
void enter() override;
|
||||
|
||||
void update() override;
|
||||
|
||||
void command(char c) override;
|
||||
|
||||
void exit() override;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user