Example #1
0
void drawAxes()
{
	// Draw the origin
	glPushMatrix();
	glScalef(5,5,5);

	glShadeModel(GL_FLAT);
	glDisable(GL_LIGHTING);
	glBegin(GL_LINES);
		// x axis
		glColor3f(1.0, 0.0, 0.0);
		glVertex3d( 0.0, 0.0, 0.0 );
		glVertex3d( 1.0, 0.0, 0.0 );

		// y axis
		glColor3f(0.0, 1.0, 0.0);
		glVertex3d( 0.0, 0.0, 0.0 );
		glVertex3d( 0.0, 1.0, 0.0 );

		// z axis
		glColor3f(0.0, 0.0, 1.0);
		glVertex3d( 0.0, 0.0, 0.0 );
		glVertex3d( 0.0, 0.0, 1.0 );
	glEnd();

	glColor3f(1.0f, 0.0f, 0.0f);
	glRasterPos3f(1.2f, 0.0f, 0.0f);
	printString("X");

	glColor3f(0.0, 1, 0.0);
	glRasterPos3f(0.0f, 1.2f, 0.0f);
	printString("Y");

	glColor3f(0.0f, 0.0f, 1.0f);
	glRasterPos3f(0.0f, 0.0f, 1.2f);
	printString("Z");

	glPopMatrix();

	glEnable(GL_LIGHTING);
}
Example #2
0
void TaskStat(void)                /* a task to track statistics */
{
    unsigned max, switchCount, idleCount;
    int tmp;
        
    YKDelayTask(1);
    printString("Welcome to the YAK kernel\r\n");
    printString("Determining CPU capacity\r\n");
    YKDelayTask(1);
    YKIdleCount = 0;
    YKDelayTask(5);
    max = YKIdleCount / 25;
    YKIdleCount = 0;

    YKNewTask(TaskPrime, (void *) &TaskPRMStk[TASK_STACK_SIZE], 32);
    YKNewTask(TaskWord,  (void *) &TaskWStk[TASK_STACK_SIZE], 10);
    YKNewTask(TaskSpace, (void *) &TaskSStk[TASK_STACK_SIZE], 11);
    YKNewTask(TaskPunc,  (void *) &TaskPStk[TASK_STACK_SIZE], 12);
    
    while (1)
    {
        YKDelayTask(20);
        
        YKEnterMutex();
        switchCount = YKCtxSwCount;
        idleCount = YKIdleCount;
        YKExitMutex();
        
        printString ("<<<<< Context switches: ");
        printInt((int)switchCount);
        printString(", CPU usage: ");
        tmp = (int) (idleCount/max);
        printInt(100-tmp);
        printString("% >>>>>\r\n");
        
        YKEnterMutex();
        YKCtxSwCount = 0;
        YKIdleCount = 0;
        YKExitMutex();
    }
}   
Example #3
0
void printHeader()
{
	int screen_height, screen_weight;
	char header_buf[ 1024 ];

	clear();
	getmaxyx( stdscr, screen_height, screen_weight );
	printString( "h,? - help; z - toggle color-mode; q,F10,Ctrl-c - quit",
			     A_NORMAL, getW (), NEWLINE );
	if( is_colorize )
      attron( COLOR_PAIR( 1 ) );

	sprintf(
			  header_buf,
			  " +User%c          .+cpu(%)  %c         . +read(B/s)%c        . +write(B/s)   %c . CAUSE    ",
			  sort_type == 3 ? '*' : ' ', !sort_type ? '*' : ' ', sort_type
				  	    == 1 ? '*' : ' ', sort_type == 2 ? '*' : ' ' );
	printString( header_buf, (is_colorize) ? A_NORMAL : A_REVERSE, getW(),
			     NEWLINE );
    if( is_colorize ) attroff( COLOR_PAIR( 1 ) );
}
Example #4
0
/*
 * printf(char *fmt, ... ) - prints a sequence of data formatted as the format 
 * argument specifies 
 * 
 * This function emulates the stdio.h printf() functionality in C and will send
 * the output to the Serial connection using printByte(). The resulting 
 * string sent over serial is limited to 128 chars.
 * 
 * Parameters: 
 * 		fmt : FlashStringHelper defined in Flash memory  
 * 
 * Examples:
 * 	USB.printf("%s\n", "Hello world");
 *  USB.printf("x:%d,y:%d,z:%d -bat: %d%c%c%c",
 * 												ACC.getX(),
 * 												ACC.getY(),
 * 												ACC.getZ(),  														
 * 												PWR.getBatteryLevel(),
 * 												'%',
 * 												'\r',
 * 												'\n'	);	
 * 
 */
