Can't get Simple Class Variable

223 views
asked Oct 27, 2017 in Getting started by hakanzi

Hello,

I am developing STM32F7 application with ew. I have to Classes and I need to get the other class variable value when the screen touch event occurs.

In onTouch event

this.ModeText.String = Application::CANDevice.HakanVariable;
Application::CANDevice.HakanVariable =  14;

With first touch, i can see 0 (which is the default value of the variable but then i set the variable to 14 but all the other touches i see the 0 on the screen. 

When i run the prototyper (run on my laptop) it works, i can see the 14 value on the second touch, but it does not work on STM32F769 eval kit

 

What can i do to get this work on STM32F769 eval kit too?

Thanks in advance

2 Answers

0 votes
answered Oct 27, 2017 by Manfred Schweyer

Hello,

it seems, that the autoobject (that contains your data) is destroyed by the Garbage Collector - please have a look to the article Variable loosing their value.

Does this solve the problem?

Best regards,

Manfred.

 

commented Oct 27, 2017 by hakanzi
thanks but it works on my computer, but does not work on eval kit.

I have added a variable to the root object and assigned the value to the variable but stiil works in computer but not the eval kit
commented Oct 27, 2017 by Manfred Schweyer
Some more ideas or questions:

- Does the variable in the root object refer to the autoobject (or to the HakanVariable) ? Ensure to have a variable with type of the autoobject.

- Have you already implemented a DeviceDriver, that is called within your main loop and resetting your HakanVariable to 0? Maybe this is the difference between Prototyper and your target.
commented Oct 27, 2017 by hakanzi
- yes rootobject refer to the root object

- no, i have done nothing in the mainloop or anywhere else :(
0 votes
answered Oct 27, 2017 by Manfred Schweyer

Hi Hakan,

let's make an example together - I assume you are working with STM32F769 Discovery board.

1. Open the original 'DeviceIntegration' example that you will find in the /Example subdirectory of the Build Environment for the STM32F769 Discovery board.

2. Generate code and compile / link / flash the application - just to see that everything is working.

3. Within Embedded Wizard Studio, open the Device Class and add a new property from the Gallery folder 'Device' into the class and rename it to 'HakanVariable':

4. Open the class Application::Application and add a Text view from the Gallery folder 'Views' into the application and choose a suitable font. Add a simple touch handler from the Gallery folder 'EventHandlers' and place it over the text item:

5. Add a slot method from the Gallery folder 'Chora' into the application class and rename it to 'onTouch'.

6. Set the property 'OnPress' of the simple touch handler to 'onTouch' in order to call the slot method 'onTouch' every time the user has pressed the touch area.

7. Open the slot method 'onTouch' within the Editor and add the following code:

Device.HakanVariable = Device.HakanVariable + 1;
Text.String = string( Device.HakanVariable );

Now, when you start the application in the Prototpyer, everytime you touch on the text item, the counter is incremented and updated. 

The same result is also on the target! :-)

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...