Announcement

Collapse
No announcement yet.

Color Picker

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

  • Color Picker

    Hello,
    I am using the uLCD-32PTU connected to an Ardunio Mega2560. I have setup the display in the Visi-Genie environment.
    I selected the "Color Picker" so whenever the operator touched part of the screen the color code will be sent out to the
    Ardunio. Based on the "Color Picker" there should be 3 values sent out. one for RED, one for GREEN and one for BLUE.

    But when I used the GTX in the TOOL menu, the display only sends out 2 values that relates to the color. I am going to use
    the Ardunio to turn a RGB LED light to different colors. And it need the 3 values (RED, GREEN, BLUE).

    Why does the "Color Picker" sending out only 2 values?
    Is there anyway I can translate that to the 3 values required?
    Is there any other ways, I can use something like the Color Picker to do this?

    Is there any examples available?

    Thanks

    Bobby

  • #2
    Hello Bobby,

    The colour picker will only return 16 - bit colour values as this is the format of the screen.
    You can try using this formula that has also been answered in your technical support tickets.

    R8 = ( (color >> 11) * 527 + 23 ) >> 6;
    G8 = ( ((color >> 5) & 0x3f) * 259 + 33 ) >> 6;
    B8 = ( (color & 1f) * 527 + 23 ) >> 6;

    It has been tested and it work. I hope this helps.

    Best regards,
    Bern

    Comment


    • #3
      Hello Bern,

      That is Excellent. The only comment I have is that in the 3rd line (color & 1f) should be (color & 0x1f).
      It works great.
      My last question is that the COLOR PICKER has an arrow on the right side of it. This arrow suppose to make the color darker or brighter.
      But when I move it, it does not make any difference in the color.

      Please look at the picture I have attached.
      Is there any way I can make that arrow to function the way it suppose to.

      Thank You

      Best Regards
      Bobby
      Attached Files

      Comment


      • #4
        Hello,

        Having the color picker in the ViSi Genie environment dont have a preview box for the color variation.
        You will need to use Magic in order to utilize the touch functionality for color selection.

        Alternatively you can use ViSi environment instead. There you'll have an automatic preview box for color variation.
        I have attached a sample code for you. I hope it helps.

        Best regards,
        Bern
        Attached Files

        Comment


        • #5
          Hello,

          My project is consist of few forms, buttons, Sliders, Gages, ... that is made in the ViSi Genie environment. It is going to be very hard to start all over
          again and do everything is ViSi.
          Is there any way to just make a conversion from one environment to another?

          Thanks

          Best Regards
          Bobby

          Comment


          • #6
            Hello,

            Yes there is a way to convert ViSi Genie project to a ViSi project, you just need to save your project as a
            ViSi project type using the "Save As" option in the the File tab of the Workshop4 IDE. Just save your ViSi project under a new name.

            I hope this helps.

            Best regards,
            Bern

            Comment


            • #7
              Hello Bern,

              I am sorry that I was not clear. I like the Genie environment and will be adding a lot of more forms, etc to the project.
              What I like to do is to Convert the Color Picker you sent in ViSi to Genie-ViSi project.

              Thanks

              Best Regards

              Bobby

              Comment


              • #8
                Hello Again,

                I forgot to let you know that I tried to SAVE it AS Genie-ViSi project. But it does not work. The Genie-ViSi environment does not
                recognize the new project. It still is in ViSi format.

                Thanks Again
                Bobby

                Comment


                • #9
                  Hello Bern,

                  My apologies. The Color Picker Arrow works fine in the Genie-ViSi environment. So I do not have to transfer the Project to Visi.
                  The problem is Ardunio Mega2560 library file called "genieArdunio.h". It does define the Color Picker main area. But it does not
                  define the ARROW part of it. That is the reason the main area works, but it ignore the ARROW part.

                  I know that the uLCD-32PTU does send out the data out to Ardunio via serial port. It is the Ardunio that ignores the ARROW section.

                  I do not know if there is a new library available for it. Or if there is any other ways that I can just have the Ardunio read the data coming in.

                  Any idea.

                  Thank You.

                  Best Regards

                  Bobby

                  Comment


                  • #10
                    Hello,

                    The arrow part of the color picker doesn't have a return value and thats mainly the reason why it doesnt send value to be able to read by the Arduino host.

                    On the sample image below the highlight part in the ViSi code handle the arrow part of the color picker.
                    Now in ViSi Geie it is already combine for the reason that the color is already 16 bit adding it and sending to Arduino is not applicable.
                    So it doesn't have a return value.

                    If you wish to utilize the arrow part of the color picker you'll have to customize code for it or you can use Magic.

                    Best regards,
                    Bern

                    Attached Files

                    Comment


                    • #11
                      Hello Bern,

                      I am confused. I use the uUSB-PAS-II cable that is used to program and download into the uLCD-32PTU. using this cable and then the GTX monitoring of the serial port shows that moving the ARROW up and down, values are being sent out through the serial port. So I think values are being sent out of
                      uLCD-32PTU but the Ardunio is not reading it. So I was hoping that I can use any other functions from the genieArdunio.h library to force a serial read on the Ardunio side.
                      Then read the value and use your formual shown above to get the 3 values needed for the LEDs.

                      Is that possible?

                      Thanks

                      Bobby

                      Comment


                      • #12

                        Hello,

                        I have attached a sample code for you to try using Arduino. I hope this help.
                        Also you can look at this related project for additional references, https://www.4dsystems.com.au/appnote/4D-AN-00029/
                        and you can follow this thread as well https://forum.4dsystems.com.au/forum...put-to-arduino.
                        Hope this helps.

                        Best regards,
                        Bern
                        Attached Files
                        Last edited by bernadette; 2nd October 2018, 11:46 AM.

                        Comment


                        • #13
                          Hello Bern,

                          This program does the same as my program. The main screen part of the Color picker works but the Arrow part does not work.
                          The Ardunio does not receive or check the data on the serial port when the Arrow moves up or down.
                          I know the uLCD-32PTU is sending the data because when I use the GTX, the serial port shows the data.
                          But no data when the Ardunio is connected.
                          As I stated above, I think the genieArdunio.h library needs to be updated to look for the Arrow status.

                          Thanks

                          Bobby

                          Comment


                          • #14
                            Hello,

                            Again, the arrow to the color picker is integrated with the main color picker area,
                            in short both the main window and the side bar with the arrow output will output
                            data under the same colorpicker ID. You might need to do some touch calibration
                            since you mentioned that the arrow part does not send any data back as it normally should.

                            For the Arduino, you could check if the baud rate is the same as the display.
                            If possible you could also post your Genie Arduino routines here, for testing.

                            Best regards,
                            Bern

                            Comment


                            • #15
                              Hello,

                              Attached are the 2 files that I am using. I like to remind you that the Arrow part of the display works fine when I use the GTX in the 4D WORKSHOP
                              environment.
                              But when I connect the Ardunio board, the Color screen works but the ARROW part does not.

                              I had to add an extension .txt to the Genie program to upload the file here. So just rename the file and remove the .txt from the extension.

                              Thanks

                              Bobby
                              Attached Files

                              Comment

                              Working...
                              X