Пример #1
0
/* blink leds */
void
biblink(void)
{
	int i, times;
	short h;

	if ((input_line[7] == ' ') && (isdigit(input_line[8])))
		times = 10 * (input_line[8] - '0');
	else
		times = 1;
	
	for (i = 1; i <= times; i++)
	{
		for (h = 1; h <= 8; h++)
		{
			led_on(h);
			led_off(++h);
		}
		
		usleep((int)(set_time / 2));

		for (h = 1; h <= 8; h++)
		{
			led_off(h);
			led_on(++h);
		}

		usleep((int)(set_time / 2));
	}

	led_off_all();
}
Пример #2
0
int main()
{
	init_led();
	init_beep();
	init_key();

	led_off_all();
	int i;

	while(1)
	{
		if(i= key_press()){
			led_on(i);
			beep_on();
		}else{
			led_off_all();
			beep_off();
		}
	}
	 return 0;
}
Пример #3
0
/* turns off all leds or, if a parameter is given, that led */
void
ledoff(void)
{
        short led_num = -1;
        if ((input_line[6] == ' ') && (isdigit(input_line[7])))
                led_num = input_line[7] - '0';

        if (led_num == -1)
                led_off_all();
        else if ((led_num >= 1) && (led_num <= 8))
                led_off(led_num);
}
Пример #4
0
/* center and side combination */
void
biside(void)
{
	int i, times;
	short h;
	
	if ((input_line[6] == ' ') && (isdigit(input_line[7])))
		times = 10 * (input_line[7] - '0');
	else
		times = 1;
	
	for (i = 1; i <= times; i++)
	{
		for (h = 5; h <= 8; h++)
		{
			/* ok, redundant... forgive me... */
			if ((h >= 5) && (h <= 8))
			{
				led_on(h);
				led_on(9 - h);
			}
			if (h != 5)
			{
				led_off(h - 1);
				led_off(10 - h);
			}
			if (h != 8)
				usleep((int)(set_time / 8));
		}


		for (h = 1; h <= 4; h++)
		{
			/* ok, redundant... forgive me... */
			if ((h >= 1) && (h <= 4))
			{
				led_on(h);
				led_on(9 - h);
			}
			if (h != 1)
			{
				led_off(h - 1);
				led_off(10 - h);
			}
			if (h != 4)
				usleep((int)(set_time / 8));
		}
		
	}

	usleep((int)(set_time / 8));
	led_off_all();
}
Пример #5
0
/* main loop */
int
main(void)
{
	input_line = (char *)malloc(6 * sizeof(char));

	led_setperm();

	set_time = 200000;

	while (strncmp(input_line, "quit", 4) != 0)
	{
		input_line = readline("Led Control> ");

		/* I know instruction parsing is really lame :/ */
		if (!strncmp(input_line, "help", 4))
			help();
		if (!strncmp(input_line, "ledon", 5))
			ledon();
		if (!strncmp(input_line, "ledoff", 6))
			ledoff();
		if (!strncmp(input_line, "settime", 7))
			settime();
		if (!strncmp(input_line, "volume", 6))
			volume();
		if (!strncmp(input_line, "bin", 3))
			bin();
		if (!strncmp(input_line, "slide", 5))
			slide();
		if (!strncmp(input_line, "blink", 5))
			blink();
		if (!strncmp(input_line, "bislide", 7))
			bislide();
		if (!strncmp(input_line, "biblink", 7))
			biblink();
		if (!strncmp(input_line, "grow", 4))
			grow();
		if (!strncmp(input_line, "center", 6))
			center();
		if (!strncmp(input_line, "side", 4))
			side();
		if (!strncmp(input_line, "biside", 6))
			biside();
		if (!strncmp(input_line, "demo", 4))
			demo();
	}

	led_off_all();

	exit(0);
}
Пример #6
0
/* sets blinking and sliding time */
void
settime(void)
{
	short set = -1;
	if ((input_line[7] == ' ') && (isdigit(input_line[8])))
		set = input_line[8] - '0';

	if (set != -1)
		set_time = set * 100000;

	if (set_time == 0)
		set_time = 1000000;

	led_off_all();
}
Пример #7
0
void long_press(int key_num,int num){
    if((rEXTINT1 &(7<<num))==0){
        if(key_num == 5 || key_num == 6){
            led_on_all();
        }else{
            led_on(key_num);
        }
        beep_on();
        rEXTINT1 &= ~(7<<num);
        rEXTINT1 |= 0x4;
    } else if((rEXTINT1 &(7<<num)) == 0x4){
        led_off_all();
        beep_off();
        rEXTINT1 &= ~(7<<num);
    }
}
Пример #8
0
int main()
{
	init_led();
    init_beep();
    //init_key();  轮循初始化
    //init_interrupt_for_key();   //中断的方式

    led_off_all();
    if(flag){
        led_on_all();
        beep_on();
    }
	int i;
	while(1){
	}
	return 0;
}
Пример #9
0
int main()
{
	init_led();

	led_off_all();
	
	int i=1;
	while (1) {
		for(i=1; i<5; i++) {
			led_on(i);
			delay(0xfff);
			led_off(i);
			delay(0xfff);
		}	
	}
	return 0;
}
Пример #10
0
void long_press(int key_num,int num){
    if((rEXTINT1 &(num))==0){
        //低电平触发了中断
        if(key_num == 5 || key_num == 6){
            led_on_all();
        }else{
            led_on(key_num);
        }
        beep_on();
        //改变中断的触发方式为上升沿
        rEXTINT1 &= ~(num);
        rEXTINT1 |= 0x4;
    } else if((rEXTINT1 &(num)) == 0x4){
        //上升沿触发中断
        led_off_all();
        beep_off();
        rEXTINT1 &= ~(num);
    }
}
Пример #11
0
/* like slide, but heavier ;) */
void
grow(void)
{
	int i, times;
	short h;
	
	if ((input_line[4] == ' ') && (isdigit(input_line[5])))
		times = 10 * (input_line[5] - '0');
	else
		times = 1;
	for (i = 1; i <= times; i++)
	{
		for (h = 1; h <= 8; h++)
		{
			led_on(h);
			usleep((int)(set_time / 9));
		}
		led_off_all();
		usleep((int)(set_time / 9));
	}
}