Announcement

Collapse
No announcement yet.

how to send slider value over serial communication?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Juniel Cruz
    commented on 's reply
    Widgets typically stores its value when you update it. You would normally just need to show the widget again (unless you are resetting the value every time you redraw the form)

    To start the widgets in the middle, then simply set its value before you show it the first time.

    If you are using GCI sliders (those without the letter 'i' in it icon), then you are using img_Show to show the widget and img_SetWord to change its value.

  • amart55
    replied
    Thank you, that worked perfectly. I have a couple more questions, is there a way to have the slider start in the middle and how do I save the position of the slider so when I go to another form then come back to my slider form, the slider position is where I left it last?

    Leave a comment:


  • Juniel Cruz
    replied
    Good day!

    If you already got UART setup properly, then you only need to use serout to send bytes to the Serial communication.

    Code:
    serout(HIbyte(posn));
    serout(LObyte(posn));
    This will send 2 bytes containing the value of the slider.

    Alternatively, if you wish to send it as ASCII string, you can do something like this:

    Code:
    to(COM0); print(posn, "\n");
    This will send a data array containing the string formatted value of slider followed by a line feed at the end.

    I hope this helps.

    Best Regards

    Leave a comment:


  • amart55
    started a topic how to send slider value over serial communication?

    how to send slider value over serial communication?

    I am using the gen4-uLCD-35DT and I am not sure how to go about sending the slider value over serial comm. Below is the code I am using to get the slider functional, I just need some help sending the serial data in Visie.

    Any help is appreciated, thanks.

    Code:
    func Sliders()
    var posn;
    var y;
    y := touch_Get(TOUCH_GETY);
    
    img_Enable(hndl,iSlider1);
    img_Show(hndl,iSlider1) ; // show initialy, if required
    img_ClearAttributes(hndl, iSlider1, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
    posn := y - 111;
    if(posn < 0)
         posn := 100;
    else if(posn > 230)
         posn := 0;
    else
         posn := 100 - 100 * posn / 230;
    endif
    img_SetWord(hndl, iSlider1, IMAGE_INDEX, posn);
    img_Show(hndl,iSlider1) ;
    
    endfunc
Working...
X