Ejemplo n.º 1
0
void update_leds()
{
   auto char *ptr[4];
   auto int i;

   ptr[0] = led_LED0;
   ptr[1] = led_LED1;
   ptr[2] = led_LED2;
   ptr[3] = led_LED3;
 
   for(i=0; i< (sizeof(ptr)/2); i++)
   {
		TextGotoXY(&wholewindow,0,i);
      if (strcmp(ptr[i],"ledon.gif") == 0)
      {
      	ledOut(i, 1);
			TextPrintf(&wholewindow, "LED %d on ", i);
      }
      else
      {
      	ledOut(i, 0);
			TextPrintf(&wholewindow, "LED %d off", i);
      }
   }
}
Ejemplo n.º 2
0
void TodTextPrint(Text *text, Tod tod)
{
  long	hour, min, sec;
  if (tod == TODNA) TextPrintf(text, "na");
  else {
    hour = tod / 3600;
    min = (tod - 3600*hour)/60;
    sec = tod % 60;
    TextPrintf(text, "%.2ld%.2ld%.2ld", hour, min, sec);
  }
}
Ejemplo n.º 3
0
//------------------------------------------------------------------------
// Date and Time prompt message routine
//------------------------------------------------------------------------
void date_prompt(char *ptr, int *col, int *row)
{

	glBlankScreen();
	TextGotoXY(&textWindow, 0, 0);
	TextPrintf(&textWindow, "%s", ptr);
	TextCursorLocation(&textWindow, col, row);

	TextGotoXY(&textWindow, 0, 3);
	TextPrintf(&textWindow, "ENTER to Continue...");
}
Ejemplo n.º 4
0
void TsTextPrint(Text *text, Ts *ts)
{
  struct tm *tms;
  if (ts == NULL) { TextPrintf(text, "NULL"); return; }
  if (ts->flag & TSFLAG_APPROX) TextPrintf(text, "~");
  if (ts->flag & TSFLAG_TOD) {
    TodTextPrint(text, (Tod)ts->unixts);
    TextPrintf(text, "tod");
  } else if (ts->flag & TSFLAG_DUR) {
    DurTextPrint(text, (Dur)ts->unixts);
  } else if (ts->unixts == UNIXTSNA) {
    TextPrintf(text, "na");
  } else if (ts->unixts == UNIXTSNEGINF) {
    TextPrintf(text, "-Inf");
  } else if (ts->unixts == UNIXTSPOSINF) {
    TextPrintf(text, "Inf");
  } else {
    if (NULL == (tms = localtime(&ts->unixts))) {
      TextPrintf(text, "ERROR");
    } else {
      TextPrintf(text, "%.4d%.2d%.2dT%.2d%.2d%.2d", 1900+tms->tm_year,
                 tms->tm_mon+1, tms->tm_mday, tms->tm_hour, tms->tm_min,
                 tms->tm_sec);
    }
  }
}
Ejemplo n.º 5
0
/*
 * Display the current window within the display buffer
 */
void DispUpdateWindow(void)
{
	int i;
	char line[DISP_COLS + 1];

	glBlankScreen();
	for (i = 0; i < DISP_ROWS; i++) {
		if ((emailDispLine + i) < emailLastLine) {
			TextGotoXY(&wholewindow, 0, i);
			xmem2root(line, dispBuffer + ((DISP_COLS+1) * (emailDispLine+i)), DISP_COLS+1);
			TextPrintf(&wholewindow, "%s", line);
		} else {
			TextGotoXY(&wholewindow, 0, i);
			TextPrintf(&wholewindow, "");
		}
	}
}
Ejemplo n.º 6
0
//***************************************************************************
//	Clear a single text line on the LCD display.
//***************************************************************************
void clrline(int line, int len)
{
	char spaces[256];
	int i;

	for(i=0; i < len; i++)
	{
		spaces[i] = ' ';
	}
	spaces[i] = '\0';
	TextGotoXY(&textWindow1, 0, line);
	TextPrintf(&textWindow1, "%s", spaces);
}
Ejemplo n.º 7
0
/*
 * Receive a message.  The connected socket and is sent back, and the need
 * for a response is indicated.
 */
