cancel
Showing results for 
Search instead for 
Did you mean: 

Weird causes with my touchgfx project

Thomas8607
Senior

Hi everybody!

I implemented a keyboard into my project. (I tested the keyboard widget in a separated project, and it worked well).

If I use the keyboard in my dashboard project, it make weird things.
If i entry a value, i write to the eeprom(M95320). If is restart the dashboard, i read all eeprom value.

On the "Beállítások 1" screen work perfect the keyboard and value entry. 
But on the "Beállítások 2" doesn't it work good. The end of the video you can see this.
Keyboard text area wrong and when(2:29) i entry a value to "Levegő tartály szorzó", then change the values some textarea to zero and "Emap nyomás szorzó" will be 5.0.

I don't know where to look for the error, but it's very strange that it doesn't always do it.
Here is the video:
Youtube video 

Thanks!

28 REPLIES 28

If I enter the page:

Thomas8607_0-1713461182457.png

If I press enter, update value:

Thomas8607_1-1713461258365.pngThomas8607_2-1713461289591.png

 

Place code as code no images

Unicode::snprintfFloat(buffer, 20, "%6.4f", 3.14159f);
// buffer="3.1416"

and check all printed is floats and  buffersizes is ok.

I checked all buffersizes and printings.
Why does it at first entry to screen. I dont know where should i search the error/errors.
And why good the "Beállítások 1" screen.

From your code is not clean how keyboard select active object = impossible to help.

 

void SettingsScreen2View::BatteryVoltageMultipleButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	BatteryVoltageMultipleClicked = true;
}
void SettingsScreen2View::BatteryVoltageOffsetButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	BatteryVoltageOffsetClicked = true;
}
void SettingsScreen2View::ImapPressureMultipleButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	ImapPressureMultipleClicked = true;
}
void SettingsScreen2View::ImapPressureOffsetButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	ImapPressureOffsetClicked = true;
}
void SettingsScreen2View::EmapPressureMultipleButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	EmapPressureMultipleClicked = true;
}
void SettingsScreen2View::EmapPressureOffsetButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	EmapPressureOffsetClicked = true;
}
void SettingsScreen2View::AirPressureMultipleButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	AirPressureMultipleClicked = true;
}
void SettingsScreen2View::AirPressureOffsetButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	AirPressureOffsetClicked = true;
}
void SettingsScreen2View::AccelerationMultipleButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	AccelerationMultipleClicked = true;
}
void SettingsScreen2View::AccelerationOffsetButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	AccelerationOffsetClicked = true;
}

hpp file

class SettingsScreen2View : public SettingsScreen2ViewBase
{
public:
    SettingsScreen2View();
    virtual ~SettingsScreen2View() {}
    virtual void setupScreen();
    virtual void tearDownScreen();
    virtual void handleTickEvent();
    virtual void BatteryVoltageMultipleButtonClicked();
    virtual void BatteryVoltageOffsetButtonClicked();
    virtual void ImapPressureMultipleButtonClicked();
    virtual void ImapPressureOffsetButtonClicked();
    virtual void EmapPressureMultipleButtonClicked();
    virtual void EmapPressureOffsetButtonClicked();
    virtual void AirPressureMultipleButtonClicked();
    virtual void AirPressureOffsetButtonClicked();
    virtual void AccelerationMultipleButtonClicked();
    virtual void AccelerationOffsetButtonClicked();
protected:
    bool BatteryVoltageMultipleClicked;
    bool BatteryVoltageOffsetClicked;
    bool ImapPressureMultipleClicked;
    bool ImapPressureOffsetClicked;
    bool EmapPressureMultipleClicked;
    bool EmapPressureOffsetClicked;
    bool AirPressureMultipleClicked;
    bool AirPressureOffsetClicked;
    bool AccelerationMultipleClicked;
    bool AccelerationOffsetClicked;
};

Place breakpoints into all that go to zero. Seems your touch set multiple true ...

And maybe use if keyboard isvisible return... as first line

the whole cpp:

#include <gui/settingsscreen2_screen/SettingsScreen2View.hpp>
#include <extern.h>


SettingsScreen2View::SettingsScreen2View()
{

}

