Nýtt branch og kóðar plús breytingar á fyrri kóðum fyrir part 4

This commit is contained in:
2026-10-01 12:55:11 +00:00
parent bf389cd012
commit a5c2da8bae
10 changed files with 144 additions and 1 deletions
+66
View File
@@ -0,0 +1,66 @@
#include "pre_operational_state.h"
#include "motor_controller.h"
#include <Arduino.h>
PreOperationalState::PreOperationalState()
: previous_time(0),
led_state(false)
{
}
void PreOperationalState::enter()
{
Serial.println("State: Pre-operational");
context->stop_motor();
context->led_off();
led_state = false;
previous_time = millis();
}
void PreOperationalState::update()
{
unsigned long current_time = millis();
if (current_time - previous_time >= 500)
{
previous_time = current_time;
led_state = !led_state;
if (led_state)
{
context->led_on();
}
else
{
context->led_off();
}
}
}
void PreOperationalState::command(char c)
{
if (c == 'o' || c == 'O')
{
Serial.println("Command: set operational");
context->to_operational();
}
else if (c == 'r' || c == 'R')
{
Serial.println("Command: reset");
context->to_initialization();
}
}
void PreOperationalState::exit()
{
context->led_off();
}