void RecvMessage(tcp_Socket* tcpSock)
{
    auto char buffer[500];
    auto int numBytes;

    tcp_listen(tcpSock, PORT, 0, 0, NULL, 0);

    /* Wait for connection. */
    while( ! tcp_established( tcpSock ) )
    {
        if( ! tcp_tick( (sock_type *) tcpSock ) )
        {
            TextGotoXY(&wholewindow, 0, 0 );
            TextPrintf(&wholewindow, "Error: listen");
            return;
        }
    }

    /*  Wait for some data to appear, or an error... */
    while((numBytes = sock_fastread(tcpSock, buffer, sizeof(buffer))) == 0 )
    {
        if( ! tcp_tick( tcpSock ) || numBytes == -1 )
        {
            TextGotoXY(&wholewindow, 0, 0 );
            TextPrintf(&wholewindow, "Error: read");
            return;
        }
    }
    // Display received from other controller
    glBlankScreen();
    TextGotoXY(&wholewindow, 0, 0 );
    TextPrintf(&wholewindow, "Message received:");
    buffer[numBytes] = '\0';
    TextGotoXY(&wholewindow, 0, 1 );
    TextPrintf(&wholewindow, "%s", buffer);

}   /* end RecvMessage() */
Ejemplo n.º 8
0
//------------------------------------------------------------------------
// Display the Date and Time on the LCD display
//------------------------------------------------------------------------
int dispDate( void )
{
	static int status;
	auto int wKey;

	costate
	{
		// Get current Date/Time
		status = 0;
		ulTime = read_rtc ();			// get the RTC value
		mktm( &CurTime, ulTime );		// convert seconds to date values
		FormatDateTime();					// convert to text
		waitfor(DelayMs(5));

		// Display Date and Time
		glBuffLock();
		TextGotoXY(&textWindow, 0, 0);
		TextPrintf(&textWindow, "%s\n", szTime);
		waitfor(DelayMs(5));

		// Display user exit message
		TextGotoXY(&textWindow, 0, 3);
		TextPrintf(&textWindow, "Press Key to EXIT");
		waitfor(DelayMs(5));
		glBuffUnlock();

		// Wait for key to be pressed to exit
		waitfor(((wKey = keyGet()) != 0) || DelayMs(100));
		if(wKey != 0)
		{
			glBlankScreen();
			status = 1;
		}
	}
	return(status);
}
Ejemplo n.º 9
0
/* <sort_by>: -2 - do not sort
 *            -1 - sort by all fields, right to left
 *             0 - field 0
 *             1 - field 1
 *             ...
 * <sort_sign>: 1 - sort forward
 *             -1 - sort backward
 *
 */
