Hallo,
ich möchte bei der RP6 Control das Move Programm so ändern, das bei Druck auf Taster 2 die Akkuspannung in Volt auf dem Display angezeigt werden soll (später noch Helligkeit bei Taster 3,..), bei Druck auf Taster 1 dann wieder das Aktive Verhalten. Problem ist jetzt im Display steht in Zeile 1 immer "Akku Spannung", bei Druck auf Taster 2 Steht in Zeile 2 eine 7. Sobald z.B. escape aktiv wird steht dann in Zeile 2 das aktive Verhalten (ohne das der Taster gedrückt wurde).
Hier der code den ich geändert habe:
Code:
void displayBehaviour(uint8_t behave)
{
	static uint8_t compare = 0;
	uint8_t key = getPressedKeyNumber(); 
	while(getPressedKeyNumber());
	
	switch(key)
	{
		case 1:
		compare = 0;
		clearLCD();
		showScreenLCD("Active Behaviour", "");
		
		case 2:
		compare = behave;
		clearLCD();
		showScreenLCD("Akku Spannung", "");
		clearPosLCD(1, 0, 13);
		setCursorPosLCD(1, 0); 
		uint16_t ubat = adcBat;
		uint16_t UinVolts = (ubat / 100);
		writeIntegerLCD(UinVolts, DEC);
		
		
	}
		
	if(compare != behave)
	{
		compare = behave;
		clearPosLCD(1, 0, 13);
		setCursorPosLCD(1, 0); 
		switch(behave)
		{
			case 6: writeStringLCD_P("LOW BATTERY!"); setLEDs(0b0000); break;
			case 5: writeStringLCD_P("WAIT"); setLEDs(0b0000); break;
			case 4: writeStringLCD_P("ESCAPE"); setLEDs(0b0110); break;
			case 3: writeStringLCD_P("AVOID"); setLEDs(0b1001); break;
			case 2: writeStringLCD_P("CRUISE"); setLEDs(0b0000); break;
			case 1: writeStringLCD_P("STOP"); setLEDs(0b0000); break;
		}
	}
	if(behave == 2) // If Cruise behaviour is active, show a running light...
	{
		static uint8_t runLEDs = 1;
		static uint8_t dir = 0;
		if(getStopwatch2() > 100) 
		{
			setLEDs(runLEDs); 
			if(dir == 0)
				runLEDs <<= 1; 
			else
				runLEDs >>= 1;
			if(runLEDs > 7 ) 
				dir = 1;			
			else if (runLEDs < 2 ) 
				dir = 0;
			setStopwatch2(0);
		}
	}
	if(behave == 6) // If Battery is low - beep all 3 seconds!
	{
		if(getStopwatch2() > 3000)  // We can use Stopwatch2 here and 
		{							// for several other things because only
			sound(200,20,20);		// one of these things can be active at 
			sound(225,20,60);		// the same time! You could not do this if
			sound(200,20,20);		// there were things that could be active
			sound(225,20,0);		// at the same time!
			setStopwatch2(0);
		}
	}
}
Außerdem steht bei Akkuspannung nur 7, ich hätte gerne das diese mit Kommastelle angezeigt wird. z.B. wenn ADC_Bat 730 ist: 730/100 = 7,3 Volt