I am trying to get Arduino working with Protothreads and wanted to confirm I have the basic setup correct. If I have understood the API correctly, then the following code should be what I need to start 2 concurrent threads from inside an Arduino program:
#include <pt.h>
static struct pt t1, t2;
void setup() {
PT_INIT(&t1);
PT_INIT(&t2);
}
void loop() {
doSomething(&t1, 500);
doSomethingElse(&t2, 500);
}
static int doSomething(struct pt *pt, int interval) {
PT_BEGIN(pt);
sleep(100);
PT_END(pt);
}
static int doSomethingElse(struct pt *pt, int interval) {
PT_BEGIN(pt);
sleep(250);
PT_END(pt);
}
Does anyone see anything that jumps out at them as missing or wrong?