Example #1
0
void printString(const char *s)
{
    while(*s) {
        printChar(*s);
        s++;
    }
}
Example #2
0
/**
 * Display the debugging messages in the ncurses window
 */
void displayDebugStack(const WINDOW* window) {
    if (DEBUG_STACK->head == NULL) {
        return;
    }

    int maxY = 24;
    int maxX = 80;
    getmaxyx(window, maxY, maxX);

    for (int y=1; y <= 3; y++) {
        for (int x=0; x <= maxX; x++) {
            MapCoordinate position = initMapCoordinate(x, y);
            printChar(' ', position, BLACK_ON_WHITE);
        }
    }

    // Print three most recent debug messages
    DebugNode* current = DEBUG_STACK->current;
    if (current != NULL) {
        printDebug(current, 3);
        current = current->previous;
        if (current != NULL) {
            printDebug(current, 2);
            current = current->previous;
            if (current != NULL) {
                printDebug(current, 1);
            }
        }
    }
}
Example #3
0
File: term.c Project: gto76/race
void movePlayer(PLAYER (*ppp)[], int i, int dir) {
	PLAYER *p = &(*ppp)[i];
	POSITION oldPosition = (*p).obj.pos;
	POSITION newPosition = getNewPosition(oldPosition, dir);
	if (isPositionValid(newPosition, dir)) {
		// save move if not yet finished:
		if ((*p).finished != 1) {
			saveMove(p, dir);
		}
		// if player crossed the line, finished flag is set to true:
		if (crossedTheLine(oldPosition, dir)) {
			(*p).finished = 1;
		}
		int symbol = getSymbolOnTheTrack(oldPosition);
		erasePlayer(p); 
		// if player was on the finish line, draw finish line:
		if (symbol == '|') { 
			printChar('|', oldPosition);
		}
		(*p).obj.pos = newPosition;
		// so that if two were on the same spot both get printed:
		printAllPlayers(ppp);
		// so that it if two are on the same spot the last that arrived gets printed:
		printPlayer(p); 
	}
}
Example #4
0
/**
 * Prints an integer value
 * @param input The unsigned value.
 */
void pn(unsigned int input)
{
	int ldb = input % 10;
	int n = (int) input / 10;
	if (input > 9) pn(n);
	printChar(ldb + 48);
}
void TFT_ScaleFonts::rotateChar(byte c, int x, int y, int pos, int S, int deg)
{
  if (S < 1) S = 1;

  if ((S == 1) && (deg == 0))
  {
    _Disp->printChar(c, x, y);
    return;
  }
  else if (S == 1)
  {
    _Disp->rotateChar(c, x, y, pos, deg);
    return;
  }
  else if (deg == 0)
  {
    printChar(c, x, y, S);
    return;
  }

  byte i, j, ch;
  word temp;
  int newx, newy;
  double radian;
  radian = deg * 0.0175;

  cbi(_Disp->P_CS, _Disp->B_CS);

  temp = ((c - _Disp->cfont.offset) * ((_Disp->cfont.x_size / 8) * _Disp->cfont.y_size)) + 4;
  for (j = 0; j < _Disp->cfont.y_size * S; j += S)
  {
    for (int zz = 0; zz < (_Disp->cfont.x_size / 8)*S; zz += S)
    {
      ch = pgm_read_byte(&_Disp->cfont.font[temp + (zz / S)]);
      for (i = 0; i < (8 * S); i++)
      {
        for (int s = 0; s < S; s++)
        {
          newx = x + (((i + (zz * 8) + (pos * _Disp->cfont.x_size)) * cos(radian)) - ((j + s) * sin(radian)));
          newy = y + (((j + s) * cos(radian)) + ((i + (zz * 8) + (pos * _Disp->cfont.x_size)) * sin(radian)));

          _Disp->setXY(newx, newy, newx + 1, newy + 1);

          if ((ch & (1 << (7 - (i / S)))) != 0)
          {
            _Disp->setPixel((_Disp->fch << 8) | _Disp->fcl);
          }
          else
          {
            if (!_Disp->_transparent)
              _Disp->setPixel((_Disp->bch << 8) | _Disp->bcl);
          }
        }
      }
    }
    temp += (_Disp->cfont.x_size / 8);
  }
  sbi(_Disp->P_CS, _Disp->B_CS);
  _Disp->clrXY();
}
void TFT_ScaleFonts::print(char *st, int x, int y, int S, int deg)
{
  if (S < 1) S = 1;

  if (S == 1)
  {
    _Disp->print(st, x, y, deg);
    return;
  }

  int stl, i;

  stl = strlen(st);

  if (_Disp->orient == PORTRAIT)
  {
    if (x == RIGHT)
      x = ((Bound_X2 - Bound_X)/*_Disp->disp_x_size*/ + 1) - (stl * _Disp->cfont.x_size * S);
    if (x == CENTER)
      x = (((Bound_X2 - Bound_X) + 1) - (stl * _Disp->cfont.x_size * S)) / 2;
  }
  else
  {
    if (x == RIGHT)
      x = ((Bound_Y2 - Bound_Y) + 1) - (stl * _Disp->cfont.x_size * S);
    if (x == CENTER)
      x = (((Bound_Y2 - Bound_Y) + 1) - (stl * _Disp->cfont.x_size * S)) / 2;
  }

  for (i = 0; i < stl; i++)
    if (deg == 0)
      printChar(*st++, x + (i * (_Disp->cfont.x_size * S)), y, S);
    else
      rotateChar(*st++, x, y, i * S, S, deg);
}
Example #7
0
/*! Repeatedly prints a character specified by its ASCII code to the display.
    Most LCDs can also print some special characters, such as those in LCD.h.
    @param data The character to print to the LCD.
    @param times The number of times to print the character.
 */
