Announcement

Collapse
No announcement yet.

How do I read slider values in Serial Environment?

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

  • How do I read slider values in Serial Environment?

    I'm using a uLCD-32PTU as a serial slave to a Parallax Propeller. I've drawn a slider on my screen. I've enabled Touch and set the Touch Region to full screen. Two questions:

    1) My slider's thumb doesn't move. What's missing?
    2) How do I return the thumb values to the Propeller?

    Thanks.


  • #2
    Hello TomLewis,

    Would it be possible to post at least your touch detection routine as well as your widget updating routine?
    It would be easier to resolve this issue that way. You could also add in other snippets that you think are relevant.

    Best Regards,
    Michael
    Michael

    Comment


    • #3
      Here's my stripped down version in C. The area of interest is after the while(1) line.

      #include "simpletools.h" // Include simple tools
      #include "fdserial.h"
      #include "libPicaso.h"
      #include "PICASO_CONST4D.H" // From 4D Systems

      int main()
      {
      char Return3Bytes[3]; // My standard return from functions that return 3 bytes. Usually ignorded.
      int Return;
      char *Time;
      int hours = 3;
      int minutes = 45;

      sys_Reset(15); // Reset is connected to Pin 15.
      pause(5000); // Allow internal reset to complete.

      PTU = fdserial_open(13,14,0,9600); // Controller RX = 13, TX = 14, mode (Not sure), BAUD Rate
      gfx_Cls(); // Clear screen
      gfx_ScreenMode(Return3Bytes, LANDSCAPE); // change screen to landscape mode

      while(1) // forever
      {
      gfx_MoveTo(0x0010, 0x0010);
      txt_FGColour(Return3Bytes, GOLD);
      txt_SetHeight(Return3Bytes, 3);
      txt_SetWidth(Return3Bytes, 3);

      touch_Set(0);
      touch_DetectRegion(0, 0, 320, 240);

      gfx_SetGraphicsParameters(18, RED);
      txt_PutStr(Return3Bytes, "Hours");
      gfx_MoveTo(0x0010, 0x005A);
      txt_PutStr(Return3Bytes, "Minutes");

      Return = gfx_Slider(0x0000, 0x000F, 0x0034, 0x0135, 0x004A, GRAY, 0x0017, hours);
      Return = gfx_Slider(0x0000, 0x000F, 0x007F, 0x0135, 0x0096, GRAY, 0x003B, minutes);
      Return = gfx_Button(0x0001, 0x0090, 0x00C0, GRAY, 0x0001, BLACK, 0x0002, 0x0002, "Accept Time");

      gfx_MoveTo(0x0010, 0x00B9);
      sprintf(Time,"%02d:%02d", hours, minutes);
      txt_PutStr(Return3Bytes, Time);
      pause(1000);
      }
      }


      I'm not sure how to proceed with the detection and updating of the widgets. If there was only one, I could handle it but three widgets is a challenge.

      Comment


      • #4
        Hello TomLewis,

        I don't see any instances of touch_Get() in your code.
        touch_Get() is used for detecting touch, you could check the BIGDEMO sample code for the application of this function.
        BIGDEMO is a sample program from the Picaso serial C library.

        When programing with ViSi/ Designer, a certain algorithm is implemented in order to translate the detected touch region into the correct slider value.

        ViSi example:
        Code:
        posn := y - 8 ;                        // y - top - 8
            if (posn < 0)
                posn := 100 ;                       // maxvalue-minvalue
            else if (posn > 271)                    // height - 17)
                posn := 0 ;
            else
                posn := 100 - 100 * posn / 271 ;    // max-min - (max-min) * posn / (height-17)
            endif
            img_SetWord(hndl, iSlider1, IMAGE_INDEX, posn);
            img_Show(hndl, iSlider1);
        I don't see anything similar to that happening in your code.

        I also don't understand how you're updating "hours" and "minutes", could you please explain what you're planning to do with your program?

        Please check out the BIGDEMO sample code for more clarity on this



        Best Regards,
        Michael

        Michael

        Comment

        Working...
        X