Skip to content
Snippets Groups Projects
Commit c655f3f8 authored by Armin Co's avatar Armin Co
Browse files

Slow down simulation and sending.

parent dfa0bef9
Branches
No related tags found
No related merge requests found
...@@ -58,14 +58,18 @@ void SmartGridModell::default_state_fancy() ...@@ -58,14 +58,18 @@ void SmartGridModell::default_state_fancy()
void SmartGridModell::update_windmill_speed(uint8_t speed) void SmartGridModell::update_windmill_speed(uint8_t speed)
{ {
constexpr uint8_t min_motor_speed {35}; constexpr uint8_t min_motor_speed {40};
if (speed >= min_motor_speed) if (speed == 0)
{ {
set_output_pin(Pin::WindmillMotor, speed); set_output_pin(Pin::WindmillMotor, 0);
} }
else if (speed == 0) else if (speed > 180)
{ {
set_output_pin(Pin::WindmillMotor, 0); set_output_pin(Pin::WindmillMotor, 140);
}
else if (speed <= min_motor_speed)
{
set_output_pin(Pin::WindmillMotor, speed);
} }
else else
{ {
...@@ -115,7 +119,7 @@ void SmartGridModell::set_output_pin(Pin pin, uint8_t value) ...@@ -115,7 +119,7 @@ void SmartGridModell::set_output_pin(Pin pin, uint8_t value)
bool succ = m_modell.send(static_cast<uint8_t>(pin), value); bool succ = m_modell.send(static_cast<uint8_t>(pin), value);
spdlog::debug("Send: {} {}, success: {}", pin, value, succ); spdlog::debug("Send: {} {}, success: {}", pin, value, succ);
using namespace std; using namespace std;
this_thread::sleep_for(chrono::milliseconds(12)); this_thread::sleep_for(chrono::milliseconds(14));
} }
void SmartGridModell::set_house_color(House number, uint8_t red, uint8_t green) void SmartGridModell::set_house_color(House number, uint8_t red, uint8_t green)
......
...@@ -65,7 +65,8 @@ void run_sim() ...@@ -65,7 +65,8 @@ void run_sim()
sim_state = SimState::Do; sim_state = SimState::Do;
break; break;
case SimState::Do: case SimState::Do:
std::this_thread::sleep_for(std::chrono::milliseconds(50)); // limit speed of simulation
std::this_thread::sleep_for(std::chrono::milliseconds(500));
if (sim_state_do(day) == true) if (sim_state_do(day) == true)
{ {
sim_state = SimState::Exit; sim_state = SimState::Exit;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment