October 6, 2016

A Kyu tutorial - a delay combined with a continuation

#include "kyu.h"
#include "thread.h"

static void
blinker ( int xx )
{
	/* Writing a "1" does turn the LED on */
	gpio_led_set ( 1 );
	thr_delay ( 100 );
	gpio_led_set ( 0 );
}

void
user_init ( int xx )
{

	gpio_led_init ();
	thr_new_repeat ( "blinker", blinker, 0, 10, 0, 1000 );
}
This is really not as elegant as the prior example, or maybe it is depending on how you look at it. This example shows that timer delays can be combined with repeating threads without a problem. The thread runs every 1000 ticks (once a second) and produces a pulse of 100 tick duration (0.1 second).

That is the end of this tutorial. It is admittedly sort of a whirlwind tour of Kyu facilities without a lot of explanation. It is designed more than anything to give the "flavor" of using Kyu, give examples of commonly used functions, and showcase some unique features.


Have any comments? Questions? Drop me a line!

Kyu / tom@mmto.org