cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F429I-Discovery board: SLIDER_Handle

TVan .8
Associate III

I'm trying to work with a slider on the STM32F429I-Discovery board.

I have build a GUI with the GUI-tool.

The widgets are created in the LogViewerDLG.c file as follows:

static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "LogViewer", ID_FRAMEWIN_0, 0, 0, 240, 320, 0, 0x64, 0 },
{ MULTIEDIT_CreateIndirect, "Multiedit", ID_MULTIEDIT_0, 6, 4, 214, 149, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Auto", ID_BUTTON_0, 9, 244, 100, 50, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Manual", ID_BUTTON_1, 117, 244, 100, 50, 0, 0x0, 0 },
{ SLIDER_CreateIndirect, "Slider", ID_SLIDER_0, 7, 164, 214, 35, 0, 0x0, 0 },
{ EDIT_CreateIndirect, "Edit", ID_EDIT_0, 72, 206, 80, 20, 0, 0x64, 0 },

The Multiedit, Edit and buttons all work correctly. I am having trouble working with the slider though.

To set the range and get the slider value I need the SLIDER_Handle hObj. I have no idea what the Handle is or how to find it. I've tried these functions, but they do not work:

SLIDER_SetRange(ID_SLIDER_0,0,50);

SLIDER_GetValue(ID_SLIDER_0);

I gues the SLIDER_ID is not the same the SLIDER_HANDLE?

Does anyone know how to use these functions?

Thx!

1 ACCEPTED SOLUTION

Accepted Solutions
JNova.0
Associate III

Hello,
not long ago, I was dealing with a callback and I found the answer in the detailed description of the source code of the slider and the demo example. I got a reply from ST as well, but it was too late.
The following is declared in the slider code:

GenericCallback<const Slider&, int>* startValueCallback;
GenericCallback<const Slider&, int>* stopValueCallback;
GenericCallback<const Slider&, int>* newValueCallback;

These are events raised on press, release, and scroll.
In the screen, it replaces the event handler.

…
Screen1View::Screen1View():
Slider1StartCallback(this, &Screen1View::Slider1StartCallbackHandler),
Slider1StopCallback(this, &Screen1View::Slider1StopCallbackHandler),
Slider1NewCallback(this, &Screen1View::Slider1NewCallbackHandler)

{
    Slider1.setStartValueCallback(Slider1StartCallback);
    Slider1.setStopValueCallback(Slider1StopCallback);
    Slider1.setNewValueCallback(Slider1NewCallback);
…
void Screen1View::Slider1StartCallbackHandler(const jnSlider& jns, int value_)
{
    // Handle button click event (PRESSED or RELEASED)
//    if (eventtype_ == ClickEvent::PRESSED) {
        // Handle button pressed event
    	touchgfx_printf("START %d \n", value_);
//    } else if (eventtype_ == ClickEvent::RELEASED) {
        // Handle button released event
//    	touchgfx_printf("RELEASED \n");
//    }
}

void Screen1View::SliderStopCallbackHandler(const jnSlider& jns, int value_)
{
    	touchgfx_printf("STOP %d \n", value_);
}

void Screen1View::SliderNewCallbackHandler(const jnSlider& jns, int value_)
{
    	touchgfx_printf("NEW %d \n", value_);

    	invalidate();
}

I was just editing my code, not compiling anything. I've been rewriting the code and I hope I haven't made any mistakes. Callback is simple, but you need to know how to implement it. Everything is described in the manual, but you won't find how to do it there. I hope the description I provided helps.

JN

 

View solution in original post

2 REPLIES 2
JNova.0
Associate III

Hello,
not long ago, I was dealing with a callback and I found the answer in the detailed description of the source code of the slider and the demo example. I got a reply from ST as well, but it was too late.
The following is declared in the slider code:

GenericCallback<const Slider&, int>* startValueCallback;
GenericCallback<const Slider&, int>* stopValueCallback;
GenericCallback<const Slider&, int>* newValueCallback;

These are events raised on press, release, and scroll.
In the screen, it replaces the event handler.

…
Screen1View::Screen1View():
Slider1StartCallback(this, &Screen1View::Slider1StartCallbackHandler),
Slider1StopCallback(this, &Screen1View::Slider1StopCallbackHandler),
Slider1NewCallback(this, &Screen1View::Slider1NewCallbackHandler)

{
    Slider1.setStartValueCallback(Slider1StartCallback);
    Slider1.setStopValueCallback(Slider1StopCallback);
    Slider1.setNewValueCallback(Slider1NewCallback);
…
void Screen1View::Slider1StartCallbackHandler(const jnSlider& jns, int value_)
{
    // Handle button click event (PRESSED or RELEASED)
//    if (eventtype_ == ClickEvent::PRESSED) {
        // Handle button pressed event
    	touchgfx_printf("START %d \n", value_);
//    } else if (eventtype_ == ClickEvent::RELEASED) {
        // Handle button released event
//    	touchgfx_printf("RELEASED \n");
//    }
}

void Screen1View::SliderStopCallbackHandler(const jnSlider& jns, int value_)
{
    	touchgfx_printf("STOP %d \n", value_);
}

void Screen1View::SliderNewCallbackHandler(const jnSlider& jns, int value_)
{
    	touchgfx_printf("NEW %d \n", value_);

    	invalidate();
}

I was just editing my code, not compiling anything. I've been rewriting the code and I hope I haven't made any mistakes. Callback is simple, but you need to know how to implement it. Everything is described in the manual, but you won't find how to do it there. I hope the description I provided helps.

JN

 

Thanks, your answer made me look deeper into the callback functions and I realised I should use the handler of the dialogbox.ow it works with this code:

SLIDER_SetRange(pMsg->hWinSrc,0,50);

slider_value = SLIDER_GetValue(pMsg->hWinSrc);

Wonderful!