cancel
Showing results for 
Search instead for 
Did you mean: 

Send variable from screen1View.cpp to Model.cpp

OBorz.1
Associate II

Hello,

I would like to send the value of a parameter from screen1View.cpp to Model.cpp.

Is there any way to do this?

I work with TouchGFX 4.14 and STM32429-Eval

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
MM..1
Chief II

When you are newbie, star twith simple think and irq use later. Working solution is config I2C in main and too in main create function to pool read state on joystick, no based on interrupt .

// recomm 400kHz I2C
#define I2CREADTIMEOUT 4
uint8_t joystik_GET_state(void)
{
uint8_t joystik_state[] = {0xFF}; 
 HAL_I2C_Mem_Read(&hi2c1, 0x84, 0x0B, I2C_MEMADD_SIZE_8BIT, joystik_state, 1, I2CREADTIMEOUT);
return joystik_state[0];
}

in model tick

if (joystik_GET_state() &MASKBIT ) 
 
 {
 
  static_cast<FrontendApplication*>(Application::getInstance())->handleKeyEvent(88); // keycode from gui interaction
 
 }

View solution in original post

22 REPLIES 22

What do you mean by parameter? Do you mean a variable? If so define that in main.h for example as extern, then define it completely in main, and then include the header file.

OBorz.1
Associate II

Thanks for the quick replies.

Yes, I mean a variable.

Is it also possible to send the variable directly from screen1View to main.c?

I have already implemented the reverse way. From main.c to Model.cpp using xQueueSendFromISR

All peaple read and use complicated example on TouchGFX. Sending is hard multithread processing, in simple project you can use memory shared variables.

UNDERSTAND uintx_t var;

When is properly used can be changed or read on any place. Nothing sending is required.

But in handletick you need if for compare and detect changing this var .

if(lastvavr!=var) do change on screen.

OBorz.1
Associate II

I'm sorry I don't understand this way.

Do you have an example?

Unzip and read model.cpp screenview.cpp or open .touchgfx file , but is 4.15 . Then run simulator.

OBorz.1
Associate II

it works. Thank you very much!

MM..1
Chief II

Queues is good for situation, when you dont have reference value is displayed or not, or when exist big amount to display and make if for every is complicated.

Then you wait for queue event and then change display once per event. switch case or if is here same , but executed only on event received.

Hello OBorz.1,

When your question is answered, please close this topic by choosing Select as Best.

/Alexandre

OBorz.1
Associate II

Hello,

I have no data to send.

With the queue I want to set a sign that something moves in the display.

Correct: I press the joystick button of the STM32429I-EVAL1 down and a bar in the display should move down.