void  WaspUSB::printf(char *fmt, ... )
{	
	secureBegin();	
	// resulting string limited to 128 chars
    char tmp[128]; 
    va_list args;
    va_start (args, fmt );
    vsnprintf(tmp, 128, fmt, args);
    va_end (args);
    printString(tmp, _uart);
    secureEnd();
}
::Ice::DispatchStatus
Demo::Printer::___printString(::IceInternal::Incoming& __inS, const ::Ice::Current& __current)
{
    __checkMode(::Ice::Normal, __current.mode);
    ::IceInternal::BasicStream* __is = __inS.is();
    __is->startReadEncaps();
    ::std::string s;
    __is->read(s);
    __is->endReadEncaps();
    printString(s, __current);
    return ::Ice::DispatchOK;
}
Example #6
0
void initUSART() 
{                                
	/* Set Baud Rate */
	UBRR0L = 0x33;

	/* Enable receiver and transmitter */
	UCSR0B = ( 1 << RXEN0 ) | ( 1 << TXEN0 );

	/* set frame format: 8data, 2 stop bit */
	UCSR0C = ( 1 << UCSZ00 ) | ( 1 << UCSZ01 );
	printString( "UART Initialized.\n\n" );
}
/* Everything above this line could be in a library that defines a font.
 * To make it work, you've got to call makeRasterFont() before you start
 * making calls to printString().
 */
