Browse Source

AP_Scheduler: use designated initializers for tasks structs

Makes code less prone to break build and semantics (e.g., when a new field is
added).
mission-4.1.18
Gustavo Jose de Sousa 10 years ago committed by Andrew Tridgell
parent
commit
2e6074c108
  1. 11
      libraries/AP_Scheduler/examples/Scheduler_test/Scheduler_test.cpp

11
libraries/AP_Scheduler/examples/Scheduler_test/Scheduler_test.cpp

@ -62,7 +62,10 @@ private: @@ -62,7 +62,10 @@ private:
static SchedTest schedtest;
#define SCHED_TASK(func) FUNCTOR_BIND(&schedtest, &SchedTest::func, void)
#define SCHED_TASK(func, _interval_ticks, _max_time_micros) {\
.function = FUNCTOR_BIND(&schedtest, &SchedTest::func, void),\
.interval_ticks = _interval_ticks,\
.max_time_micros = _max_time_micros}
/*
scheduler table - all regular tasks are listed here, along with how
@ -70,9 +73,9 @@ static SchedTest schedtest; @@ -70,9 +73,9 @@ static SchedTest schedtest;
they are expected to take (in microseconds)
*/
const AP_Scheduler::Task SchedTest::scheduler_tasks[] PROGMEM = {
{ SCHED_TASK(ins_update), 1, 1000 },
{ SCHED_TASK(one_hz_print), 50, 1000 },
{ SCHED_TASK(five_second_call), 250, 1800 },
SCHED_TASK(ins_update, 1, 1000),
SCHED_TASK(one_hz_print, 50, 1000),
SCHED_TASK(five_second_call, 250, 1800),
};

Loading…
Cancel
Save