Esempio n. 1
0
/*************************************************************************************
nodef()
*************************************************************************************/
void nodef(void)
{
    putccLCD(1);
    printf("Submenu nedefiniran!");
    while(key_getch());     // Izprazni buffer tipk.
    getchar();
}
Esempio n. 2
0
void debug_help()
{
	int s, i;

	dc_printf( "Available functions:\n\n" );

	s = scroll_times;
	for (i=0; i<Num_debug_commands; i++ ) {
		dc_printf( " %s - %s\n", Debug_command[i]->name, Debug_command[i]->help );

		if ( scroll_times - s > DROWS - 3 ) {
			int k;
			dc_printf( "       Press a key...B for back\n" );
			debug_draw();
			k = key_getch();
			s = scroll_times;
			if ( k == KEY_B ) {
				i -= ((DROWS-3)*2);
				if ( i <= 0 ) {
					i = -1;
				}
			}
		}
		debug_draw();
	}
	dc_printf( "\n" );

	dc_printf( "Typing '? function_name' will give the current status.\n" );
	dc_printf( "Typing 'function_name ?' will give help on the function.\n" );
	dc_printf( "Typing ? or help will give you help.\n");
	dc_printf( "F3 selects last command line.\n" );
}
Esempio n. 3
0
/*************************************************************************************
pressAnyKey()
*************************************************************************************/
void pressAnyKey(void)
{
    gotoxyLCD(1,4);
    printf("Press any key ...   ");
    while(key_getch());     // Izprazni buffer tipk.
    getchar();
}
Esempio n. 4
0
/*************************************************************************************
menu_pwm()
*************************************************************************************/
int menu_pwm(int c)
{
	IN0 = 0;	// definiramo smer
	IN1 = 1;
	CR = 1;		// vkljucimo PCA
	do
	{
		putccLCD(1);     // brisanje ekrana
        printf("Menu pwm:");
        gotoxyLCD(1,2);
        putsLCD("CCAP0H:");
        gotoxyLCD(1,3);
        printf("%s", itoa(CCAP0H, s));
        gotoxyLCD(1,4);
        putsLCD(" +1   -1  SET  SMER");
        do
        {
			c = (unsigned char)key_getch();
        } while(c == 0);
        switch(c)
        {
            case F1:
				if(CCAP0H < 255)
				CCAP0H++;
        		gotoxyLCD(1,3);
				printf("%s", itoa(CCAP0H, s));
				break;
            case F2:
				if(CCAP0H > 0)
				CCAP0H--;
        		gotoxyLCD(1,3);
				printf("%s", itoa(CCAP0H, s));
				break;
            case F3:
				gotoxyLCD(1,3);
				printf("Nova vrednost: ");
				gets(s);
				CCAP0H = atoi(s);
				gotoxyLCD(1,3);
				printf("%s", itoa(CCAP0H, s));
				break;
            case F4:
				IN0 = !IN0;
				IN1 = !IN1;
				break;
            case 27:            // Escape
				c = 0;
				break;
        }
    } while(c != 0);
    CR = 0;		// izkljucimo PCA
    return c;
}
Esempio n. 5
0
/*************************************************************************************
menu_glavni()
*************************************************************************************/
int menu_glavni(int c)
{
	refresh = 1;
    do
    {
        putccLCD(1);     // brisanje ekrana
        printf("Glavni menu");
        gotoxyLCD(1,3);
        putsLCD(" F1   F2   F3   F4");
        gotoxyLCD(1,4);
        putsLCD("LABV PWM  SEL3 TIME");
        do
        {
            c = (unsigned char)key_getch();
         	if (refresh == 1)
         	{
         	     gotoxyLCD(16,1);
                 SecToHms(value,s);
                 s[5] = 0;
                 putsLCD(s);
         	     refresh = 0;
                 led_y = !led_y;
            }
        } while(c == 0);
        switch(c)
        {
            case 0:
                 break;
            case F1:
                 menu_pwm_labvaja(0);
                 break;
            case F2:
                 menu_pwm(0);
                 break;
            case F3:
                 nodef();
                 break;
            case F4:
                 menu_time(0);
                 break;
            case 27:            // Escape
                 c = 0;
                 break;
        }
    } while(c != 0);
    return c;
}
Esempio n. 6
0
/*************************************************************************************
menu_sub()				Sample menu
						c - default selection
						Return value: last submenu selection
*************************************************************************************/
int menu_sub(int c)
{
    do
    {
        putccLCD(1);     // brisanje ekrana
        printf("Menu sub:");
        gotoxyLCD(1,2);
        putsLCD("Select Submenu with");
        gotoxyLCD(1,3);
        putsLCD(" F1   F2   F3   F4");
        gotoxyLCD(1,4);
        putsLCD("SEL1 SEL2 SEL3 SEL4");
        do
        {
            c = (unsigned char)key_getch();
        } while(c == 0);
        switch(c)
        {
            case F1:
				nodef();
				break;
            case F2:
				nodef();
				break;
            case F3:
				nodef();
				break;
            case F4:
				nodef();
				break;
            case 27:            // Escape
				c = 0;
				break;
        }
    } while(c != 0);
    return c;
}
Esempio n. 7
0
File: testj.c Progetto: btb/d2x
void main (void)
{
	unsigned int t1, t2;
	int i, start, stop, frames;
	short bd1, bd2, bu1, bu2, b, x, y, bt1, bt2;

	key_init();

	if (!joy_init())   {
		printf( "No joystick detected.\n" );
		key_close();
		exit(1);
	}

	timer_init( 0, NULL );

	printf( "Displaying joystick button transitions and time...any key leaves.\n" );

	i = 0;
	while( !key_inkey() )
	{
		i++;
		if (i>500000)    {
			i = 0;
			joy_get_btn_down_cnt( &bd1, &bd2 );
			joy_get_btn_up_cnt( &bu1, &bu2 );
			joy_get_btn_time( &bt1, &bt2 );
			printf( "%d  %d   %d   %d      T1:%d   T2:%d\n",bd1, bu1, bd2, bu2, bt1, bt2 );
		}
	}

	printf( "\nPress c to do a deluxe-full-fledged calibration.\n" );
	printf( "or any other key to just use the cheap method.\n" );

	if (key_getch() == 'c')    {
		printf( "Move stick to center and press any key.\n" );
		wait();
		joy_set_cen();

		printf( "Move stick to Upper Left corner and press any key.\n" );
		wait();
		joy_set_ul();

		printf( "Move stick to Lower Right corner and press any key.\n" );
		wait();
		joy_set_lr();
	}


	while( !keyd_pressed[KEY_ESC])
	{
		frames++;

		joy_get_pos( &x, &y );
		b = joy_get_btns();

		printf( "%d, %d   (%d %d)\n", x, y, b & 1, b & 2);

	}


	printf( "Testing joystick reading speed...\n" );
	t1 = timer_get_microseconds();
	joy_get_pos( &x, &y );
	t2 = timer_get_microseconds();

	printf( "~ %u æsec per reading using Timer Timing\n", t2 - t1 );

	joy_close();
	key_close();
	timer_close();

	frames = 1000;
	start = TICKER;
	for (i=0; i<frames; i++ )
		joy_get_pos( &x, &y );

	stop = TICKER;

	printf( "~ %d æsec per reading using BIOS ticker as a stopwatch.\n", USECS_PER_READING( start, stop, frames ) );


}
Esempio n. 8
0
void main (void)
{
	char ascii;
	int c;

	setbuf( stdout, NULL );

	key_init();
	//timer_init( 0, NULL );
	//keyd_buffer_type = 2;
	keyd_repeat = 0;

	printf( "\n\n\n\nThis tests the keyboard library.\n\n" );
	printf( "Press any key to start...\n" );
	printf( "You pressed: %c\n\n", key_getch() );
	printf( "Press F1 to turn off buffering.\n" );
	printf( "      F2 to turn on buffering.\n" );
	printf( "      F4 to flush keyboard.\n" );
	printf( "      F5 to turn repeat off.\n");
	printf( "      F6 to turn repeat on.\n");
	printf( "      F7 to do an INT 3.\n" );
	printf( "      F10 to display some boxes.\n" );
	printf( "      The arrows to see fast multiple keystrokes.\n");
	printf( "      ESC to exit.\n\n" );


	while( !keyd_pressed[KEY_ESC]  ) {
		int i,j;

		for (i=0; i<256; i++ )	{
			if (keyd_pressed[i])		{
				j = key_to_ascii(i);
				if (j==255)
					vidmem[i*2] = 219;
				else
					vidmem[i*2] = j;
			} else 
				vidmem[i*2] = 32;
		}

		if (keyd_pressed[KEY_F1])
			keyd_buffer_type = 0;

		if (keyd_pressed[KEY_F2])
			keyd_buffer_type = 1;

		if (keyd_pressed[KEY_F4])
			key_flush();

		if (keyd_pressed[KEY_F5])	{
			keyd_repeat = 0;
			printf( "Repeat off" );
		}

		if (keyd_pressed[KEY_F6])	{
			keyd_repeat = 1;
			printf( "Repeat on" );
		}

//		if (keyd_pressed[KEY_F7] )
//			key_debug();

		if (keyd_pressed[KEY_PAUSE])
			putch( 254 );

		if (key_checkch())   {
			c = key_getch();

			ascii=key_to_ascii(c);
			if ( ascii==255 )
			{
				printf("[%4X] ", c );
				fflush( stdout );
			}
			else
				putch( ascii );

			if (c==1) break;
		}

		delay(100);

	}

	key_close();
	//timer_close();
}
Esempio n. 9
0
void iglasses_init_tracking(int serial_port)	
{
	fix t1,t2;
	int c;

	if (iglasses_headset_installed) return;

	if ( (serial_port < 1) || (serial_port > 4) )	{
		Error( TXT_IGLASSES_ERROR_1 );
	}
	printf( "\n\n");
	printf( TXT_IGLASSES_INIT, serial_port );
	printf( "\n%s\n", TXT_IGLASSES_ON);
	printf( "Looking for glasses - %s", TXT_PRESS_ESC_TO_ABORT);
	Iport = PortOpenGreenleafFast(serial_port-1, 9600, 'N', 8, 1 );
	if ( !Iport )	{
		printf( "%s\n", TXT_SERIAL_FAILURE, Iport->status );
		return;
	}
	
	SetDtr( Iport, 1 );
	SetRts( Iport, 1 );
	UseRtsCts( Iport, 0 );
	
	t2 = timer_get_fixed_seconds() + i2f(20);

	while(timer_get_fixed_seconds() < t2)	{
		printf( "." );
		t1 = timer_get_fixed_seconds() + F1_0;
		ClearRXBuffer(Iport);
		ClearTXBuffer(Iport);
		WriteBuffer( Iport, "!\r", 2 );
		while ( timer_get_fixed_seconds() < t1 )	{
			if ( key_inkey() == KEY_ESC ) goto NotOK;
			c = ReadChar( Iport );
			if ( c == 'O' )	{
				goto TrackerOK1;
			} 	
		}
	}

NotOK:;
	printf(	"\n\nWarning: Cannot find i-glasses! on port %d\n"
				" Press Esc to abort D2, any other key to continue without i-glasses support.\n"
				" Use SETUP to disable i-glasses support.\n",serial_port);
	if ( key_getch() == KEY_ESC )
		exit(1);
	else
		return;

TrackerOK1:

	while( 1 )	{
		printf( "." );
		t1 = timer_get_fixed_seconds() + F1_0;
		ClearRXBuffer(Iport);
		ClearTXBuffer(Iport);
		// M2 = p,b,h
		// M1 = all data
		WriteBuffer( Iport, "!M1,P,B\r", 8 );
		while ( timer_get_fixed_seconds() < t1 )	{
			if ( key_inkey() == KEY_ESC ) return;
			c = ReadChar( Iport );
			if ( c == 'O' )	{
				goto TrackerOK2;
			} 	
		}
	}

TrackerOK2:

	printf( ".\n" );
	ClearRXBuffer(Iport);
	ClearTXBuffer(Iport);

 	WriteChar( Iport, 'S' );

	iglasses_headset_installed = 1;
	atexit( iglasses_close_tracking );

#ifdef USE_FILTERS 
	initFIR( &X_filter );
	initFIR( &Y_filter );
	initFIR( &Z_filter );
#endif

//	{
//		fix y,p,r;
//		while( 1 )	{
//			iglasses_read_headset( &y, &p, &r);
//		 	//printf( "%d\t%d\t%d\n", y, p, r );
//		 	printf( "%8.2f\n", f2fl(y) );
//			if (key_inkey()==KEY_ESC) break;
//		}
//	}

}
Esempio n. 10
0
/*************************************************************************************
menu_time
*************************************************************************************/
int menu_time(int c)
{
    char *pt;
    char *pt1;
    uint nv;

    do
    {
        putccLCD(1);     // brisanje ekrana
        printf("Time");
        gotoxyLCD(11,2);
        putsLCD(SecToHms(value,s));
        gotoxyLCD(1,4);
        putsLCD("Comp.  -1s  +1s  SET");
        do
        {
            c = (unsigned char)key_getch();
         	if (refresh == 1)
         	{
         	     gotoxyLCD(11,2);
                 putsLCD(SecToHms(value,s));
         	     refresh = 0;
                 led_y = !led_y;
            }
        } while(c == 0);
        switch(c)
        {
            case F1:
                 gotoxyLCD(1,2);
                 printf("   1s comp = %d  ", comp);
                 gotoxyLCD(1,3);
                 putsLCD("New comp: ");
                 gets(s);
                 if (strlen(s) > 3)
                 {
                    comp = atoi(s);
                 }
                 break;
            case F2:
                 --value;
                 break;
            case F3:
                 ++value;
                 break;
            case F4:
                 gotoxyLCD(11,2);
                 putsLCD("hh.mm.ss ");
                 gotoxyLCD(1,3);
                 putsLCD("New time: ");
                 gets(s);
                 if (strlen(s) > 4)
                 {
                    pt = strchr(s, '.');   //  10.49.27
                    if (pt) *pt = 0;         //    pt
                    nv = atoi(s) * 3600;
                    pt1 = strchr(pt+1, '.'); //       pt1
                    if (pt1) *pt1 = 0;
                    nv += atoi(pt+1) * 60;
                    nv += atoi(pt1+1);
                    if (nv > 43200)
                        nv -= 43200;
                    value = nv;
                 }
                 break;
            case 27:            // Escape
                 c = 0;
                 break;
        }
    } while(c != 0);
    return c;
}
Esempio n. 11
0
/*************************************************************************************
menu_pwm_labvaja()
*************************************************************************************/
int menu_pwm_labvaja(int c)
{   uint frekvenca;
	IN0 = 1;	// definiramo smer
	IN1 = 0;
	CR = 1;  // vkljucimo PCA
	TRIGGER = 0;
    putccLCD(1);     // brisanje ekrana
	
	do
	{
		putccLCD(1);     // brisanje ekrana
        printf("Menu pwm_labvaja:");
        gotoxyLCD(1,2);
        putsLCD("CCAP0H:");
        gotoxyLCD(12,2);
        printf("%s", itoa(CCAP0H, s));
		gotoxyLCD(1,3);
        printf("Frekvenca:");
        gotoxyLCD(1,4);
        putsLCD(" -10   -20  SET  TG0");
        do
        {
			c = (unsigned char)key_getch();
             if(refresh == 1)
			{
				refresh = 0;
				frekvenca = pulz*10000/cas;
				pulz = 0;
				cas = 0;
				gotoxyLCD(12,3);
				printf("%s", itoa(frekvenca, s));
			}
        } while(c == 0);
        switch(c)
        {
            case F1:
				if(CCAP0H > 9)
				{
					TRIGGER = 1;
				    CCAP0H = CCAP0H - 10;
				}
				gotoxyLCD(1,3);
				printf("%s", itoa(CCAP0H, s));
				break;
            case F2:
				if(CCAP0H > 19)
				{   TRIGGER = 1;
					CCAP0H = CCAP0H - 20;
				}
				gotoxyLCD(1,3);
				printf("%s", itoa(CCAP0H, s));
				break;
            case F3:
				gotoxyLCD(1,3);
				printf("Nova vrednost: ");
				gets(s);
				TRIGGER = 1;
				CCAP0H = atoi(s);
				gotoxyLCD(1,3);
				printf("%s", itoa(CCAP0H, s));
				break;
            case F4:
			if(CCAP0H < 255)
				TRIGGER = 0;
        		gotoxyLCD(1,3);
				printf("%s", itoa(CCAP0H, s));
				break;
            case 27:            // Escape
				c = 0;
				break;
        }
    } while(c != 0);
    CR = 0;		// izkljucimo PCA
    return c;
}