src/drivers/rgbled/rgbled.cpp
/**
 * Set mode, if mode not changed has no any effect (doesn't reset blinks phase)
 */
Set mode, if mode not changed has no any effect (doesn't reset blinks phase)
Set mode if mode not changed has no any effect ( doesn ' t reset blinks phase )
void
RGBLED::set_mode(rgbled_mode_t mode)
{
	if (mode != _mode) {
		_mode = mode;
		switch (mode) {
		case RGBLED_MODE_OFF:
			_should_run = false;
			send_led_enable(false);
			break;
		case RGBLED_MODE_ON:
			_brightness = 1.0f;
			send_led_rgb();
			send_led_enable(true);
			break;
		case RGBLED_MODE_BLINK_SLOW:
			_should_run = true;
			_counter = 0;
			_led_interval = 2000;
			_brightness = 1.0f;
			send_led_rgb();
			break;
		case RGBLED_MODE_BLINK_NORMAL:
			_should_run = true;
			_counter = 0;
			_led_interval = 500;
			_brightness = 1.0f;
			send_led_rgb();
			break;
		case RGBLED_MODE_BLINK_FAST:
			_should_run = true;
			_counter = 0;
			_led_interval = 100;
			_brightness = 1.0f;
			send_led_rgb();
			break;
		case RGBLED_MODE_BREATHE:
			_should_run = true;
			_counter = 0;
			_led_interval = 25;
			send_led_enable(true);
			break;
		case RGBLED_MODE_PATTERN:
			_should_run = true;
			_counter = 0;
			_brightness = 1.0f;
			send_led_enable(true);
			break;
		default:
			warnx("mode unknown");
			break;
		}
		if (_should_run && !_running) {
			_running = true;
			work_queue(LPWORK, &_work, (worker_t)&RGBLED::led_trampoline, this, 1);
		}
	}
}
void RGBLED :: set_mode ( rgbled_mode_t mode ) { if ( mode != _mode ) { _mode = mode ; switch ( mode ) { case RGBLED_MODE_OFF : _should_run = false ; send_led_enable ( false ) ; break ; case RGBLED_MODE_ON : _brightness = 1.0f ; send_led_rgb ( ) ; send_led_enable ( true ) ; break ; case RGBLED_MODE_BLINK_SLOW : _should_run = true ; _counter = 0 ; _led_interval = 2000 ; _brightness = 1.0f ; send_led_rgb ( ) ; break ; case RGBLED_MODE_BLINK_NORMAL : _should_run = true ; _counter = 0 ; _led_interval = 500 ; _brightness = 1.0f ; send_led_rgb ( ) ; break ; case RGBLED_MODE_BLINK_FAST : _should_run = true ; _counter = 0 ; _led_interval = 100 ; _brightness = 1.0f ; send_led_rgb ( ) ; break ; case RGBLED_MODE_BREATHE : _should_run = true ; _counter = 0 ; _led_interval = 25 ; send_led_enable ( true ) ; break ; case RGBLED_MODE_PATTERN : _should_run = true ; _counter = 0 ; _brightness = 1.0f ; send_led_enable ( true ) ; break ; default : warnx ( " " ) ; break ; } if ( _should_run && ! _running ) { _running = true ; work_queue ( LPWORK , & _work , ( worker_t ) & RGBLED :: led_trampoline , this , 1 ) ; } } }
Set mode, if mode not changed has no any effect (doesn't reset blinks phase)
Set mode if mode not changed has no any effect ( doesn ' t reset blinks phase )
/* if it should run now, start the workq */