October 6, 2016

A Kyu tutorial - even more blinking

We can improve even further on the previous example. As we said, it is a very common thing to want to have a thread that runs repeatedly at some interval. A thread creation call is provided to do just that.
#include "kyu.h"
#include "thread.h"

static int led = 0;

static void
blinker ( int xx )
{
	gpio_led_set ( led );
	led = (led+1) % 2;
}

void
user_init ( int xx )
{

	gpio_led_init ();
	thr_new_repeat ( "blinker", blinker, 0, 10, 0, 500 );
}
This example uses an implicit continuation (you are probably thinking that Kyu is all about continuations, but it really isn't).


Have any comments? Questions? Drop me a line!

Kyu / tom@mmto.org