/*
#include "contiki.h"
#include <stdio.h>
PROCESS(hello_world_process, "Hello world process");
AUTOSTART_PROCESSES(&hello_world_process);
PROCESS_THREAD(hello_world_process, ev, data)
{
PROCESS_BEGIN();
printf("Hello, world\n");
PROCESS_END();
}
*/



#include <stdio.h> /* For printf() */
#include "contiki.h"
#include "dev/leds.h"
#include "lib/random.h"
#include "sys/ctimer.h"
#include "sys/etimer.h"

static struct etimer et_hello;
static uint16_t count;
static uint8_t blinks;
PROCESS(hello_world_process, "[Exemple] Hello world avec affichage des LED");
AUTOSTART_PROCESSES(&hello_world_process);//, &blink_process);


PROCESS_THREAD(hello_world_process, ev, data)
{
PROCESS_BEGIN();
count = 1;
blinks = 1;
while(1) {
etimer_set(&et_hello, CLOCK_SECOND*30); // Start the timer
PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER);
printf("[Exemple] Cycle : #%u\n", count);
count++;
leds_off(LEDS_ALL);
if (blinks==1){
leds_on(LEDS_BLUE);
printf("[Exemple] Passage au bleu\n");
}
else if (blinks==2){
leds_on(LEDS_RED);
printf("[Exemple] Passage au rouge\n");
}
else if (blinks==3){
leds_on(LEDS_GREEN);
printf("[Exemple] Passage au vert\n");
blinks=0;
}
blinks++;
}
PROCESS_END();
}