void SettingsScreen2View::setupScreen()
{
    SettingsScreen2ViewBase::setupScreen();
    DisplayValues.ActiveScreenNumber = 5;
    Keyboard.setXY(620, 165);
    Keyboard.resetBuffer();
    Keyboard.setVisible(false);
    Keyboard.invalidate();
    Unicode::snprintfFloat(BatteryVoltageMultipleBuffer, BATTERYVOLTAGEMULTIPLE_SIZE, "%.2f", SettingsValues.BatteryVoltageMultiple);
    BatteryVoltageMultiple.invalidate();
    Unicode::snprintfFloat(BatteryVoltageOffsetBuffer, BATTERYVOLTAGEOFFSET_SIZE, "%.2f", SettingsValues.BatteryVoltageOffset);
    BatteryVoltageOffset.invalidate();
    Unicode::snprintfFloat(ImapPressureMultipleBuffer, IMAPPRESSUREMULTIPLE_SIZE, "%.2f", SettingsValues.ImapMultiple);
    ImapPressureMultiple.invalidate();
    Unicode::snprintfFloat(ImapPressureOffsetBuffer, IMAPPRESSUREOFFSET_SIZE, "%.2f", SettingsValues.ImapOffset);
    ImapPressureOffset.invalidate();
    Unicode::snprintfFloat(EmapPressureMultipleBuffer, EMAPPRESSUREMULTIPLE_SIZE, "%.2f", SettingsValues.EmapMultiple);
    EmapPressureMultiple.invalidate();
    Unicode::snprintfFloat(EmapPressureOffsetBuffer, EMAPPRESSUREOFFSET_SIZE, "%.2f", SettingsValues.EmapOffset);
    EmapPressureOffset.invalidate();
    Unicode::snprintfFloat(AirPressureMultipleBuffer, AIRPRESSUREMULTIPLE_SIZE, "%.2f", SettingsValues.AirPressureMultiple);
    AirPressureMultiple.invalidate();
    Unicode::snprintfFloat(AirPressureOffsetBuffer, AIRPRESSUREOFFSET_SIZE, "%.2f", SettingsValues.AirPressureOffset);
    AirPressureOffset.invalidate();
    Unicode::snprintfFloat(AccelerationMultipleBuffer, ACCELERATIONMULTIPLE_SIZE, "%.2f", SettingsValues.GiroMultiple);
    AccelerationMultiple.invalidate();
    Unicode::snprintfFloat(AccelerationOffsetBuffer, ACCELERATIONOFFSET_SIZE, "%.2f", SettingsValues.GiroOffset);
    AccelerationOffset.invalidate();
}

