view examples/10-Instruments/d-box/StatusLED.h @ 556:ce391098f321 prerelease tip

THIS PROJECT HAS MOVED TO https://github.com/BelaPlatform/bela
author Giulio Moro <giuliomoro@yahoo.it>
date Sat, 25 Jun 2016 20:21:00 +0100
parents 8fcfbfb32aa0
children
line wrap: on
line source
/*
 * StatusLED.h
 *
 *
 */

#ifndef STATUSLED_H_
#define STATUSLED_H_

#include <pthread.h>
#include <unistd.h>

class StatusLED
{
public:
	StatusLED();
	~StatusLED();

	bool init(int gpio_pin);

	void on();
	void off();
	void blink(int ms_on, int ms_off);

	static void *static_blink_loop(void *data) {
		((StatusLED*)data)->blink_loop(NULL);
		return 0;
	}

	void* blink_loop(void *);

private:
	int gpio_number;
	int milliseconds_on, milliseconds_off;
	bool this_should_stop;
	pthread_t blink_thread;
};

#endif // STATUSLED_H_