cancel
Showing results for 
Search instead for 
Did you mean: 

Hardfault occurs when initial value is set in Slider's setupScreen

Hwoo-
Associate II

Hi,

I am using touchGFX version 4.16.1

​setupScreenSAView::setupScreenSAView()

{

sliderHigh.setValue((uint16_t)((fanset_h1/2) * 10));

}

void setupScreenSAView::sliderMovedSAHigh(int value)

{

  //report to presenter and update text

  presenter->userSetSAFanSpeed();

}

A hardfault occurs when the above function is executed.

But

​setupScreenSAView::setupScreenSAView()

{

//sliderHigh.setValue((uint16_t)((fanset_h1/2) * 10));

}​

​or

void setupScreenSAView::sliderMovedSAHigh(int value)

{

  //report to presenter and update text

  //presenter->userSetSAFanSpeed();

}

If I comment out sliderHigh.setValue(); or presenter->userSetSAFanSpeed(); the hardFault doesn't happen

I have to initialize the Slider and use the presenter as well.

How can I solve this problem ?

Best regards,​

2 REPLIES 2
Romain DIELEMAN
ST Employee

Hi,

Could you give a bit more context to your code and project ? Is the setupScreenSAView() function generated by TouchGFX Designer or is it a custom function (asking this because usually a screen setup would look like this: setup<screen name>View:: setupScreen() )? is the hardfault met in that setup function or in the slider moved function (what does that userSetSAFanSpeed() do exacly, meaning could the error come from it ?

Something to maybe try as well would be to create a variable (or const int) for the value you want to set instead of adding it in the function. It does help sometimes.

/Romain

Hwoo-
Associate II

Hi,

Thanks for the reply.

I changed it like you said and it works normally.

setupScreenSAView::setupScreenSAView()

{

//sliderHigh.setValue((uint16_t)((fanset_h1/2) * 10));

}

void setupScreenSAView::setupScreen()

{

   setupScreenSAViewBase::setupScreen();

sliderHigh.setValue((uint16_t)((fanset_h1/2) * 10));

}

void setupScreenSAView::tearDownScreen()

{

  setupScreenSAViewBase::tearDownScreen();

}

Best regards,​