void printCharN(const u08 data, const u08 times)
{
	for (u08 i = 0; i < times; i++)
	{
		printChar(data);
	}
}
Example #8
0
void sendHeader(uint16_t channel)
{
//return; //ign

    CRC = 0;
    printChar('$');
    printUInt(channel);
    printD();
    printUInt(Program::programType+1);
    printD();

    printUInt(currentTime/1000);   //timestamp
    printChar('.');
    printUInt((currentTime/100)%10);   //timestamp
    printD();
}
Example #9
0
static void printConstant( int lev, ASTNode node )
{
	indent( lev );
	switch (node->vConstExpr.type)
	{
	case inumberConst:
		ec_stderr_printf( "<const: %ld>", (long)node->vConstExpr.vInt );
		break;
	case fnumberConst:
		ec_stderr_printf( "<const: %g>", node->vConstExpr.vFloat );
		break;
	case charConst:
		if (isprint( (int) node->vConstExpr.vChar ))
			ec_stderr_printf( "<const: '%c'>", node->vConstExpr.vChar );
		else
		{
			ec_stderr_printf( "<const: '" );
			printChar( node->vConstExpr.vChar );
			ec_stderr_printf( "'>" );
		}
		break;
	case symbolConst:
		ec_stderr_printf( "<const: %s>", EcSymbolAt( node->vConstExpr.vSym ) );
		break;
	case stringConst:
		ec_stderr_printf( "<const: \"" );
		printString( node->vConstExpr.vString );
		ec_stderr_printf( "\">" );
		break;
	case objectConst:
		ec_stderr_printf( "<const: EC_OBJ 0x%08lX>", (unsigned long)node->vConstExpr.vObject );
		break;
	}
}
Example #10
0
File: ascart.c Project: NeTTa/espl
void printWord(int iline , int argc ,char **argv){
	int iarg;
	for(iarg = 1; iarg != argc; ++iarg) {
		char *c = argv[iarg];
		printChar(c,iline);
		printSpace(iarg , iline , argc);
	}
}
Example #11
0
void printInteger(int X){
  	int Y=getReverse(X);
  	while(Y>0)
	{
  	printChar(48+mod(Y,10));
  	Y=div(Y,10);
 	 }
}
void MG2639_Cell::sendATCommand(const char * command)
{	
	clearSerial();	// Empty the UART receive buffer
	// Send the command:
	printString("AT"); // Print "AT"
	printString(command); // Print the command
	printChar('\r'); // Print a carriage return to end command
}
Example #13
0
void Ticker::printString(const char* st)
// print a zero-terminated string which is stored in RAM
{
	while (*st) {
		printChar(*st);
		st++;
	}
}
Example #14
0
//Prints an 8-bit unsigned integer as 1-3 digits (no padding). Example: "7"
void printPlain_u08(u08 number)
{
	//if there is a digit in the tens place
	if (number >= 10)
	{
		//if there is a digit in the hundreds place
		if (number >= 100)
		{
			//print the hundreds digit
			printChar((number / 100) + 48);
		}
		//print the tens digit
		printChar(((number % 100 ) / 10) + 48);
	}
	//always print the ones digit
	printChar((number % 10) + 48);
}
Example #15
0
void printString(View *view, char *string, int size, int x, int y, Color mainColor, Color shadowColor) {
   int i=0;
   for (i=0;i<size;++i) {
      char c = *(string + i);
      int p = x + i*8;
      printChar(view, c, p, y, mainColor, shadowColor);
   }
}
Example #16
0
//Prints a 16-bit signed integer as +/- and 1-5 digits (no padding). Example: "+42"
void printPlain_s16(s16 number)
{
	if (number >= 0)
	{
		//print plus
		printChar('+');
		//cast to print the number as a u16
		printPlain_u16((u16)number);
	}
	else
	{
		//print minus
		printChar('-');
		//make the number positive and print it as a u16
		printPlain_u16((u16)(-number));
	}
}
Example #17
0
/*!	\fn 	static void printTextP(const char *data)
*	\brief	Print a string using FLASH stored data
* 
*   \param  data - pointer to flash string
*/
static void printTextP(const char *data)
{
    char c;
    while((c = pgm_read_byte(data++)))
    {
        printChar(c);
    }
}
Example #18
0
int main()
{   
    int i, j, k;
    scanf("%d", &j);
    for(i = 1; i <= j; i++)
    {
          printChar('*', i);
          printf("\n");            
    }
    for (i = j - 1; i > 0; i--)
    {
        printChar('*', i);
        printf("\n");
    }
    system("pause");
    return 0;
}
Example #19
0
static void normalizeAndPrintString(uchar *s, int len)
{
    int i;

    for(i = 0; i < len; i++) {
        printChar(s[i], (i + 1) >= len);
    }
}
Example #20
0
void printString( char* str )
{
	while (*str != '\0')
	{
		printChar( *str );
		str++;
	}
}
Example #21
0
//Prints an 8-bit signed integer as +/- and 1-3 digits (no padding). Example: "+7"
void printPlain_s08(s08 number)
{
	if (number >= 0)
	{
		//print plus
		printChar('+');
		//cast to print the number as a u08
		printPlain_u08((u08)number);
	}
	else
	{
		//print minus
		printChar('-');
		//make the number positive and print it as a u08
		printPlain_u08((u08)(-number));
	}
}
int derDecodeTest(TestParams *testParams)
{
	/* which flavor - good or bad? */
	const CSSM_DATA *derSrc;
	bool expectErr = false;
	
	if((testParams->threadNum & 1) || !DO_BAD_DECODE) {
		derSrc = &goodDer;
	}
	else {
		derSrc = &badDer;
		expectErr = true;
	}
	for(unsigned loop=0; loop<testParams->numLoops; loop++) {
		if(testParams->verbose) {
			printf("derDecode thread %d: loop %d\n", 
				testParams->threadNum, loop);
		}
		else if(!testParams->quiet) {
			printChar(testParams->progressChar);
		}
		
		for(unsigned dex=0; dex<DECODES_PER_LOOP; dex++) {
			SecAsn1CoderRef coder;
			SecAsn1CoderCreate(&coder);
			twoInts ti;
			OSStatus perr1, perr2;
			memset(&ti, 0, sizeof(ti));
			perr1 = SecAsn1DecodeData(coder, derSrc, twoIntsTemp, &ti);
			usleep(100);
			perr2 = SecAsn1DecodeData(coder, derSrc, twoIntsTemp, &ti);
			if(perr1 != perr2) {
				printf("***derDecodeTest: different errors (%d, %d)\n",
					(int)perr1, (int)perr2);
				return 1;
			}
			if(expectErr) {
				if(!perr1) {
					printf("derDecodeTest: expect failure, got success\n");
					return 1;
				}
			}
			else {
				if(perr1) {
					printf("derDecodeTest: expect success, got %d\n", (int)perr1);
					return 1;
				}
			}
			SecAsn1CoderRelease(coder);
		}
		#if DO_PAUSE
		fflush(stdin);
		printf("End of loop, CR to continue: ");
		getchar();
		#endif
	}
	return 0;
}
int main0( )
{

  printStr("Benchmark mc_median\n");

  // start counting instructions and cycles
  int cycles, insts;
  cycles = getCycle();
  insts = getInsts();

  // do the median filter
  median_first_half( DATA_SIZE, input_data, results_data );

  // stop counting instructions and cycles
  cycles = getCycle() - cycles;
  insts = getInsts() - insts;

  // wait for main1 to finish
  while( main1_done == 0 );

  // print the cycles and inst count
  printStr("Cycles (core 0) = "); printInt(cycles); printChar('\n');
  printStr("Insts  (core 0) = "); printInt(insts); printChar('\n');
  printStr("Cycles (core 1) = "); printInt(main1_cycles); printChar('\n');
  printStr("Insts  (core 1) = "); printInt(main1_insts); printChar('\n');
  cycles = (cycles > main1_cycles) ? cycles : main1_cycles;
  insts = insts + main1_insts;
  printStr("Cycles  (total) = "); printInt(cycles); printChar('\n');
  printStr("Insts   (total) = "); printInt(insts); printChar('\n');

  // Check the results
  int ret = verify( DATA_SIZE, results_data, verify_data );
	printStr("Return "); printInt(ret); printChar('\n');
	return ret;
}
Example #24
0
int getline(char arr[],int maxLen)
{
	/*
	 * 读取用户输入的一行
	 */

	int i = 0;
	char in;
	if(maxLen == 0)
	{
		return 0;
	}
	in = getchar();
	while(in != '\n'&& in != '\r') 
	{
		/*
		 * 判断是不是回车键
		 */
		int k = in;
		if(k == 8)
		{
			/*
			 * 判断是不是退格键
			 */
			i--;
			in = getchar();
			continue;
		}
		printChar(in);
		arr[i++] = in;
		if(i == maxLen)
		{
			/*
			 * 是否达到允许输入的最大长度
			 */
			arr[i] = '\0';
			printChar('\n');
			return 0;
		}
		in = getchar();
	}
	arr[i] = '\0';
	print("\n\r");
    return 1;
}
Example #25
0
static void
indent (int *width)
{
  int i;
  for (i = 0; i < indentation; i++)
    {
      printChar (' ', width);
    }
}
Example #26
0
/*
 * Esta funcion imprime una cadena de caracteres, es utilizada solo por el kernel
 */