void display(void)
{
    GLfloat white[3] = { 1.0, 1.0, 1.0 };
    int i, j;
    char teststring[33];

    glClear(GL_COLOR_BUFFER_BIT);
    glColor3fv(white);
    for (i = 32; i < 127; i += 32) {
	glRasterPos2i(20, 200 - 18*i/32);
	for (j = 0; j < 32; j++)
	    teststring[j] = (char) (i+j);
	teststring[32] = 0;
	printString(teststring);
    }
    glRasterPos2i(20, 100);
    printString("The quick brown fox jumps");
    glRasterPos2i(20, 82);
    printString("over a lazy dog.");
    glFlush ();
}
Example #8
0
void printHex(unsigned int Number) {
  char HexBuffer[5];
  HexBuffer[4] = 0;
  HexBuffer[3] = HexDigit(Number & 0x000f);
  Number = Number >> 4;
  HexBuffer[2] = HexDigit(Number & 0x000f);
  Number = Number >> 4;
  HexBuffer[1] = HexDigit(Number & 0x000f);
  Number = Number >> 4;
  HexBuffer[0] = HexDigit(Number & 0x000f);
  printString(HexBuffer);
}
void loop(){
  seq.rotation.update(getAnalogValue(SEQUENCER_ROTATE_CONTROL));
  seq.step.update(getAnalogValue(SEQUENCER_STEP_CONTROL));
  seq.fill.update(getAnalogValue(SEQUENCER_FILL_CONTROL));
  seq.update();

#ifdef SERIAL_DEBUG
  if(serialAvailable() > 0){
    serialRead();
    printString("a: [");
    seq.dump();
    printString("] ");
    seq.print();
    if(clockIsHigh())
      printString(" clock high");
    if(resetIsHigh())
      printString(" reset high");
    printNewline();
  }
#endif
}
/* Returns joined network name. */
char* RemoteHomeWifi::getNetworkName() {
    //static char netName[33];
    char * netName = (char *) calloc (33, 1);
    if (connectedToWifi) {
        cleanSerialBuffer(); 
        printString(AT_CHECK_AP_CONNECTION);
        printCrLf();
        _ser.find("\"");
        _ser.readBytesUntil((char)34, netName, 32); 
    }
    return netName;
}
Example #11
0
int main(int argc, char ** argv)
{
	if (argc == 1) {
		print();
	} else if (argc == 2) {
		printInt(2);
	} else {
		printString(*argv);
	}

	return 0;
}
Example #12
0
void CrlInfo::printName(const char *prefixStr)
{
	#ifndef	NDEBUG
	CSSM_DATA_PTR val = fetchValidAttr(ATTR_DEX_PRINT_NAME);
	if(val == NULL) {
		ocspdCrlDebug("%s: X509 CRL <no name>", prefixStr);
	}
	else {
		printString(prefixStr, val);
	}
	#endif
}
Example #13
0
int print_delay_list(void)
{   
    int count = 0;
	tcb_t* iter = YKBlockList;
	while( iter )
	{
		printInt( iter->priority );
        if (iter->state == DELAYED) {
		    printString( " Delay: " );
		    printInt( iter->delay );
        }
        else if (iter->state == SEMAPHORE) {
		    printString( " Semaphore: " );
		    printInt( iter->semaphore->value );
        }
		printNewLine();
		iter = iter->next;
        ++count;
	}
    return count;
}  
Example #14
0
/*
	Send/print unsigned or signed number over UART. 
	Printable data for viewing on terminal.
	Call this function:		printNumber(number, DEC);		printNumber(2246, DEC);	
	Base: DEC, HEX, OCT, BIN
	Data must be number, int32_t.
*/
void printNumber(int32_t number, uint8_t base){
	if (number < 0) 
	{
		printString("-");
		number = -number;
		printUnsignedNumber(number, base);
	}
	else 
	{
		printUnsignedNumber(number, base);
	}
}
Example #15
0
void STask(void)           /* tracks statistics */
{
    unsigned max, switchCount, idleCount;
    int tmp;

    YKDelayTask(1);
    printString("Welcome to the YAK kernel\r\n");
    printString("Determining CPU capacity\r\n");
    YKDelayTask(1);
    YKIdleCount = 0;
    YKDelayTask(5);
    max = YKIdleCount / 25;
    YKIdleCount = 0;

    YKNewTask(CharTask, (void *) &CharTaskStk[TASK_STACK_SIZE], 2);
    YKNewTask(AllNumsTask, (void *) &AllNumsTaskStk[TASK_STACK_SIZE], 1);
    YKNewTask(AllCharsTask, (void *) &AllCharsTaskStk[TASK_STACK_SIZE], 3);
    
    while (1)
    {
        YKDelayTask(20);
        
        YKEnterMutex();
        switchCount = YKCtxSwCount;
        idleCount = YKIdleCount;
        YKExitMutex();
        
        printString("<<<<< Context switches: ");
        printInt((int)switchCount);
        printString(", CPU usage: ");
        tmp = (int) (idleCount/max);
        printInt(100-tmp);
        printString("% >>>>>\r\n");
        
        YKEnterMutex();
        YKCtxSwCount = 0;
        YKIdleCount = 0;
        YKExitMutex();
    }
}   
int main(void) {

	float voltage1;
	float voltage2;
	float res1;
	float res2;
	// -------- Inits --------- //
	initUSART();
	setupADCSleepmode();
	printString("\r\nDigital Voltmeter\r\n\r\n");
	

	// ------ Event loop ------ //
  
	while (1) {

		initADC(0);
		voltage1 = oversample16x();
		printString("Thermistor 1:\r\n");
		printFloat(voltage1);
		//printVoltage(voltage1);
		res1 = printThermRes(voltage1);
		printTemp(res1);
		printString("\r\n");
		
		_delay_ms(100);

		initADC(1);
		voltage2 = oversample16x();
		printString("Thermistor 2:\r\n");
		printFloat(voltage2);
		//printVoltage(voltage2);
		res2 = printThermRes(voltage2);
		printTemp(res2);
		printString("\r\n");
		_delay_ms(2500);
		
	}                                                  /* End event loop */
	return (0);                            /* This line is never reached */
}
/* This will tell ESP module to connect to the WiFi network. */
boolean RemoteHomeWifi::joinNetwork(String ssid, String password, String ip) {
  cleanSerialBuffer();
  if (ip.length() == 0) {
      //enable dhcp
      sendATCommand(AT_ENABLE_DHCP, ANSWER_OK);
  } else {
      //disable dhcp and set ip
      sendATCommand(AT_DISABLE_DHCP, ANSWER_OK);
      printString(AT_SET_IP_ADDR);
      printStr(ip);
      printString(AT_QUOTATION_MARK);
      printString(CRLF);
      _ser.find(ANSWER_OK);
  }
  printString( AT_JOIN_AP_PARAMS);
  printStr(ssid);
  printString(AT_QUOTATION_MARKS_WITH_COMMA);
  printStr(password);
  printString(AT_QUOTATION_MARK);
  printCrLf();
  _ser.setTimeout(19000);
  boolean ret = _ser.find(ANSWER_OK);
  setDefaultSerialTimeout();
  delay(20);
  return ret;
}
Example #18
0
void askNums() {
	printString("Enter the number of integers you want to read in.\n");
	int num = readInt();
	int* myNums = sbrk(sizeof(int) * num);
	printString("Enter your numbers now.\n");
	int i;
	for(i = 0; i < num; i++) {
		*(myNums + i) = readInt();
	}
	int sum = 0;
	int product = 1;
	for(i = 0; i < num; i++) {
		int j = myNums[i];
		if(j == 0) {
			continue;
		}
		sum += myNums[i];
		product *= myNums[i];
	}
	printString("The sum of these numbers is ");
	printInt(sum);
	printString(".\n");
	
	printString("The product of these numbers is ");
	printInt(product);
	printString(".\n");
}
void ParticleShaderText::drawParticle(int i)
{
	
	int val = i;
	if((useScalar) && (scalar))
		val = (int) scalar->getScalar(i);

	makeRasterFont();
    char wholestring[6];
	char teststring[5];
	char zero[] = " ";

	//glRasterPos3i(0,0,0);
	glRasterPos2i(0,0);
	sprintf(teststring,"%i",val);
	
	strcpy(wholestring, zero);
	strcat(wholestring,teststring);
   	printString(wholestring);


	//	GLfloat black[3] = {0.0, 1.0, 0.0};
//	int j,k;

//	int sSz = 5; // teststring size

    //glPushAttrib(GL_COLOR_BUFFER_BIT);
	//glClear(GL_COLOR_BUFFER_BIT);
//    glColor3fv(black);
    /*for (j = 32; j < 127; j += sSz) {
        //glRasterPos2i(20, 200 - 18*j/sSz);
		glRasterPos3i(0,0,0);
        for (k = 0; k < sSz; k++)
            teststring[k] = (char) (j+k);
        teststring[sSz-1] = 0;
        printString(teststring);
    }*/
    //glRasterPos2i(20, 100);
	
//	float clr[4];
	
//	glGetFloatv(GL_CURRENT_RASTER_COLOR,clr);
	
	
	//printString("123");
    //glRasterPos2i(20, 82);
    //printString("over a lazy dog.");
    //glFlush ();
	//glPopAttrib();


}
Example #20
0
void initADC( void )
{
	/* reference voltage on AVCC. ADC defaults to channel 0 */
	ADMUX |= (1 << REFS0);

	/* ADC clock prescaler /16 */
	ADCSRA |= (1 << ADPS2);

	 /* enable ADC */
	ADCSRA |= (1 << ADEN);

	printString("ADC initialized.\n\n");
}
Example #21
0
void setup_avr(void) {
	// Run at 8Mhz
	CLKPR = (1 << CLKPCE); // Enable changing clock prescaler
	CLKPR = 0;             // Set to 8Mhz (no divider)

	// Set port directions to output
	DDRB |= (1 << LED);

#if DEBUG
	initUSART();
	printString("Therm running\r\n");
#endif
}
Example #22
0
void shove(uint8_t color, uint8_t* sensors)
{
	switch(color) {
	case RED:
		printString("shoving red\n");
		break;
	case GREEN:
		printString("shoving green\n");
		break;
	case YELLOW:
		printString("shoving yellow\n");
		break;
	case BLUE:
		printString("shoving blue\n");
		break;
	case NONE:
		printString("shoving none\n");
		break;
	default:
		break;
	}
}
Example #23
0
void sensor_init(void)
{
	i2c_start(SENSOR_WRITE);
	i2c_write(0x80 | 0x00);
	i2c_stop();
	i2c_start(SENSOR_WRITE);
	i2c_write(0x01 | 0x02);
	i2c_stop();
	i2c_start(SENSOR_WRITE);
	i2c_write(0x80 | 0x14);
	i2c_stop();
	printString("Sensor initialized\n");
}
Example #24
0
void listProcesses(){
  int q;
  char mess[20];
  char proc[5];
  proc[0] = ' ';
  proc[1] = '#';
  proc[2] = '\r';
  proc[3] = '\n';
  proc[4] = '\0';
  mess[0] = 'P';
  mess[1] = 'r';
  mess[2] = 'o';
  mess[3] = 'c';
  mess[4] = 'e';
  mess[5] = 's';
  mess[6] = 's';
  mess[7] = 'e';
  mess[8] = 's';
  mess[9] = ':';
  mess[10] = '\r';
  mess[11] = '\n';
  mess[12] = '\0';
  printString(mess);

  setKernelDataSegment();
  for(q=0; q<NUMBEROFPROCESSENTRIES; q++){
    if(processTable[q].active == 1){
      printString(processTable[q].name);

      restoreDataSegment();
      proc[1] = '0'+q;
      printString(proc);
      setKernelDataSegment();
    }
  }
  restoreDataSegment();

  return;
}
Example #25
0
/*
 * tracks statistics
 */
