Announcement

Collapse
No announcement yet.

VISI GENIE LCD 43PT DISPLAY RASPBERRY PI -

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

  • VISI GENIE LCD 43PT DISPLAY RASPBERRY PI -

    Hi help would be great , I've just bought a 43pt intelligent display along with a raspberry pi 2 b+, I've manged to make demos on workshop 4 and up loading them to the display . The problem I'm having is making my intelligent display communicate with my basic python scripts I've wrote to operate gpio outputs . And what's needed in my script to make it work . I've tried editing Demos to suit but had no joy ?!

    John
    Last edited by aliweljbh; 23 March 2015, 06:21 PM.

  • #2
    Hi John

    Welcome to the forum.

    Please post your code, both WS4 and your Python code, and hopefully someone will be able to assist you.

    To attach your Workshop4 code, open it in Workshop4, go to File, Zip Project, and attach the zip file it makes to the forum.

    Regards
    James

    Comment


    • #3
      Hi thanks for the reply ive attached my zip file from work shop 4 that ive created. im just after a simple code either in c or python that I can use as a platform to build from if you could help me . I just want to turn relays on through gpio pins on my raspberry pi for now using the intelligent display as a user interface your help would be appreciated .

      Regards

      john
      Attached Files

      Comment


      • #4
        If someone can help please it's been awhile since someone has replied to me !

        Comment


        • #5
          Hello John
          Sorry that no one has replied to you.

          Are the demos that we provide on Github not suitable to get you started?

          Here they are:

          https://github.com/4dsystems/ViSi-Ge...i-Demo-Kitchen
          https://github.com/4dsystems/ViSi-Ge...emo-Calculator
          https://github.com/4dsystems/ViSi-Ge...Pi-Demo-Slider
          https://github.com/4dsystems/ViSi-Ge...mo-SliderGauge
          https://github.com/4dsystems/ViSi-Ge...i-Demo-Monitor

          They have examples of receiving messages from win buttons...

          Regards
          James

          Comment


          • #6
            Also, have you seen the App Note we have for Raspberry Pi and ViSi-Genie?

            http://www.4dsystems.com.au/appnote/4D-AN-00023/

            Download the ZIP file to get PDF and demo code.

            I have personally never tried to write a C program on the PI to talk to Genie.
            I just looked at the demos we provided and put this together. It might help you to get started at least.
            No guarantees that it works. It should in theory (assuming it works), print to your console on the Pi when you press the buttons. You just need to add in whatever code you need to turn on and off the relays you have, however you have them connected to your Pi. You might need to use another library such as WiringPi to control the GPIO.

            Code:
            #include <stdio.h>
            #include <fcntl.h>
            #include <stdlib.h>
            #include <ctype.h>
            #include <string.h>
            #include <errno.h>
            #include <unistd.h>
            #include <sys/types.h>
            
            #include <geniePi.h> // To handle the 4D Systems ViSi-Genie Display
            
            int main ()
            {
              struct genieReplyStruct reply ;
              
              printf ("\n\n\n\n") ;
              printf ("Relay On/Off Demo\n") ;
              printf ("=================\n") ;
            
            // Genie display setup
            // Using the Raspberry Pi's on-board serial port.
            
              if (genieSetup ("/dev/ttyAMA0", 115200) < 0)
              {
                fprintf (stderr, "rgb: Can't initialise Genie Display: %s\n", strerror (errno)) ;
                return 1 ;
              }
            
            // Big loop - just wait for events from the display now
            
              for (;;)
              {
                while (genieReplyAvail ())
                {
                  genieGetReply    (&reply) ;
                  handleGenieEvent (&reply) ;
                }
                usleep (10000) ; // 10mS - Don't hog the CPU in-case anything else is happening...
              }
            
              return 0 ;
            }
            
            void handleGenieEvent (struct genieReplyStruct *reply)
            {
              if (reply->cmd != GENIE_REPORT_EVENT)
              {
                printf ("Invalid event from the display: 0x%02X\r\n", reply->cmd) ;
                return ;
              }
              
              if (reply->object == GENIE_OBJ_WINBUTTON)
              {
                if (reply->index == 0) // Relay1 Button
                {    
                    if (reply->data == 1)
                    {
                        // Set Relay ON
                        printf ("Set Relay1 ON\n");
                    }
                    else if (reply->data == 0)
                    {
                        // Set Relay OFF
                        printf ("Set Relay1 OFF\n");
                    }
                }
                else if (reply->index == 1)    // Relay2 Button
                {
                    if (reply->data == 1)
                    {
                        // Set Relay ON
                        printf ("Set Relay2 ON\n");
                    }
                    else if (reply->data == 0)
                    {
                        // Set Relay OFF
                        printf ("Set Relay2 OFF\n");
                    }
                }
                else if (reply->index == 2)    // Relay3 Button
                {
                    if (reply->data == 1)
                    {
                        // Set Relay ON
                        printf ("Set Relay3 ON\n");
                    }
                    else if (reply->data == 0)
                    {
                        // Set Relay OFF
                        printf ("Set Relay3 OFF\n");
                    }
                }
                else if (reply->index == 3)    // Relay4 Button
                {
                    if (reply->data == 1)
                    {
                        // Set Relay ON
                        printf ("Set Relay4 ON\n");
                    }
                    else if (reply->data == 0)
                    {
                        // Set Relay OFF
                        printf ("Set Relay4 OFF\n");
                    }
                }
                else if (reply->index == 4)    // Relay5 Button
                {
                    if (reply->data == 1)
                    {
                        // Set Relay ON
                        printf ("Set Relay5 ON\n");
                    }
                    else if (reply->data == 0)
                    {
                        // Set Relay OFF
                        printf ("Set Relay5 OFF\n");
                    }
                }
                else if (reply->index == 5)    // Relay6 Button
                {
                    if (reply->data == 1)
                    {
                        // Set Relay ON
                        printf ("Set Relay6 ON\n");
                    }
                    else if (reply->data == 0)
                    {
                        // Set Relay OFF
                        printf ("Set Relay6 OFF\n");
                    }
                }
                else
                  printf ("Unknown Winbutton: %d\n", reply->index) ;
              }
              else
                printf ("Unhandled Event: object: %2d, index: %d data: %d [%02X %02X %04X]\r\n",
                  reply->object, reply->index, reply->data, reply->object, reply->index, reply->data) ;
            }
            I hope this is helpful in some way.

            Our staff are on Easter Break, returning Monday/Tuesday.

            Regards
            James

            Comment


            • #7
              Hi James thank you for your code and sorry for the late reply I've not been to good but finally recovered , after hours of messing about and creating a makefile I finally got your code running on the raspberry , however , the program runs and when a button is pressed it says relay 1( on )and relay 1 (off )once pressed again on the program window on the raspberry pi . How would I get the buttons to operate gpio pins on each button ?

              Thanks john

              Comment


              • #8
                ive tried adding pieces of code from other scripts ive found cant seem to get it to work if someone can help

                #include <stdio.h>
                #include <fcntl.h>
                #include <stdlib.h>
                #include <ctype.h>
                #include <string.h>
                #include <errno.h>
                #include <unistd.h>
                #include <sys/types.h>
                #include <wiringPi.h>
                #include <math.h>

                #include <geniePi.h> // To handle the 4D Systems ViSi-Genie Display

                int main ()
                {
                struct genieReplyStruct reply ;

                printf ("\n\n\n\n") ;
                printf (" Relay On/Off Demo\n") ;
                printf ("=================\n") ;

                // Standard wiringPi Setup

                if (wiringPiSetup () == -1)
                {
                fprintf (stderr, "rgb: Can't initialise wiringPi: %s\n", strerror (errno)) ;
                return 1 ;
                }

                // Genie display setup
                // Using the Raspberry Pi's on-board serial port.

                if (genieSetup ("/dev/ttyAMA0", 115200) < 0)
                {
                fprintf (stderr, "rgb: Can't initialise Genie Display: %s\n", strerror (errno)) ;
                return 1 ;
                }

                // Big loop - just wait for events from the display now

                for (;
                {
                while (genieReplyAvail ())
                {
                genieGetReply (&reply) ;
                handleGenieEvent (&reply) ;
                }
                usleep (10000) ; // 10mS - Don't hog the CPU in-case anything else is happening...
                }

                return 0 ;
                }

                void handleGenieEvent (struct genieReplyStruct *reply)
                {
                if (reply->cmd != GENIE_REPORT_EVENT)
                {
                printf ("Invalid event from the display: 0x%02X\r\n", reply->cmd) ;
                return ;
                }

                #define RELAY1 17
                #define RELAY2 27
                #define RELAY3 7
                #define RELAY4 4
                #define RELAY5 23
                #define RELAY6 22

                void setup()
                {
                // Initialise the pins for OUTPUT
                pinMode(RELAY1, OUTPUT);
                pinMode(RELAY2, OUTPUT);
                pinMode(RELAY3, OUTPUT);
                pinMode(RELAY4, OUTPUT);
                pinMode(RELAY5, OUTPUT);
                pinMode(RELAY6, OUTPUT);
                }

                if (reply->object == GENIE_OBJ_WINBUTTON)
                {
                if (reply->index == 0) // Relay1 Button
                {
                if (reply->data == 1)
                {
                // Set Relay ON
                printf ("Set Relay1 ON\n");
                }
                else if (reply->data == 0)
                {
                // Set Relay OFF
                printf ("Set Relay1 OFF\n");
                }
                }
                else if (reply->index == 1) // Relay2 Button
                {
                if (reply->data == 1)
                {
                // Set Relay ON
                printf ("Set Relay2 ON\n");
                }
                else if (reply->data == 0)
                {
                // Set Relay OFF
                printf ("Set Relay2 OFF\n");
                }
                }
                else if (reply->index == 2) // Relay3 Button
                {
                if (reply->data == 1)
                {
                // Set Relay ON
                printf ("Set Relay3 ON\n");
                }
                else if (reply->data == 0)
                {
                // Set Relay OFF
                printf ("Set Relay3 OFF\n");
                }
                }
                else if (reply->index == 3) // Relay4 Button
                {
                if (reply->data == 1)
                {
                // Set Relay ON
                printf ("Set Relay4 ON\n");
                }
                else if (reply->data == 0)
                {
                // Set Relay OFF
                printf ("Set Relay4 OFF\n");
                }
                }
                else if (reply->index == 4) // Relay5 Button
                {
                if (reply->data == 1)
                {
                // Set Relay ON
                printf ("Set Relay5 ON\n");
                }
                else if (reply->data == 0)
                {
                // Set Relay OFF
                printf ("Set Relay5 OFF\n");
                }
                }
                else if (reply->index == 5) // Relay6 Button
                {
                if (reply->data == 1)
                {
                // Set Relay ON
                printf ("Set Relay6 ON\n");
                }
                else if (reply->data == 0)
                {
                // Set Relay OFF
                printf ("Set Relay6 OFF\n");
                }
                }
                else
                printf ("Unknown Winbutton: %d\n", reply->index) ;
                }
                else
                printf ("Unhandled Event: object: %2d, index: %d data: %d [%02X %02X %04X]\r\n",
                reply->object, reply->index, reply->data, reply->object, reply->index, reply->data) ;
                }

                Comment


                • #9
                  IF ANY BODY CAN HELP ME WITH THE CODE TO OPERATE GPIO OUTPUTS WITHIN THIS CODE ID BE GREATFULL

                  Comment


                  • #10
                    Its only been 4 hours since you last posted - please be patient. We are likely not in the same time zone as you.
                    James

                    Comment


                    • #11
                      Thanks for the reply didn't realise on time zone , I've managed to find some code I think might work if I add it in for relay control just need help with library's an forwarding it to the gpio ?

                      char relayPos = 0; //Holds the current position of the relay
                      char relayRelease = 1; //Holds if trigger has been released yet
                      if(GetOIDInput(1, 1) && relayRelease) //If trigger is pressed after being released
                      {
                      if(relayPos == 1)
                      {
                      SetRelay(1, 0, 1);
                      relayPos = 0;
                      }else
                      {
                      SetRelay(1, 1, 0);
                      relayPos = 1;
                      }
                      relayRelease = 0; //Set trigger as pressed
                      }else if(GetOIDInput(1, 1)==0) //trigger released
                      {
                      relayRelease = 1;
                      }

                      Comment


                      • #12
                        These are really Raspberry Pi questions, nothing to do with our displays.
                        Someone will hopefully try and help soon, but you are probably more suited to get Raspberry Pi code support from elsewhere...
                        James

                        Comment


                        • #13
                          So you sell them as at kit but say these are raspberry pi questions seek help else where ..... False advertising and of course not helpful !! ! ...http://www.4dsystems.com.au/group/Ra...splay_Modules/

                          Comment


                          • #14
                            No thats not what I am saying.

                            We are not raspberry pi experts. We do not write raspberry pi code. If you see from the above code I wrote for you on the 3rd of April, its not something I am an expert in. You are now getting deeper into your project and asking more specific questions about how to set Raspberry Pi GPIO from the Raspberry Pi Code... It has nothing to do with the display, meaning I have no idea how to do it...
                            I have said someone may be able to answer you, but I am suggesting you ask somewhere where Raspberry Pi experts gather, as it will be easy for them to answer.

                            You are obviously impatient or wanting a solution fast, as you posted 4 hours after your last post asking why no one has replied to you. I am merely stating you should ask somewhere where Raspberry Pi people gather so you can get a faster response.
                            James

                            Comment


                            • #15
                              sorry just got that impression . ive managed to add some code in to get it working from examples i found on wiring pi last night, please have a look through to see if it looks ok . it is working just piled everthing i could find in together . i did try to add another 2 relays by copying and pasting and changing it abit but it didnt work. ive put the add on at the bottom if you can have a look please

                              #include <stdio.h>
                              #include <fcntl.h>
                              #include <stdlib.h>
                              #include <ctype.h>
                              #include <string.h>
                              #include <errno.h>
                              #include <unistd.h>
                              #include <sys/types.h>
                              #include <wiringPi.h>
                              #include <math.h>
                              #include <softPwm.h>

                              #include <geniePi.h> // To handle the 4D Systems ViSi-Genie Display

                              int main ()
                              {
                              struct genieReplyStruct reply ;

                              printf ("\n\n\n\n") ;
                              printf (" Relay On/Off Demo\n") ;
                              printf ("=================\n") ;

                              // Standard wiringPi Setup

                              if (wiringPiSetup () == -1)
                              {
                              fprintf (stderr, "rgb: Can't initialise wiringPi: %s\n", strerror (errno)) ;
                              return 1 ;
                              }

                              // Genie display setup
                              // Using the Raspberry Pi's on-board serial port.

                              if (genieSetup ("/dev/ttyAMA0", 115200) < 0)
                              {
                              fprintf (stderr, "rgb: Can't initialise Genie Display: %s\n", strerror (errno)) ;
                              return 1 ;
                              }

                              // Big loop - just wait for events from the display now

                              for (;
                              {
                              while (genieReplyAvail ())
                              {
                              genieGetReply (&reply) ;
                              handleGenieEvent (&reply) ;
                              }
                              usleep (10000) ; // 10mS - Don't hog the CPU in-case anything else is happening...
                              }

                              return 0 ;
                              }

                              void handleGenieEvent (struct genieReplyStruct *reply)
                              {
                              if (reply->cmd != GENIE_REPORT_EVENT)
                              {
                              printf ("Invalid event from the display: 0x%02X\r\n", reply->cmd) ;
                              return ;
                              }
                              #define RELAY1 0
                              #define RELAY2 1
                              #define RELAY3 2
                              #define RELAY4 3
                              #define RELAY5 4
                              #define RELAY6 5
                              #define RELAY7 6
                              #define RELAY8 7

                              void setup()
                              {
                              // Initialise the Raspberry pi data pins for OUTPUT
                              pinMode(0, OUTPUT);
                              pinMode(1, OUTPUT);
                              pinMode(2, OUTPUT);
                              pinMode(3, OUTPUT);
                              pinMode(4, OUTPUT);
                              pinMode(5, OUTPUT);
                              pinMode(6, OUTPUT);
                              pinMode(7, OUTPUT);
                              }
                              if (reply->object == GENIE_OBJ_WINBUTTON)
                              {
                              if (reply->index == 0) // Relay1 Button
                              {
                              if (reply->data == 1)
                              {
                              // Set Relay ON
                              printf ("Set Relay1 ON\n");
                              digitalWrite(0,HIGH); // Turns ON Relays 1
                              }
                              else if (reply->data == 0)
                              {
                              // Set Relay OFF
                              printf ("Set Relay1 OFF\n");
                              digitalWrite(0,LOW); // Turns OFF Relays 1
                              }
                              }
                              else if (reply->index == 1) // Relay2 Button
                              {
                              if (reply->data == 1)
                              {
                              // Set Relay ON
                              printf ("Set Relay2 ON\n");
                              digitalWrite(1,HIGH);
                              }
                              else if (reply->data == 0)
                              {
                              // Set Relay OFF
                              printf ("Set Relay2 OFF\n");
                              digitalWrite(1,LOW);
                              }
                              }
                              else if (reply->index == 2) // Relay3 Button
                              {
                              if (reply->data == 1)
                              {
                              // Set Relay ON
                              printf ("Set Relay3 ON\n");
                              digitalWrite(2,HIGH);
                              }
                              else if (reply->data == 0)
                              {
                              // Set Relay OFF
                              printf ("Set Relay3 OFF\n");
                              digitalWrite(2,LOW);
                              }
                              }
                              else if (reply->index == 3) // Relay4 Button
                              {
                              if (reply->data == 1)
                              {
                              // Set Relay ON
                              printf ("Set Relay4 ON\n");
                              digitalWrite(3,HIGH);
                              }
                              else if (reply->data == 0)
                              {
                              // Set Relay OFF
                              printf ("Set Relay4 OFF\n");
                              digitalWrite(3,LOW);
                              }
                              }
                              else if (reply->index == 4) // Relay5 Button
                              {
                              if (reply->data == 1)
                              {
                              // Set Relay ON
                              printf ("Set Relay5 ON\n");
                              digitalWrite(4,HIGH);
                              }
                              else if (reply->data == 0)
                              {
                              // Set Relay OFF
                              printf ("Set Relay5 OFF\n");
                              digitalWrite(4,LOW);
                              }
                              }
                              else if (reply->index == 5) // Relay6 Button
                              {
                              if (reply->data == 1)
                              {
                              // Set Relay ON
                              printf ("Set Relay6 ON\n");
                              digitalWrite(5,HIGH);
                              }
                              else if (reply->data == 0)
                              {
                              // Set Relay OFF
                              printf ("Set Relay6 OFF\n");
                              digitalWrite(5,LOW);
                              }
                              }
                              else
                              printf ("Unknown Winbutton: %d\n", reply->index) ;
                              }
                              else
                              printf ("Unhandled Event: object: %2d, index: %d data: %d [%02X %02X %04X]\r\n",
                              reply->object, reply->index, reply->data, reply->object, reply->index, reply->data) ;
                              }



                              now for the add on for more relays that didnt work ?? any ideas why ?



                              else if (reply->index == 6) // Relay7 Button
                              {
                              if (reply->data == 1)
                              {
                              // Set Relay ON
                              printf ("Set Relay6 ON\n");
                              digitalWrite(6,HIGH);
                              }
                              else if (reply->data == 0)
                              {
                              // Set Relay OFF
                              printf ("Set Relay6 OFF\n");
                              digitalWrite(6,LOW);
                              }
                              }
                              else if (reply->index == 7) // Relay8 Button
                              {
                              if (reply->data == 1)
                              {
                              // Set Relay ON
                              printf ("Set Relay6 ON\n");
                              digitalWrite(7,HIGH);
                              }
                              else if (reply->data == 0)
                              {
                              // Set Relay OFF
                              printf ("Set Relay6 OFF\n");
                              digitalWrite(7,LOW);
                              }

                              Comment

                              Working...
                              X