Example #1
0
File: lsc.c Project: wcheswick/ex
void
kbd_hit(char key) {
	set_active();
	switch (key) {
	case 'd':
		dump_screen(0);
		break;
	case 'w':
	case 'W':
		save_image();
		break;
	case 'q':
	case 'Q':
	case 'x':
	case 'X':	/* exit the program */
		end_display();
		exit(0);
	case 'v':
		show_video_settings = !show_video_settings;
		refresh_screen = 1;
		break;
	case 'h':
		set_hue(get_hue() - 1);
		refresh_screen = 1;
		break;
	case 'H':
		set_hue(get_hue() + 1);
		refresh_screen = 1;
		break;
	case 's':
		set_saturation(get_saturation() - 1);
		refresh_screen = 1;
		break;
	case 'S':
		set_saturation(get_saturation() + 1);
		refresh_screen = 1;
		break;
	case 'b':
		set_brightness(get_brightness() - 1);
		refresh_screen = 1;
		break;
	case 'B':
		set_brightness(get_brightness() + 1);
		refresh_screen = 1;
		break;
	case 'c':
		set_contrast(get_contrast() - 1);
		refresh_screen = 1;
		break;
	case 'C':
		set_contrast(get_contrast() + 1);
		refresh_screen = 1;
		break;
	}
}
Example #2
0
static void v4l_picture_controls(struct context *cnt, struct video_dev *viddev)
{
    int dev = viddev->fd_bktr;

    if ((cnt->conf.contrast) && (cnt->conf.contrast != viddev->contrast)) { 
        set_contrast(dev, cnt->conf.contrast);
        viddev->contrast = cnt->conf.contrast;    
    }

    if ((cnt->conf.hue) && (cnt->conf.hue != viddev->hue)) {
        set_hue(dev, cnt->conf.hue);
        viddev->hue = cnt->conf.hue;    
    }

    if ((cnt->conf.brightness) && 
        (cnt->conf.brightness != viddev->brightness)) {
        set_brightness(dev, cnt->conf.brightness);
        viddev->brightness = cnt->conf.brightness; 
    }

    if ((cnt->conf.saturation) && 
        (cnt->conf.saturation != viddev->saturation)) {
        set_saturation(dev, cnt->conf.saturation);
        viddev->saturation = cnt->conf.saturation;
    }
}
Example #3
0
Gobby::HueButton::HueButton(const Glib::ustring& title, Gtk::Window& parent):
	m_title(title), m_parent(parent), m_saturation(1.0), m_value(1.0)
{
	parent.signal_hide().connect(
		sigc::mem_fun(*this, &HueButton::on_parent_hide));
	set_hue(1.0);
}
Example #4
0
void Gobby::HueButton::on_dialog_response(int response_id)
{
	if(response_id == Gtk::RESPONSE_OK)
	{
		set_hue(
			inf_text_gtk_hue_chooser_get_hue(
				INF_TEXT_GTK_HUE_CHOOSER(m_hue_chooser)));
	}

	m_dialog->hide();
}
Example #5
0
void Gobby::HueButton::set_value(double value)
{
	m_value = value;
	set_hue(get_hue()); // Update view
}
Example #6
0
void Gobby::HueButton::set_saturation(double saturation)
{
	m_saturation = saturation;
	set_hue(get_hue()); // Update view
}
Example #7
0
int main(void)
{
	//port configuration

	DDRA=(1<<LED)|(1<<RED)|(1<<GREEN)|(1<<BLUE);		//leds as output
	DDRB=(1<<DIRECTION)|(1<<ENABLE);			//motor direction and enable as output
	PORTA=(1<<BUTTON)|(1<<TRAY_OUT)|(1<<TRAY_IN)|(1<<LED);	//pull-ups and LED on for debug

	//pwm setup for motor and front led

	pwm(0);							//configure motor and front led pwm
	TCCR0B = (1<<CS00);
	ADMUX = (1<<MUX0)|(1<<MUX1); 				//select PA3 for adc
	ADCSRB = (1<<ACME)|(1<<ADLAR);				// enable as adc source and select to show the 8 highest bits
	ADCSRA = (1<<ADEN)|(1<<ADSC)|(1<<ADATE);		//enable with auto trigger

	//configure software pwm
	TIMSK0 = (1<<TOIE0);
	pwm_RED = 0;
	pwm_GREEN = 0;
	pwm_BLUE = 0;
	sei();							//interrupts on

	int i=0,dir=1,afk=0;				//dir 1=in 2=out 0=don't care
	uint16_t cnt=0;
	OCR0B=0;						//front led brightness

	while(1)
	{
		//move tray if the button is pressed

		if(bit_is_clear(PINA,BUTTON))	//if front button is pressed, move the tray
		{
			while(bit_is_clear(PINA,BUTTON)); //wait for button to be released
			if(dir==2)	//if moving outwards, blink the led for a while
			{
				for(i=6;i>0;i--)
				{
					OCR0B=0xff*(i%2);
					_delay_ms(100);
				}
			}
			else _delay_ms(300);
			move(dir);
		}

		//stop tray if it is at the limits

		if(bit_is_clear(PINA,TRAY_OUT)&&dir==2)	//moving out and allready at max reach
		{
			move(0);
			dir=1;
		}

		if(bit_is_clear(PINA,TRAY_IN)&&dir==1)	//moving in and closed
		{
			_delay_ms(100);		//make sure it has reached the end
			OCR0A=0;		//stop the motor immediately fade will cause the tray to bump out
			pwm(0);			//motor pwm off for sake of silence
			dir=2;
		}

		//idle

		if(bit_is_clear(PINA,TRAY_IN))	//fade led in and out if tray is in
		{
			afk ++;
			if(afk==0x1ff)afk=0;
			if(afk<=0xff)
			{
				OCR0B=afk;	//duty cycle
			}
			else
			{
				OCR0B=0xff-afk;	//duty cycle
			}
			pwm_RED = 0;		//rgb leds off
			pwm_GREEN = 0;
			pwm_BLUE = 0;
			_delay_ms(10);		//slow the program :(
		}
		else				
		{
			afk=0;			//turn off the front led
			OCR0B=afk;
			//set_hue(ADCH);
			if(cnt>(ADC+100)/100)	//mess with the rgb leds
			{
				cnt = 0;
				set_hue(i);
				if(i<255)
					i++;
				else
					i = 0;
			}
			else
				cnt++;
		}

		if(bit_is_clear(PINA,TRAY_OUT))	
		{
		}

	}
}