static void print(const char* msg, pBuffer buffer)
{
	unsigned long i;
	// Continue until we reach null character
	i = 0;
	while (msg[i] != 0)
		printChar(msg[i++],buffer);
	
}
Example #27
0
void replaceLastLine(char* string){
	WORD i = 0;
	WORD curLoc;
	curLoc = i+startOfThisLine(Screen.curLoc);
	for(;i<WIDTH;++i){
		if(i<strlen(string)){
			if(Screen.charSpace[curLoc] != string[i]){
				Screen.charSpace[curLoc] = string[i];
				printChar(string[i], curLoc);
			}
		}else if(Screen.charSpace[curLoc]!=0){
			Screen.charSpace[curLoc] = 0;
			printChar(' ', curLoc);
		}
		curLoc++;
	}
	Screen.curLoc = startOfNextLine(startOfThisLine(curLoc));
}
Example #28
0
int main( int argc, char* argv[] )
{
  int results_data[DATA_SIZE];

  // Do the filter
  int cycles, insts;
  cycles = getTime();
  insts = getInsts();
  median( DATA_SIZE, input_data, results_data );
  cycles = getTime() - cycles;
  insts = getInsts() - insts;
  printStr("Cycles = "); printInt(cycles); printChar('\n');
  printStr("Insts  = "); printInt(insts); printChar('\n');

  // Check the results
  return !(verify( DATA_SIZE, results_data, verify_data ));

}
Example #29
0
static void printString         // PRINT A STRING
    ( char const *str )         // - string to be printed
{
    for( ; ; ++str ) {
        char chr = *str;
        if( '\0' == chr ) break;
        printChar( chr );
    }
}
Example #30
0
//Prints a string starting at the current cursor position.
//Strings exceeding the length of the display go into the display's buffer.
//This is useful if you are using the scrolling option, but wastes write time otherwise.
//Once the buffer for the first line has been filled, the cursor wraps to the next line.
void printString(char* string)
{
	u08 i = 0;
	//keep printing until we encounter a null terminator
	while (string[i] != 0)
	{
		printChar(string[i++]);
	}
}