void SettingsScreen2View::tearDownScreen()
{
    SettingsScreen2ViewBase::tearDownScreen();
    Keyboard.resetBuffer();
    Keyboard.setVisible(false);
    Keyboard.invalidate();
}
void SettingsScreen2View::handleTickEvent()
{
	if(DisplayValues.BootScreenActivate == 1  && DisplayValues.ActiveScreenNumber != 0) {
		static_cast<FrontendApplication*>(Application::getInstance())->gotoBootScreenScreenSlideTransitionEast();
	}
	//Keyboard
	if(Keyboard.enterPressed)
		{
			Keyboard.enterPressed = false;
			if(BatteryVoltageMultipleClicked)
			{
				SettingsValues.BatteryVoltageMultiple = Keyboard.DoubleGetBuffer(-99.99, 9.99);
				//ExtEEPROM.writeToEEPROM(BatteryVoltageMultiple_EEPROMADDRESS, SettingsValues.BatteryVoltageMultiple);
			    Unicode::snprintfFloat(BatteryVoltageMultipleBuffer, BATTERYVOLTAGEMULTIPLE_SIZE, "%f.2", SettingsValues.BatteryVoltageMultiple);
			    BatteryVoltageMultiple.invalidate();
				Keyboard.resetBuffer();
				Keyboard.setVisible(false);
				Keyboard.invalidate();
				BatteryVoltageMultipleClicked = false;
			}
			if(BatteryVoltageOffsetClicked)
			{
				SettingsValues.BatteryVoltageOffset = Keyboard.DoubleGetBuffer(-99.99, 9.99);
				//ExtEEPROM.writeToEEPROM(BatteryVoltageOffset_EEPROMADDRESS, SettingsValues.BatteryVoltageOffset);
			    Unicode::snprintfFloat(BatteryVoltageOffsetBuffer, BATTERYVOLTAGEOFFSET_SIZE, "%.2f", SettingsValues.BatteryVoltageOffset);
			    BatteryVoltageOffset.invalidate();
				Keyboard.resetBuffer();
				Keyboard.setVisible(false);
				Keyboard.invalidate();
				BatteryVoltageOffsetClicked = false;
			}
			if(ImapPressureMultipleClicked)
			{
				SettingsValues.ImapMultiple = Keyboard.DoubleGetBuffer(-99.99, 9.99);
				//ExtEEPROM.writeToEEPROM(ImapMultiple_EEPROMADDRESS, SettingsValues.ImapMultiple);
			    Unicode::snprintfFloat(ImapPressureMultipleBuffer, IMAPPRESSUREMULTIPLE_SIZE, "%.2f", SettingsValues.ImapMultiple);
			    ImapPressureMultiple.invalidate();
				Keyboard.resetBuffer();
				Keyboard.setVisible(false);
				Keyboard.invalidate();
				ImapPressureMultipleClicked = false;
			}
			if(ImapPressureOffsetClicked)
			{
				SettingsValues.ImapOffset = Keyboard.DoubleGetBuffer(-99.99, 9.99);
				//ExtEEPROM.writeToEEPROM(ImapOffset_EEPROMADDRESS, SettingsValues.ImapOffset);
			    Unicode::snprintfFloat(ImapPressureOffsetBuffer, IMAPPRESSUREOFFSET_SIZE, "%.2f", SettingsValues.ImapOffset);
			    ImapPressureOffset.invalidate();
				Keyboard.resetBuffer();
				Keyboard.setVisible(false);
				Keyboard.invalidate();
				ImapPressureOffsetClicked = false;
			}
			if(EmapPressureMultipleClicked)
			{
				SettingsValues.EmapMultiple = Keyboard.DoubleGetBuffer(-99.99, 9.99);
				//ExtEEPROM.writeToEEPROM(EmapMultiple_EEPROMADDRESS, SettingsValues.EmapMultiple);
			    Unicode::snprintfFloat(EmapPressureMultipleBuffer, EMAPPRESSUREMULTIPLE_SIZE, "%.2f", SettingsValues.EmapMultiple);
			    EmapPressureMultiple.invalidate();
				Keyboard.resetBuffer();
				Keyboard.setVisible(false);
				Keyboard.invalidate();
				EmapPressureMultipleClicked = false;
			}
			if(EmapPressureOffsetClicked)
			{
				SettingsValues.EmapOffset = Keyboard.DoubleGetBuffer(-99.99, 9.99);
				//ExtEEPROM.writeToEEPROM(EmapOffset_EEPROMADDRESS, SettingsValues.EmapOffset);
			    Unicode::snprintfFloat(EmapPressureOffsetBuffer, EMAPPRESSUREOFFSET_SIZE, "%.2f", SettingsValues.EmapOffset);
			    EmapPressureOffset.invalidate();
				Keyboard.resetBuffer();
				Keyboard.setVisible(false);
				Keyboard.invalidate();
				EmapPressureOffsetClicked = false;
			}
			if(AirPressureMultipleClicked)
			{
				SettingsValues.AirPressureMultiple = Keyboard.DoubleGetBuffer(-99.99, 9.99);
				//ExtEEPROM.writeToEEPROM(AirPressureMultiple_EEPROMADDRESS, SettingsValues.AirPressureMultiple);
			    Unicode::snprintfFloat(AirPressureMultipleBuffer, AIRPRESSUREMULTIPLE_SIZE, "%.2f", SettingsValues.AirPressureMultiple);
			    AirPressureMultiple.invalidate();
				Keyboard.resetBuffer();
				Keyboard.setVisible(false);
				Keyboard.invalidate();
				AirPressureMultipleClicked = false;
			}
			if(AirPressureOffsetClicked)
			{
				SettingsValues.AirPressureOffset = Keyboard.DoubleGetBuffer(-99.99, 9.99);
				//ExtEEPROM.writeToEEPROM(AirPressureOffset_EEPROMADDRESS, SettingsValues.AirPressureOffset);
			    Unicode::snprintfFloat(AirPressureOffsetBuffer, AIRPRESSUREOFFSET_SIZE, "%.2f", SettingsValues.AirPressureOffset);
			    AirPressureOffset.invalidate();
				Keyboard.resetBuffer();
				Keyboard.setVisible(false);
				Keyboard.invalidate();
				AirPressureOffsetClicked = false;
			}
			if(AccelerationMultipleClicked)
			{
				SettingsValues.GiroMultiple = Keyboard.DoubleGetBuffer(-99.99, 9.99);
				//ExtEEPROM.writeToEEPROM(GiroMultiple_EEPROMADDRESS, SettingsValues.GiroMultiple);
			    Unicode::snprintfFloat(AccelerationMultipleBuffer, ACCELERATIONMULTIPLE_SIZE, "%.2f", SettingsValues.GiroMultiple);
			    AccelerationMultiple.invalidate();
				Keyboard.resetBuffer();
				Keyboard.setVisible(false);
				Keyboard.invalidate();
				AccelerationMultipleClicked = false;
			}
			if(AccelerationOffsetClicked)
			{
				SettingsValues.GiroOffset = Keyboard.DoubleGetBuffer(-99.99, 9.99);
				//ExtEEPROM.writeToEEPROM(GiroOffset_EEPROMADDRESS, SettingsValues.GiroOffset);
			    Unicode::snprintfFloat(AccelerationOffsetBuffer, ACCELERATIONOFFSET_SIZE, "%.2f", SettingsValues.GiroOffset);
			    AccelerationOffset.invalidate();
				Keyboard.resetBuffer();
				Keyboard.setVisible(false);
				Keyboard.invalidate();
				AccelerationOffsetClicked = false;
			}
		}
		if(Keyboard.escPressed)
		{
			Keyboard.escPressed = false;
			BatteryVoltageMultipleClicked = false;
			BatteryVoltageOffsetClicked = false;
			ImapPressureMultipleClicked = false;
			ImapPressureOffsetClicked = false;
			EmapPressureMultipleClicked = false;
			EmapPressureOffsetClicked = false;
			AirPressureMultipleClicked = false;
			AirPressureOffsetClicked = false;
			AccelerationMultipleClicked = false;
			AccelerationOffsetClicked = false;
		}
}