void StatTask(void) {
    unsigned max, switchCount, idleCount;
    int tmp;
	
    YKDelayTask(1);
	
    printString("Welcome to the YAK kernel\r\n");
    printString("Determining CPU capacity\r\n");
    YKDelayTask(1);
    YKIdleCount = 0;
    YKDelayTask(5);
    max = YKIdleCount / 25;
    YKIdleCount = 0;
	
    YKNewTask(ArrivalTask, (void *) &ArrivalTaskStk[TASK_STACK_SIZE], 25);
    YKNewTask(CommunicationTask, (void *) &CommunicationTaskStk[TASK_STACK_SIZE], 20);
    
    while (1)
    {
        YKDelayTask(20);
        
        YKEnterMutex();
        switchCount = YKCtxSwCount;
        idleCount = YKIdleCount;
        YKExitMutex();
        
        printString("<CS: ");
        printInt((int)switchCount);
        printString(", CPU: ");
        tmp = (int) (idleCount/max);
        printInt(100-tmp);
        printString(">\r\n");
        
        YKEnterMutex();
        YKCtxSwCount = 0;
        YKIdleCount = 0;
        YKExitMutex();
    }
}
handleInterrupt21(int ax, int bx, int cx, int dx){
   if(ax==0)
   	printString(bx);
   if(ax==1)
   	readString(bx);
   if(ax==2)
   	readSector(bx,cx);
   if(ax==3)
   	readfile(bx,cx);
    if(ax==4)
     executeProgram(bx,cx);
   if(ax==5)
   	terminate();
   if(ax==6)
    writeSector(bx,cx);
   if(ax==7)
   	deleteFile(bx);
   if(ax==8)
   	 writeFile(bx,cx,dx);
   if(ax>=9)
   	printString("Error");
 }
