Simple stroboscope

Simple function for stoboscope effect. User defines time between light breaks (in milliseconds) and number of repetitions.

//    PRIVILEGE needed to be set in tizen-manifest.xml:
//    http://tizen.org/privilege/led

#include <dlog.h> // for logging purposes
#include <device/led.h>

void
stroboscope(int milliseconds, int repetitions) {
	int max;
	int i = 0;
	bool inf = false;

	if(repetitions == 0) {
		inf = true;
	}

	if(device_flash_get_max_brightness(&max) == DEVICE_ERROR_NONE) {
		LOGI("Max value of LED: %d", max);

		if(device_flash_set_brightness(max) == DEVICE_ERROR_NONE) {
			LOGI("LED set to maximum value");
			while(i<repetitions  || inf) {
				usleep(milliseconds*1000);

				device_flash_set_brightness(0);
				usleep(milliseconds*1000);
				if(device_flash_set_brightness(max) == DEVICE_ERROR_NONE) {
					LOGI("LED set to maximum value");
				}
				i++;
			}
		device_flash_set_brightness(0);
		}
	}
}

Responses

0 Replies