// Lab01/2 -  for third task
void tWrite(void){
	while(1){
		beLazy(100);
		char stringBufferPot[50];
		char stringBufferTemp[50];
		char stringBufferKey[50];
		
		semTake(writeSem, WAIT_FOREVER);
		sprintf(stringBufferTemp, "Temperature: %d   ",AInTemp);
		//sprintf(stringBufferPot, "Potentiomenter: %d   ",AInPot);
		sprintf(stringBufferKey, "Gedrueckte Taste: %d   ", key);
		
		if(key == 49){
			sprintf(stringBufferPot, "Potentiometer: %d                      ",AInPot);
		}
		else if(key == 50){
			//calculation of the voltage based on the input value 58...4095
			float k = (5.0/4037);
			float d = (float)(-k*58);
			float calc = (float)(k* AInPot+d);
			sprintf(stringBufferPot, "Potentiometer: %f V                      ",calc);
		}
		else if (key == 51){
			sprintf(stringBufferPot, "Potentiometer: %x                        ", AInPot);
		}
		else{
			sprintf(stringBufferPot, "Error - key 1,2 or 3 should be used");
		}
		writeToDisplay(0,0, stringBufferPot);
		writeToDisplay(1,0, stringBufferTemp);
		writeToDisplay(2,0, stringBufferKey);
		semGive(writeSem);
	}
}
Пример #2
0
int timer (void)
{
	
	int t;
	char output[32];

	while(1){
		
		time_t t;
		struct tm * timeinfo;

		time ( &t );
		timeinfo = localtime ( &t );
		
		semTake (writeDisplay, WAIT_FOREVER);
		sprintf(output,"Current local time and date: %s", asctime (timeinfo));
		writeToDisplay (10, 2, output );
		
		
		semGive (writeDisplay);
		beLazy (3000);
		
	}
	
}
// Lab02 
void tKeyboard(void){
	while(1){
		beLazy(100);
		//printf("Taste %d gedrückt \n",getKey());
		int tempKey = getKey();
		if(tempKey != 0){
			key = tempKey;
		}
	}
	
}
// for third task
void tWrite(void){
	while(1){
		beLazy(100);
		char stringBufferPot[50];
		char stringBufferTemp[50];
		
		sprintf(stringBufferTemp, "Temperature: %d   ",AInTemp);
		sprintf(stringBufferPot, "Potentiomenter: %d   ",AInPot);
		
		writeToDisplay(0,0, stringBufferPot);
		writeToDisplay(1,0, stringBufferTemp);
	}
	
	
}
Пример #5
0
int readKeyboard (void)
{
	
	
	while(1){
		
		char key;
		key = getKey();
		if(key){
			globalKey=key;
		}
		beLazy (100);
		
	}
	
}
Пример #6
0
int showInputs (void)
{
	char output[64];
	float potiVolt;
	float tempVolt;
	while(1){
		semTake (writeDisplay, WAIT_FOREVER);
		
		sprintf(output,"GlobalKey = %c          ", globalKey);
		writeToDisplay (3, 2, output );
		
		switch(globalKey){
		case '1': writeToDisplay (8, 2, "                         ");
			sprintf(output,"Temperature = %d          ", globalTemp);
			writeToDisplay (5, 2, output );
			sprintf(output,"Poti = %d          ", globalPoti);
			writeToDisplay (6, 2, output );
			break;
		case '2': writeToDisplay (8, 2, "                    ");
			potiVolt=(float)(globalPoti*5)/4095;
			tempVolt=(float)(globalTemp*10)/4095;
			sprintf(output,"Temperature = %f             ", tempVolt);
			writeToDisplay (5, 2, output );
			sprintf(output,"Poti = %f        ", potiVolt);
			writeToDisplay (6, 2, output );
			break;
		case '3': writeToDisplay (8, 2, "                       ");
			sprintf(output,"Temperature = %x          ", globalTemp);
			writeToDisplay (5, 2, output );
			sprintf(output,"Poti = %x           ", globalPoti);
			writeToDisplay (6, 2, output );
			break;
		default: writeToDisplay (8, 2, "Wrong User Input" );
		}
		semGive (writeDisplay);
		beLazy (100);
		
		

	}
	
}
void tTime(void){
	while(1){
		
		time_t timedate;
		beLazy(3000);
		count +=3;
		
		char stringBufferTime[50];
		char stringBufferCount[50];
		
		timedate = time(NULL);
		semTake(writeSem, WAIT_FOREVER);
		sprintf(stringBufferTime, "Aktuelle Zeit: %s", ctime(&timedate));
		sprintf(stringBufferCount, "Count: %d                      ",count);
		
		writeToDisplay(4,0,stringBufferCount);
		writeToDisplay(5,0,stringBufferTime);
		
		semGive(writeSem);
	}
}