Skip to content

Commit

Permalink
Esteso esempio con coda eventi schedulata e gestita da un thread sepa…
Browse files Browse the repository at this point in the history
…rato.

Build task configurato in vscode.
  • Loading branch information
maiorfi-at-innovactive committed Oct 14, 2017
1 parent c65a316 commit fd36ba8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "mbed compile (debug)",
"type": "shell",
"command": "mbed compile --profile mbed-os/tools/profiles/debug.json",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
19 changes: 19 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@ static DigitalOut led2(LED2);
static DigitalOut led3(LED6);
static DigitalOut led4(LED5);

static Serial s_debug_serial_port(SERIAL_TX, SERIAL_RX);

static Thread s_thread_blink;
static Thread s_thread_recurrent_1;

static EventQueue s_eq_recurrent_1;

static Timer s_timer_1;

void event_proc_recurrent_1(char c)
{
printf("[event_proc_recurrent_1] Elapsed %d ms\n",s_timer_1.read_ms());
}

void thread_proc_blink(std::vector<DigitalOut> *pleds)
{
Expand All @@ -26,10 +38,17 @@ void thread_proc_blink(std::vector<DigitalOut> *pleds)

int main()
{
s_debug_serial_port.baud(115200);

s_leds.push_back(led1);
s_leds.push_back(led2);
s_leds.push_back(led3);
s_leds.push_back(led4);

s_eq_recurrent_1.call_every(1000,event_proc_recurrent_1,'.');

s_thread_blink.start(callback(thread_proc_blink, &s_leds));

s_timer_1.start();
s_thread_recurrent_1.start(callback(&s_eq_recurrent_1,&EventQueue::dispatch_forever));
}

0 comments on commit fd36ba8

Please sign in to comment.