Example #27
0
void print_debug(RHTresult *result) {
#if DEBUG
	printString("Bits:\r\n");
	for(int i = 0; i < 43; i++) { 
		printByte(i);
		printString(": ");
		printByte(tries_b[i]);
		printString("\r\n"); 
	}

	printString("\r\n\r\n");
	printString("Temperature: ");
	printWord(result->temperature);
	printString("\r\n");
	printString("Humidity: ");
	printWord(result->humidity);
	printString("\r\n");
	printString("Checksum: ");
	printByte(result->checksum);
	printString("\r\n\r\n");
#endif
}
Example #28
0
void printTime(int hours, int minutes, int seconds) 
{
  int decimalbuffer =0;
    DecimalBuffer[0] = (hours%10)+'0';
  DecimalBuffer[1] = (hours / 10)+'0';
 DecimalBuffer[2] = ':';
  DecimalBuffer[3] = (minutes%10)+'0';
  DecimalBuffer[4] = (minutes / 10)+'0';
 DecimalBuffer[5] = ':';
  DecimalBuffer[6] = (seconds%10)+'0';
  DecimalBuffer[7] = (seconds / 10)+'0';
  printString(DecimalBuffer);
}
Example #29
0
void PrenController::setCrossingFound(int distance) {
	char str[50];
	sprintf(str, "Crossing ahead: Distance to Crossing: %d", distance);
	printString(str, CONTROLLER, 1);
	// inform MC-Board
	uartSender->setEngineSpeed(0, UARTSender::SOFT);
	uartSender->setCameraPos(CAM_CHECK_STREET);
	// inform ObjectFinder
	objectStateObserver->updateCrossingState(true);
	usleep(500 * 1000);
	uartSender->setCameraPos(CAM_STRAIGHT);
	uartSender->setEngineSpeed(MAX_ENGINE_SPEED);
}
Example #30
0
void moveNow() {
	delayMs(10000);
	move(RIGHT);
	delayMs(2000);
	for (;;) {
		clearScreen();
		printString("looping");
		move(RIGHT);
		delayMs(3450);
		move(LEFT);
		delayMs(3500);
	}
}