void RptTextPrint(Text *text, Rpt *r, int show_header, int sort_by,
                  int sort_sign, int maxfieldlen)
{
    int		cnt;
    RptLine	*rl;
    cnt = 0;
    if (r->lines) {
        TextNextParagraph(text);
        if (sort_by != -2) RptSort(r, sort_by, sort_sign);
        if (show_header) {
            RptTextPrintLine(text, r, r->lines, maxfieldlen, 0);
            RptTextPrintLine(text, r, r->lines, maxfieldlen, 1);
        }
        for (rl = r->lines->next; rl; rl = rl->next) {
            cnt++;
            RptTextPrintLine(text, r, rl, maxfieldlen, 0);
        }
    }
    if (cnt > 49) TextPrintf(text, "%d entries\n", cnt);
}
Ejemplo n.º 10
0
void initLcdKeypad()
{
	// Start-up the keypad driver and
	// Initialize the graphic driver
	dispInit();

	// Use default key values along with a key release code
	keyConfig (  0,'1', 0, 0, 0,  0, 0 );
	keyConfig (  1,'2', 0, 0, 0,  0, 0 );
	keyConfig (  2,'3', 0, 0, 0,  0, 0 );
	keyConfig (  3,'4', 0, 0, 0,  0, 0 );
	keyConfig (  4,'-', 0, 0, 0,  0, 0 );
	keyConfig (  5,'+', 0, 0, 0,  0, 0 );
	keyConfig (  6,'0', 0, 0, 0,  0, 0 );

	// Initialize 6x8 font
	glXFontInit(&fi6x8, 6, 8, 32, 127, Font6x8);          // Initialize 6x8 font
	TextWindowFrame(&wholewindow, &fi6x8, 0, 0, LCD_XS, LCD_YS);
	glBlankScreen();
	TextGotoXY(&wholewindow, 0, 0);
	TextPrintf(&wholewindow, "Password");
}
Ejemplo n.º 11
0
void DurTextPrint(Text *text, Dur dur)
{
  if (dur == DURNA) TextPrintf(text, "na");
  else TextPrintf(text, "%ldsec", dur);
}
Ejemplo n.º 12
0
void main(void)
{
	auto int wKey;
   char buffer[20];

	auto int i,j;

	brdInit();
   initLcdKeypad();

	// Initialize the #web-registered variables
   strcpy(passwords[0].entrypw, "12340");
   strcpy(passwords[0].entryname, "JGunchy");
   strcpy(passwords[0].entrytime, "no activity");
   strcpy(passwords[0].exittime, "no activity");

   for (i=1; i<MAX_ENTRIES; i++)
   {
		strcpy(passwords[i].entrypw, "Unused");
		strcpy(passwords[i].entryname, "Unused");
	   strcpy(passwords[i].entrytime, "no activity");
   	strcpy(passwords[i].exittime, "no activity");
   }

   updateentry();
   //initialize temporary variables
   j= 10;
	i = 0;

	// Initialize the TCP/IP stack, HTTP server
   sock_init();
   http_init();

   while (1)
   {
		// Drive the HTTP server
      http_handler();

  		costate
		{
			keyProcess();
			wKey = keyGet();
		}

      costate
      {
         switch (wKey)
         {
         	case 0:	break;
            case '+':	//entry
            case '-':	//exit
            		buffer[i]='\0';
		  			  	TextGotoXY(&wholewindow, 0, 1);
         		  	if (confirmentry(buffer, wKey))
            		{
							TextPrintf(&wholewindow, "Accepted");
			  			  	TextGotoXY(&wholewindow, 0, 3);
							TextPrintf(&wholewindow, "Thank you %s", buffer);
            		}
            		else
            		{
							TextPrintf(&wholewindow, "Incorrect password");
            		}
            		i=0;
			        	j=10;
                  waitfor(DelaySec(3));
						glBlankScreen();
				  		TextGotoXY(&wholewindow, 0, 0);
						TextPrintf(&wholewindow, "Password");
                  break;
            default:
            		if (i<7)
                  {
				      	buffer[i] = wKey;
					  		TextGotoXY(&wholewindow, j, 0);
							//TextPrintf(&wholewindow, "%c", wKey);
							TextPrintf(&wholewindow, "%c", '*');
         	   		j++;
            			i++;
                  }
                  break;
         }//end switch
      }//end costate switch

   }
}
Ejemplo n.º 13
0
//------------------------------------------------------------------------
// Set Date and Time
//------------------------------------------------------------------------
void SetDateTime( void )
{
	int wKey;
	int col, row;
	char buffer[256];
	fieldupdate dateTime;

	// Setup for FAST key repeat after holding down key for 12 ticks
	keyConfig (  6,'E',0, 12, 1,  1, 1 );
	keyConfig (  2,'D',0, 12, 1,  1, 1 );
	keyConfig (  5,'+',0, 12, 1,  1, 1 );
	keyConfig (  1,'U',0, 12, 1,  1, 1 );
	keyConfig (  4,'-',0, 12, 1,  1, 1 );

	date_prompt("Select \n4 digit year: ", &col, &row);
	dateTime.data = 2001;
	while(1)
	{
		sprintf(buffer, "%04d", dateTime.data);
		TextGotoXY(&textWindow, col, row);
		TextPrintf(&textWindow, "%s", buffer);
		while((wKey = ProcessKeyField(NUMBER, &dateTime)) == 0);
		if(dateTime.data < 1900 || dateTime.data > 2047)
		{
			dateTime.data = 2001;
		}
		if(wKey == 'E')
		{
			if( dateTime.data  >= 1900 && dateTime.data < 2048) {
				CurTime.tm_year = dateTime.data - 1900;	// offset from 1900
				break;
			}
		}
	}

	date_prompt("Enter month: ", &col, &row);
	dateTime.data = 1;
	while(1)
	{
		sprintf(buffer, "%02d", dateTime.data);
		TextGotoXY(&textWindow, col, row);
		TextPrintf(&textWindow, "%s", buffer);
		while((wKey = ProcessKeyField(NUMBER, &dateTime)) == 0);
		if(wKey == 'E')
		{
			if( dateTime.data >= 1 && dateTime.data < 13 )
			{
				CurTime.tm_mon = month2tm_mon(dateTime.data);
				break;
			}
		}
		if(dateTime.data < 1 || dateTime.data > 12)
		{
			dateTime.data  = (dateTime.data < 1) ? 12 : 1;
		}
	}

	date_prompt("Enter \nday of month: ", &col, &row);
	dateTime.data = 1;
	while(1)
	{
		sprintf(buffer, "%02d", dateTime.data);
		TextGotoXY(&textWindow, col, row);
		TextPrintf(&textWindow, "%s", buffer);
		while((wKey = ProcessKeyField(NUMBER, &dateTime))== 0);
		if(wKey == 'E')
		{
			if( dateTime.data  >= 1 && dateTime.data < 32) {
				CurTime.tm_mday = dateTime.data;
				break;
			}
		}
		if(dateTime.data < 1 || dateTime.data > 31)
		{
			dateTime.data  = (dateTime.data < 1) ? 31 : 1;
		}
	}


	date_prompt("Enter \nhour (24hr): ", &col, &row);
	dateTime.data = 0;
	while(1)
	{
		sprintf(buffer, "%02d", dateTime.data);
		TextGotoXY(&textWindow, col, row);
		TextPrintf(&textWindow, "%s", buffer);
		while((wKey = ProcessKeyField(NUMBER, &dateTime)) == 0);
		if(wKey == 'E')
		{
			if(dateTime.data >= 0 && dateTime.data < 24) {
				CurTime.tm_hour = dateTime.data;
				break;
			}
		}
		if(dateTime.data < 0 || dateTime.data > 23)
		{
			dateTime.data  = (dateTime.data < 0) ? 23 : 0;
		}
	}

	date_prompt("Enter minute: ", &col, &row);
	dateTime.data = 0;
	while(1)
	{
		sprintf(buffer, "%02d", dateTime.data);
		TextGotoXY(&textWindow, col, row);
		TextPrintf(&textWindow, "%s", buffer);
		while((wKey = ProcessKeyField(NUMBER, &dateTime)) == 0);
		if(wKey == 'E')
		{
			if( dateTime.data >= 0 && dateTime.data < 60) {
				CurTime.tm_min = dateTime.data;
				break;
			}
			if(wKey == 'E')
			{
				break;
			}
		}
		if(dateTime.data < 0 || dateTime.data > 59)
		{
			dateTime.data  = (dateTime.data < 0) ? 59 : 0;
		}
	}

	CurTime.tm_sec = 0;
	ulTime = mktime ( &CurTime );		// get seconds from 1/1/1980
	write_rtc ( ulTime );				// set the real time clock
	keypadDef();

	glBlankScreen();
	while(1)
	{
		// Get current Date/Time
		FormatDateTime();					// convert to text

		// Display Date and Time
		glBuffLock();
		TextGotoXY(&textWindow, 0, 0);
		TextPrintf(&textWindow, "%s\n", szTime);

		// Display user exit message
		TextGotoXY(&textWindow, 0, 3);
		TextPrintf(&textWindow, "Press Key to EXIT    ");
		glBuffUnlock();

		keyProcess ();
		if((wKey = keyGet()) != 0)
		{
			glBlankScreen();
			break;
		}
	}
}
Ejemplo n.º 14
0
/* --------------------------------------------------------------------------------------

SYNTAX:	      int display_menu(char **line, int *state, int menu_num, int num_options)

DESCRIPTION:   Display a MENU on the LCD display and get the menu option from the user


PARAMETER1:    Pointer to list of menu options
PARAMETER2:    Pointer to Menu control parameter, control parameters macro's are as follows:
	               MENU_INIT..........Initialize and Display Menu
	               MENU_NO_CHANGE.....Select option, No menu/highlight bar changes occur.
                  MENU_REFRESH.......Display last image of menu of where it was.
PARAMETER3:    Unique menu number, starting with 0 and on up.
PARAMETER4:    The number of options for a given menu.

RETURN VALUE:	0 if no option is selected, otherwise it be the option selected

-----------------------------------------------------------------------------------------*/
int display_menu ( char **line, int *state, int level, int num_options)
{
	auto int menu_option;
	auto int i;
	auto struct menu_infor *ptr;

	ptr = &menu[level];
	menu_option = 0;			// Initially set to no option selected
	switch(*state)
	{
		case 0: // Set menu parameters in menu structure array
			ptr->current_offset = 0;		// Initialize menu line index
			ptr->highlight = 1;				// Assumes all menus have a heading
			ptr->new_offset = !ptr->current_offset;
			keyProcess ();

			// Make sure no key is being pressed initially
			if(keyGet() == 0)
			{
				*state = 4;
				break;
			}
			break;

		case 1: 	// Get the user's option
			menu_option = GetKeypadOption(&ptr->current_offset, &ptr->highlight, num_options);
			if(menu_option == -1)
			{
				// Check if user selected the scrolling option
				glSetBrushType(PIXXOR);
				glBlock (0, ptr->lasthighlight*8, 122, 8);
				glSetBrushType(PIXBLACK);

				// Set menu option to zero due to scrolling operation
				menu_option = 0;
				*state = 4;
			}
			break;

		case 2: // Refresh menu options
			glBuffLock();
			glBlankScreen();
			for(i=0; i < 4; i++)
			{	// Display up to 4 lines of menu options
				TextGotoXY(&textWindow, 0, i);
				TextPrintf(&textWindow, "%s", line[ptr->current_offset]);
				if(*line[ptr->current_offset + 1] == '\0')
				{
					break;
				}
				ptr->current_offset++;
			}
			// Reset the offset back to the first option displayed
			ptr->current_offset = ptr->current_offset-i;
			ptr->new_offset = ptr->current_offset;
			glSetBrushType(PIXXOR);
			glBlock (0, ptr->highlight*8, 122, 8);
			glSetBrushType(PIXBLACK);
			glBuffUnlock();
			ptr->lasthighlight = ptr->highlight;
			*state = 1;
			break;


		case 4: // Display menu option
			if(ptr->current_offset != ptr->new_offset)
			{
				glBuffLock();
				glBlankScreen();
				for(i=0; i < 4; i++)
				{	// Display up to 4 lines of menu options
					TextGotoXY(&textWindow, 0, i);
					TextPrintf(&textWindow, "%s", line[ptr->current_offset]);
					if(*line[ptr->current_offset + 1] == '\0')
					{
						break;
					}
					ptr->current_offset++;
				}
				glBuffUnlock();
				// Reset the offset back to the first option displayed
				ptr->current_offset = ptr->current_offset-i;
				ptr->new_offset     = ptr->current_offset;
			}
			glSetBrushType(PIXXOR);
			glBlock (0, ptr->highlight*8, 122, 8);
			glSetBrushType(PIXBLACK);
			ptr->lasthighlight = ptr->highlight;
			*state = 1;
			break;

		default:
			*state = 0;
			break;
	}
	return(menu_option);
}
Ejemplo n.º 15
0
//***************************************************************************
//	Mainline
//***************************************************************************
void main (	void	)
{
	auto char entry[256];

	auto int wKey, i, loop;
	auto int helpMenuDone;

	//------------------------------------------------------------------------
	// Board and drivers initialization
	//------------------------------------------------------------------------
	brdInit();		// Required for all controllers
	dispInit();		// Graphic driver initialization, Start-up the keypad driver
	keypadDef();	// Set keys to the default driver configuration

	//------------------------------------------------------------------------
	// Font initialization
	//------------------------------------------------------------------------
	// Initialize structures with FONT bitmap information
	glXFontInit(&fi6x8, 6, 8, 32, 127, Font6x8);				//	initialize basic font

	//------------------------------------------------------------------------
	// Text window initialization
	//------------------------------------------------------------------------
	// Setup the widow frame to be the entire LCD to display information
	TextWindowFrame(&textWindow1, &fi6x8, 0, 0, 122, 32);
	TextWindowFrame(&textWindow2, &fi6x8, 0, 24, 122, 8);

	//------------------------------------------------------------------------
	// Main loop for the user to create messages from the keypad
	//------------------------------------------------------------------------
	while(1)
	{
		// Display user prompt for the message menu
		glBlankScreen();
		TextGotoXY(&textWindow1, 0, 0);
		TextPrintf(&textWindow1, "Press + to create a message...\n");

		// Wait for ENTER key to be pressed
		do
		{
			keyProcess();
			wKey = keyGet();
		} while(wKey != '+');

		// Go to the message menu
		glBlankScreen();
		memset(entry,0,sizeof(entry));
		enter_chars(entry);

		// Display the message the user typed
		glBlankScreen();
		TextGotoXY(&textWindow1, 0, 0);
		TextPrintf(&textWindow1, "Typed...%s", entry);

		// Wait for user to press any key to startover
		TextGotoXY(&textWindow1, 0, 3);
		TextPrintf(&textWindow1, "ENTER to Continue");
		do
		{
			keyProcess();
			wKey = keyGet();
		} while(wKey == 0);
	}
}
Ejemplo n.º 16
0
//***************************************************************************
//	Message Menu used to create ASCII strings from the keypad
//***************************************************************************
void enter_chars(char *p)
{
	int i, column, len, disp_col, disp_row;
	int wKey;
	char *orig_ptr;

	// Initialize function parameters
	orig_ptr = p;
	i = 0;
	column = 0;
	len = 0;

	// Display the initial charater set for the user to choose from
	glBlankScreen();
	TextGotoXY(&textWindow1, 0, 1);
	TextPrintf(&textWindow1, "-");
	TextGotoXY(&textWindow1, 0, 0);
	TextPrintf(&textWindow1, "%s", s[i]);

	// Display user instructions
	display_help();

	// Setup for FAST key repeat after holding down key for 12 ticks
	keyConfig (  6,'E',0, 12, 1,  1, 1 );
	keyConfig (  2,'D',0, 12, 1,  1, 1 );
	keyConfig (  5,'+',0, 12, 1,  1, 1 );
	keyConfig (  1,'U',0, 12, 1,  1, 1 );
	keyConfig (  4,'-',0, 12, 1,  1, 1 );

	keyConfig (  0,'L',0, 12, 1,  1, 1 );
	keyConfig (  3,'R',0, 12, 1,  1, 1 );


	// Clear only the bottom half of the display
	glSetBrushType(PIXWHITE);
	glBlock(0,16,122,16);
	glSetBrushType(PIXBLACK);

	// Set window2 to start at column 0
	TextGotoXY(&textWindow2, 0, 0);
	TextPrintf(&textWindow2, "_");
	TextGotoXY(&textWindow2, 0, 0);

	do
	{

		// Wait for a key to be pressed
		do
		{
			keyProcess();
			msDelay(50);
			wKey = keyGet();
		} while(wKey == 0);

		switch(wKey)
		{
			// Scroll-Down to select new character group
			case 'D':
				i = i < (sizeof(s)/2)-1 ? ++i : 0;
				clrline(1, len);
				TextGotoXY(&textWindow1, 0, 1);
				TextPrintf(&textWindow1, "-");
				column = 0;
				clrline(0, strlen(*s));
				TextGotoXY(&textWindow1, 0, 0);
				TextPrintf(&textWindow1, "%s", s[i]);
				break;

			// Scroll-Up to select new character group
			case 'U':
				i = i > 0 ? --i : 0;
				clrline(1, len);
				TextGotoXY(&textWindow1, 0, 1);
				TextPrintf(&textWindow1, "-");
				column = 0;
				clrline(0, strlen(*s));
				TextGotoXY(&textWindow1, 0, 0);
				TextPrintf(&textWindow1, "%s", s[i]);
				break;

			// Scroll-Right for character set
			case 'R':
				column = column < strlen(*(&s[i]))-1 ? ++column : 0;
				clrline(1, len = strlen(*(&s[i])));
				TextGotoXY(&textWindow1, column, 1);
				TextPrintf(&textWindow1, "-");
				break;

			// Scroll-Left for character set
			case 'L':
				column = column > 0  ? --column : 0;
				clrline(1, len = strlen(*(&s[i])));
				TextGotoXY(&textWindow1, column, 1);
				TextPrintf(&textWindow1, "-");
				break;

			// Add the selected character to the message
			case '+':			// select char
				*p = s[i][column];
				if(*p == '_' && column == strlen(*(&s[i]))-1 )
				{	// Change to a space
					*p = ' ';
				}
				TextCursorLocation(&textWindow2, &disp_col, &disp_row);
				TextPrintf(&textWindow2, "%c", *p++);
				TextPrintf(&textWindow2, "_");
				TextGotoXY(&textWindow2, disp_col+1, 0);
				break;

			// Do a Backspace in the message
			case '-':
				TextGotoXY(&textWindow2, disp_col, disp_row);
				TextPrintf(&textWindow2, "  ");
				TextGotoXY(&textWindow2, disp_col, disp_row);
				TextPrintf(&textWindow2, "_ ");
				if(disp_col > 0)
				{
					p--;
				}
				TextGotoXY(&textWindow2, disp_col--, disp_row);
				if(disp_col < 0)
				{
					disp_col = 0;
					p = orig_ptr;
				}
				break;
		}
	}while(wKey != 'E');

	// NULL the terminate the user message
	*p = '\0';

	// Set the keypad back to the default driver configuration
	keypadDef();
}
Ejemplo n.º 17
0
scofunc putat(int x, int y, char* str)
{

	TextGotoXY(&wholewindow, x, y);
	TextPrintf(&wholewindow, "%s", str);
}
Ejemplo n.º 18
0
void main(void)
{
    tcp_Socket tcpSock;
    char *messages[12];
    unsigned int key;
    int i, send_response, test;

    // Initialize flag to indicate not ready to send response
    send_response = FALSE;

    // Initialize the message array with NULL pointers
    for (i = 0; i < (sizeof(messages)/sizeof(char*)); i++)
    {
        messages[i] = NULL;
    }

    // Define messages here--note that you only need define the messages
    // you will actually use.
    messages[0] = "I hear ya...";
    messages[1] = "Hello, there...";
    messages[2] = "It's a \"Rabbit\" Kind of place...";

    initsystem();
    sock_init();

    // Configure the upper row of keys on the keypad, in order
    // from left to right.
    for (i = 0; i < 7; i++)
    {
        // Only enable a key if there is a corresponding message
        if (messages[i] != NULL)
        {
            keyConfig ( i, ('0'+ i), 0, 0, 0, 0, 0 );
        }
        else
        {
            keyConfig ( i, IGNORE, 0, 0, 0, 0, 0 );
        }
    }

    while (1)
    {
        //	Process Keypad Press/Hold/Release
        costate
        {
            keyProcess ();
            waitfor ( DelayMs(10) );
        }

        costate
        {
            // Wait for a message from another device
            if (send_response == FALSE)
            {
                glBlankScreen();
                TextGotoXY(&wholewindow, 0, 0 );
                TextPrintf(&wholewindow, "Waiting for a \nmessage to be sent!");

                // Function is blocking until a message is received
                RecvMessage(&tcpSock);

                // Received message, prompt user to continue
                TextGotoXY(&wholewindow, 0, 3 );
                TextPrintf(&wholewindow, "Press key to proceed");

                // Allow the keyProcess function(above costate) to execute before
                // checking for keypress.
                waitfor(DelayMs(10));

                // Check if a key has been pressed
                waitfor ( key = keyGet() );	//	Wait for Keypress

                // Set flag to send respond back to controller that
                // sent the message.
                send_response = TRUE;
            }
        }

        costate
        {
            if(send_response)
            {
                glBlankScreen();
                TextGotoXY(&wholewindow, 0, 0 );
                TextPrintf(&wholewindow, "Press the key that \nis setup to send \nyour response...");
                waitfor ( key = keyGet() );	//	Wait for Keypress

                // Flash Leds to indicate that a key has been pressed
                flashled(key - '0');

                // Only handle the keypress if it corresponds to a message and if
                // a response is currently needed
                if (key != IGNORE)
                {
                    SendMessage(&tcpSock, (key - '0'), messages);
                    send_response = FALSE;
                }
            }
        }
    }

}