Beispiel #1
0
int ScanOrKeyboardInputSymbol( char* string, int min_length, int max_length, int typ, int x, int y, int display_length, int *nCodeId )
{
	int	key;
	
	for(;;)
	{
		string[0] = '\0';
		display_input( string, x, y, display_length, max_length );
		if( ScanBarcodeSymbol( string, min_length, max_length, nCodeId ) == OK )
		{
			display_input( string, x, y, display_length, max_length );
			return( SCANNED ); // Input by scanning
		}

		key = KeyboardInput( string, min_length, max_length, typ, x, y, display_length, 3, TRIGGER_KEY, CLR_KEY, ENT_KEY );
		switch( key )
		{
			case ENT_KEY:
				return( KEYBOARD );	// Keyboard input
			case TRIGGER_KEY:
				return( KEYBOARD );	// Keyboard input  

			case CLR_KEY:
				if( strlen( string ) != 0)
				{
					break;
				} // fall through
			default:
				return( key );
		}
	}
}
Beispiel #2
0
int KeyboardInput( char* string, int min_length, int max_length, int typ, int x, int y, int display_length, int num, ... )
{
	va_list key_list;
	int key;

	if( num <= 0 )
		return( EOF );
#if (PHL|PHL1000|PHL2700)
	if( typ & INPUT_ALPHA || typ & INPUT_PRINT)
		setecho( ON );
#endif
	if( display_length > max_length )
		display_length = max_length;
	display_input(string, x, y, display_length, max_length );

	cursor( ON );
	for(;;)
	{
		va_start( key_list, num );

		if( ((key = WaitForKey()) == ENT_KEY ) && (strlen( string ) < min_length ))
			continue;

		
		// map the slash to the F4 key
		if (key == F4_KEY) { 
		  key = '/';
		}

		if( check_key_input( key, num, key_list ) == OK )
		{
			va_end( key_list );	
#if (PHL|PHL1000|PHL2700)
			if( typ & INPUT_ALPHA || typ & INPUT_PRINT)
				setecho( OFF );
#endif
		

			cursor( OFF );
			return( key );
		}
		va_end( key_list );

		if( key == BS_KEY )
		{
			remove_key_from_buffer( string );
			display_input( string, x, y, display_length, max_length );
			continue;
		}
		
		store_key_in_string( key,  string, max_length, typ );
		display_input(string, x, y, display_length, max_length );
	}
}
Beispiel #3
0
void	read_and_stock_input(char *tab, int *count_valid, int *char_nb)
{
	char	buf[2];
	char	prev_tab[17];
	int		identical;

	identical = 0;
	while (read(0, buf, 1))
	{
		tab[count_valid[0]] = buf[0];
		count_valid[0]++;
		if (count_valid[0] == 16)
		{
			tab[16] = '\0';
			prev_tab[16] = '\0';
			if (ft_strcmp(tab, prev_tab) == 0)
				tab_cmp(count_valid, char_nb, &identical);
			else
			{
				identical = 0;
				display_input(tab, count_valid, char_nb);
			}
			ft_strcpy(tab, prev_tab);
			count_valid[0] = 0;
		}
	}
}
Beispiel #4
0
int main(int argc, char* argv[])
{
  initscr();                          // initialize ncurses display
  nodelay(stdscr, 1);                 // don't wait for key presses
  noecho();                           // don't echo key presses
  gz_spi_set_width(3);                // Pass blocks of 3 bytes on SPI
  erase();
  printw("Toggling all outputs.\n");
  printw("Press 'n' for next test, any other key to stop.\n");
  int key = 0;
  while(1) {
    exercise_outputs(0xffffff, 0x000000);
    key = getch();
    if (key != -1) {
      break;
    }
  }
  if (key == 'n') {
    erase();
    printw("Toggling alternate outputs.\n");
    printw("Press 'n' for next test, any other key to stop.\n");
    while(1) {
      exercise_outputs(0xaaaaaa, 0x555555);
      key = getch();
      if (key != -1) {
        break;
      }
    }
  }
  if (key == 'n') {
    erase();
    printw("Walking outputs.\n");
    printw("Press 'n' for next test, any other key to stop.\n");
    uint32_t current = 0xfffffe;
    while(1) {
      exercise_outputs(current, (current << 1) | 0x01);
      current = (current << 2) | 0x03;
      if ((current & 0xffffff) == 0xffffff) {
        current = 0xfffffe;
      }
      key = getch();
      if (key != -1) {
        break;
      }
    }
  }
  if (key == 'n') {
    erase();
    curs_set(0);                      // Hide the cursor
    // Set RPI pin P1-07 to be an input
    INP_GPIO(PIN);
    //  with a pullup -- see BCM2835 ARM Peripherals page 101
    GPIO_PULL = 2;
    usleep(1);
    GPIO_PULLCLK0 = 1 << PIN;
    usleep(1);
    GPIO_PULL = 0;
    GPIO_PULLCLK0 = 0;
    printw("Reading input.\n");
    printw("Press any key to stop.\n");
    while(1) {
      display_input();
      key = getch();
      if (key != -1) {
        break;
      }
    }
    move(getcury(stdscr) + 1 ,0);
    curs_set(1);
    refresh();
  }
  gz_spi_close();                     // close SPI channel
  erase();
  reset_shell_mode();                 // turn off ncurses
  return 0;
}