void SettingsScreen2View::BatteryVoltageMultipleButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	BatteryVoltageMultipleClicked = true;
}
void SettingsScreen2View::BatteryVoltageOffsetButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	BatteryVoltageOffsetClicked = true;
}
void SettingsScreen2View::ImapPressureMultipleButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	ImapPressureMultipleClicked = true;
}
void SettingsScreen2View::ImapPressureOffsetButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	ImapPressureOffsetClicked = true;
}
void SettingsScreen2View::EmapPressureMultipleButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	EmapPressureMultipleClicked = true;
}
void SettingsScreen2View::EmapPressureOffsetButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	EmapPressureOffsetClicked = true;
}
void SettingsScreen2View::AirPressureMultipleButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	AirPressureMultipleClicked = true;
}
void SettingsScreen2View::AirPressureOffsetButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	AirPressureOffsetClicked = true;
}
void SettingsScreen2View::AccelerationMultipleButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	AccelerationMultipleClicked = true;
}
void SettingsScreen2View::AccelerationOffsetButtonClicked()
{
	Keyboard.setVisible(true);
	Keyboard.invalidate();
	AccelerationOffsetClicked = true;
}

Yes, you're right! The if branch was executed more than once. I edited the code logic. 

 (with eeprom write and read are good too) 

 

Already only one error, with keyboard only on two screens.

Keyboard Textarea ??? 

and on the other screen the letters

Video 

mncraftmod
Associate

@Thomas8607 wrote:

Hi everybody!

I implemented a keyboard into my project. (I tested the keyboard widget in a separated project, and it worked well).

If I use the keyboard in my dashboard project, it make weird things.
If i entry a value, i write to the eeprom(M95320). If is restart the dashboard, i read all eeprom value.

On the "Beállítások 1" screen work perfect the keyboard and value entry. 
But on the "Beállítások 2" doesn't it work good. The end of the video you can see this.
Keyboard text area wrong and when(2:29) i entry a value to "Levegő tartály szorzó", then change the values some textarea to zero and "Emap nyomás szorzó" will be 5.0.

I don't know where to look for the error, but it's very strange that it doesn't always do it.
Here is the video:
Youtube video
Thanks!


If you find any solution also tell me i am also facing similar type of issue.