Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions idf/taskboard/main/hal/board/TaskBoardDriver_v1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <sensor/CounterSensor.hpp>
#include <sensor/TriggeredSensor.hpp>
#include <task/TaskStepEqual.hpp>
#include <task/TaskStepEqualToRandom.hpp>
#include <task/SimultaneousConditionTask.hpp>
#include <task/SequentialTask.hpp>
#include <util/Timing.hpp>
Expand Down Expand Up @@ -264,13 +265,18 @@ struct TaskBoardDriver_v1 :
default_precondition_task_ = new SimultaneousConditionTask(*precondition_steps, "Precondition Task");

TaskStep* timed_fader_operation =
new TaskStepEqual(*get_sensor_by_name("FADER"), SensorMeasurement(0.8f), 0.05f);
timed_fader_operation->set_clue_timeout(*get_sensor_by_name("BLUE_BUTTON"), 3000);
new TaskStepEqual(*get_sensor_by_name("FADER"), SensorMeasurement(0.5f), 0.05f);
// timed_fader_operation->set_clue_timeout(*get_sensor_by_name("BLUE_BUTTON"), 3000);

TaskStep* random_fader_step =
new TaskStepEqualToRandom(*get_sensor_by_name("FADER"), 0.05f);
// random_fader_step->set_clue_timeout(*get_sensor_by_name("BLUE_BUTTON"), 3000);

std::vector<const TaskStep*>* main_steps = new std::vector<const TaskStep*>
{
new TaskStepEqual(*get_sensor_by_name("BLUE_BUTTON"), SensorMeasurement(true)),
timed_fader_operation,
random_fader_step,
new TaskStepEqual(*get_sensor_by_name("FADER_BLUE_BUTTON"), SensorMeasurement(0.2f), 0.05f),
new TaskStepEqual(*get_sensor_by_name("DOOR_OPEN"), SensorMeasurement(true)),
new TaskStepEqual(*get_sensor_by_name("PROBE_GOAL"), SensorMeasurement(true)),
Expand Down
23 changes: 23 additions & 0 deletions idf/taskboard/main/task/TaskExecutor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ struct TaskExecutor
current_task_->is_human_task() ? TFT_DARKGREY : TFT_BLACK);

force_screen_update_ = false;

blinkLED();
}

// Print clue
Expand Down Expand Up @@ -296,6 +298,16 @@ struct TaskExecutor
return ret;
}

void blinkLED() {
// Turn LED on
M5.Power.setLed(255);

// Start the timer to turn LED off
if (timer_led_ != nullptr) {
xTimerStart(timer_led_, 0);
}
}

ScreenController& screen_controller_; ///< Reference to screen controller
NonVolatileStorage& non_volatile_storage_; ///< Reference to non-volatile storage

Expand All @@ -306,5 +318,16 @@ struct TaskExecutor

SemaphoreHandle_t mutex_; ///< Mutex for thread safety

TimerHandle_t timer_led_ = xTimerCreate( ///< Timer to turn LED off
"LedOff", // Timer name
pdMS_TO_TICKS(500), // Delay in ms
pdFALSE, // Disabled auto-reload
nullptr,
[](TimerHandle_t xTimer) { // Callback
// Turn LED off
M5.Power.setLed(0);
}
);

std::vector<std::pair<Timer, TaskExecutorCallback>> task_callbacks_; ///< Vector of task update callbacks
};
21 changes: 21 additions & 0 deletions idf/taskboard/main/task/TaskStepEqualToRandom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,26 @@ struct TaskStepEqualToRandom :

private:

/// Virtual method implementation
void show_clue_implementation(
ClueScreenController& screen_controller) const override
{
if (!success())
{
screen_controller.print_task_clue(sensor_.name() + " != " + random_expected_value_.to_string());

const auto sensor_value = sensor_.read();

if (sensor_value.get_type() == SensorMeasurement::Type::ANALOG)
{
screen_controller.print_task_clue_analog(sensor_value.get_analog(), random_expected_value_.get_analog());
}
}
else
{
reset_clue();
}
}

mutable SensorMeasurement random_expected_value_; ///< Current random target value, updated when matched
};